2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2007 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
14 #include "taguaobject.h"
19 class IPoolCollection
;
23 * @brief The state of the game in a given moment of time.
25 * A State component encapsulates the global state of the game, i.e.
26 * what pieces are on the board or on the pool, and game flags like
27 * the en-passant square for chess.
29 * A State component also provides methods to setup the initial
30 * configuration and to make a move.
32 class TAGUA_EXPORT IState
{
36 virtual IState
* clone() const = 0;
39 * Setup the initial configuration of pieces and reset all flags.
41 virtual void setup() = 0;
44 * @return The piece board.
46 virtual const Board
* board() const = 0;
47 virtual Board
* board() = 0;
50 * @return The player who plays next.
52 virtual const IColor
* turn() const = 0;
55 * Change the current turn.
57 virtual void setTurn(const IColor
* turn
) = 0;
60 * @return Whether two states are equal.
62 virtual bool equals(IState
* other
) const = 0;
65 * Make this state equal to the given one.
67 virtual void assign(const IState
* other
) = 0;
72 virtual void move(const Move
& move
) = 0;
75 * @return Current flags.
77 virtual TaguaObject
* flags() = 0;
78 virtual const TaguaObject
* flags() const = 0;
81 * @return The absolute index of the n-th rank for a given player.
83 virtual int rank(int n
, const IColor
* turn
) const = 0;
86 * @return The pool collection associated to this state.
88 virtual const IPoolCollection
* pools() const = 0;
89 virtual IPoolCollection
* pools() = 0;
92 * @return The behaviour object associated to this state.
94 virtual const IBehaviour
* behaviour() const = 0;
96 virtual void setDelegator(IState
* state
) = 0;
99 #endif // CORE__STATE_H