MoveIterator.inl
Go to the documentation of this file.
1 // cwchessboard -- A C++ chessboard tool set
2 //
3 //! @file MoveIterator.inl This file contains the inline definitions of class MoveIterator.
4 //
5 // Copyright (C) 2008, by
6 //
7 // Carlo Wood, Run on IRC <carlo@alinoe.com>
8 // RSA-1024 0x624ACAD5 1997-01-26 Sign & Encrypt
9 // Fingerprint16 = 32 EC A7 B6 AC DB 65 A6 F6 F6 55 DD 1C DC FF 61
10 //
11 // This program is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 2 of the License, or
14 // (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 
24 namespace cwchess {
25 
26 inline Type MoveIterator::initial_type(Index const& index) const
27 {
28  Piece const& piece(M_chess_position->piece_at(index));
29  if (piece != pawn)
30  return nothing;
31  return (index.row() == ((piece == white) ? 6 : 1)) ? queen : nothing;
32 }
33 
34 inline MoveIterator::MoveIterator(ChessPosition const* chess_position, Index const& index) :
35  M_chess_position(chess_position), M_targets(chess_position->moves(index)), M_current_move(index, get_first_bitindex(), initial_type(index)) { }
36 
37 } // namespace cwchess
38 
A namespace for all chess related objects that are not related to the GUI.
Definition: Array.h:39
TypeData const queen
A constant representing a queen.
Definition: Type.h:75
ColorData const white
A constant representing the color white.
Definition: Color.h:55
TypeData const pawn
A constant representing a pawn.
Definition: Type.h:65
MoveIterator(void)
Construct a one-past-the-end MoveIterator.
Definition: MoveIterator.h:73
The index of a chess square.
Definition: Index.h:211
ChessPosition const * M_chess_position
The underlaying chess position.
Definition: MoveIterator.h:60
Piece piece_at(Index const& index) const
Return the Piece on the square index.
Move M_current_move
The actual move that is returned when dereferenced.
Definition: MoveIterator.h:62
A chess position.
Definition: ChessPosition.h:50
TypeData const nothing
A constant representing the absence of a piece.
Definition: Type.h:63
BitBoard M_targets
The targets that this piece can move to.
Definition: MoveIterator.h:61

Copyright © 2006 - 2010 Carlo Wood.  All rights reserved.