Tentative MiniShogi implementation over move generator.
[tagua/yd.git] / src / variants / minishogi / state.cpp
blob2c4ffe7aae9c78ed01a7385612b7fc833d88be47
1 #include "global.h"
2 #include "state.h"
4 #include <core/board.h>
5 #include <core/color.h>
7 namespace MiniShogi {
9 State::State(IState* state)
10 : Delegators::State(state) { }
12 IState* State::clone() const { return new State(m_state->clone()); }
14 #define COL(i,c) players[c]==White::self() ? i : board()->size().x - i - 1
15 void State::setup() {
16 for (int c = 0; c < 2; c++) {
17 const IColor* color = players[c];
18 int r0 = rank(0, color);
19 int r1 = rank(1, color);
21 board()->set(Point(COL(0,c), r1), Piece(color, pawn));
22 board()->set(Point(COL(0,c), r0), Piece(color, king));
23 board()->set(Point(COL(1,c), r0), Piece(color, gold));
24 board()->set(Point(COL(2,c), r0), Piece(color, silver));
25 board()->set(Point(COL(3,c), r0), Piece(color, bishop));
26 board()->set(Point(COL(4,c), r0), Piece(color, rook));
29 setTurn(White::self());
31 #undef COL
33 } // namespace MiniShogi