Tentative MiniShogi implementation over move generator.
[tagua/yd.git] / src / variants / minishogi / state.cpp
blob185f716502a03479df2a4e784f9beef6ec736bb2
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::DefaultState(state) { }
12 IState* State::clone() const {
13 return new State(m_dgate_defaultstate->clone());
16 #define COL(i,c) players[c]==White::self() ? i : board()->size().x - i - 1
17 void State::setup() {
18 for (int c = 0; c < 2; c++) {
19 const IColor* color = players[c];
20 int r0 = rank(0, color);
21 int r1 = rank(1, color);
23 board()->set(Point(COL(0,c), r1), Piece(color, pawn));
24 board()->set(Point(COL(0,c), r0), Piece(color, king));
25 board()->set(Point(COL(1,c), r0), Piece(color, gold));
26 board()->set(Point(COL(2,c), r0), Piece(color, silver));
27 board()->set(Point(COL(3,c), r0), Piece(color, bishop));
28 board()->set(Point(COL(4,c), r0), Piece(color, rook));
31 setTurn(White::self());
33 #undef COL
35 } // namespace MiniShogi