Skip to content

Commit d3a5371

Browse files
committed
Rename 'move' to avoid name clash in C++11
1 parent 3c9e56a commit d3a5371

File tree

7 files changed

+27
-27
lines changed

7 files changed

+27
-27
lines changed

src/ChessBoard.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ bool ChessBoard::can_move(int from, int to, piece_type promotion) const {
401401
// - returns a list of all squares where the king may move
402402
// -------------------------------------------------------------------
403403
move_list ChessBoard::mobility_king(int from) const {
404-
move m;
404+
chessmove m;
405405
move_list ml;
406406
m.promotion=Empty;
407407
m.from=from;
@@ -457,7 +457,7 @@ move_list ChessBoard::mobility_king(int from) const {
457457
// - returns a list of all squares where the knight may move
458458
// -------------------------------------------------------------------
459459
move_list ChessBoard::mobility_knight(int from) const {
460-
move m;
460+
chessmove m;
461461
move_list ml;
462462
m.promotion=Empty;
463463
m.from=from;
@@ -482,7 +482,7 @@ move_list ChessBoard::mobility_knight(int from) const {
482482
// - returns a list of all squares where the pawn may move
483483
// -------------------------------------------------------------------
484484
move_list ChessBoard::mobility_pawn(int from) const {
485-
move m;
485+
chessmove m;
486486
move_list ml;
487487
m.promotion=Empty;
488488
m.from=from;
@@ -540,7 +540,7 @@ move_list ChessBoard::mobility_pawn(int from) const {
540540
// - returns a list of all squares where the rook may move
541541
// -------------------------------------------------------------------
542542
move_list ChessBoard::mobility_rook(int from) const {
543-
move m;
543+
chessmove m;
544544
move_list ml;
545545
m.promotion=Empty;
546546
m.from=from;
@@ -568,7 +568,7 @@ move_list ChessBoard::mobility_rook(int from) const {
568568
// - returns a list of all squares where the bishop may move
569569
// -------------------------------------------------------------------
570570
move_list ChessBoard::mobility_bishop(int from) const {
571-
move m;
571+
chessmove m;
572572
move_list ml;
573573
m.promotion=Empty;
574574
m.from=from;
@@ -681,7 +681,7 @@ bool ChessBoard::is_attacked(bool by_white, int to) const {
681681
// -------------------------------------------------------------------
682682
// Determine whether the given move puts one's own king in check
683683
// -------------------------------------------------------------------
684-
bool ChessBoard::causes_check(const move& m) const {
684+
bool ChessBoard::causes_check(const chessmove& m) const {
685685
bool w_turn=is_white(square[m.from]);
686686
ChessBoard c=*this;
687687
piece_type promotion=m.promotion;

src/ChessBoard.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ class ChessBoard {
3838
virtual ~ChessBoard();
3939
void print(ostream *os) const;
4040
bool can_move(int from, int to, piece_type promotion=Empty) const;
41-
bool can_move(const move &m) const
41+
bool can_move(const chessmove &m) const
4242
{return can_move(m.from, m.to, m.promotion);}
4343
game_status do_move(int from, int to, piece_type promotion=Empty);
44-
game_status do_move(const move& m)
44+
game_status do_move(const chessmove& m)
4545
{return do_move(m.from, m.to, m.promotion);}
4646
bool white_moves(void) const;
4747
static bool show_reverse;
@@ -68,7 +68,7 @@ class ChessBoard {
6868

6969
bool triple_occurrence(void) const;
7070
bool is_attacked(bool by_white, int to) const;
71-
bool causes_check(const move& m) const;
71+
bool causes_check(const chessmove& m) const;
7272
bool is_in_check(bool white) const;
7373
bool is_black(piece_type p) const;
7474
bool is_white(piece_type p) const;

src/ComputerPlayer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ void ComputerPlayer::set_stats() {
141141
// -------------------------------------------------------------------
142142
string ComputerPlayer::get_command(const ChessBoard &b) const {
143143
if (b.in_progress) {
144-
move mv;
144+
chessmove mv;
145145
long v=alphabeta(b, ply,-LONG_MAX,LONG_MAX,mv);
146146
// To offer draw:
147147
// if v<DRAW_THRESHOLD && haven't_offered_draw_in_a_while then
@@ -296,7 +296,7 @@ long ComputerPlayer::get_score(const ChessBoard &b) const {
296296
// Alpha beta game tree search
297297
// -------------------------------------------------------------------
298298
long ComputerPlayer::alphabeta(const ChessBoard &b, long depth, long alpha,
299-
long beta, move &chosen_move) const {
299+
long beta, chessmove &chosen_move) const {
300300
if (depth==0)
301301
return get_score(b);
302302

@@ -305,7 +305,7 @@ long ComputerPlayer::alphabeta(const ChessBoard &b, long depth, long alpha,
305305
return get_score(b);
306306

307307
long best_score=-LONG_MAX;
308-
move best_move=*(moves.begin());
308+
chessmove best_move=*(moves.begin());
309309
for (move_list::iterator i=moves.begin();
310310
i!=moves.end() && best_score<beta; ++i) {
311311
ChessBoard c=b;

src/ComputerPlayer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class ComputerPlayer : public Player {
7878
int manhattan(int from, int to) const;
7979
move_list get_all_moves(const ChessBoard &b) const;
8080
long get_score(const ChessBoard &b) const;
81-
long alphabeta(const ChessBoard &b, long depth, long alpha, long beta, move &chosen_move) const;
81+
long alphabeta(const ChessBoard &b, long depth, long alpha, long beta, chessmove &chosen_move) const;
8282
bool adjacent_friendly_pawns(const ChessBoard &b, int sq) const;
8383
long rook_mobility(const ChessBoard &b, int from) const;
8484
long bishop_mobility(const ChessBoard &b, int from) const;

src/cheops.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include <cstring>
3434

3535
void show_menu(void);
36-
move *parse_move(const string& s);
36+
chessmove *parse_move(const string& s);
3737
void who_plays(Player *&w, Player *&b);
3838
void show_help(void);
3939
void show_version(void);
@@ -44,7 +44,7 @@ int main(int argc, char* argv[]) {
4444
Player *w_player=NULL, *b_player=NULL, *this_player;
4545
string cmd, log;
4646
game_status status=Normal;
47-
move *m = NULL;
47+
chessmove *m = NULL;
4848
int turn=0;
4949

5050
// Process command-line parameters
@@ -123,14 +123,14 @@ int main(int argc, char* argv[]) {
123123
delete m;
124124
// Kingside castling
125125
if (cmd=="o-o") {
126-
m = new move;
126+
m = new chessmove;
127127
m->promotion=Empty;
128128
m->from=this_player==w_player?e1:e8;
129129
m->to=this_player==w_player?g1:g8;
130130
}
131131
// Queenside castling
132132
else if (cmd=="o-o-o") {
133-
m = new move;
133+
m = new chessmove;
134134
m->promotion=Empty;
135135
m->from=this_player==w_player?e1:e8;
136136
m->to=this_player==w_player?c1:c8;
@@ -208,9 +208,9 @@ void show_menu(void) {
208208

209209
// -------------------------------------------------------------------
210210
// Parse move
211-
// - returns pointer to a move structure on success, else NULL
211+
// - returns pointer to a chessmove structure on success, else NULL
212212
// -------------------------------------------------------------------
213-
move *parse_move(const string& s) {
213+
chessmove *parse_move(const string& s) {
214214

215215
// Is this a valid move string?
216216
int len=s.length();
@@ -221,7 +221,7 @@ move *parse_move(const string& s) {
221221
return NULL;
222222

223223
// Determine promotion type
224-
move *m = new move;
224+
chessmove *m = new chessmove;
225225
if (len==5) {
226226
switch(s[4]) {
227227
case 'q':

src/move.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// $Id$
22
//
3-
// move.cpp: implementation of the move struct.
3+
// move.cpp: implementation of the chessmove struct.
44
//
55
// Copyright (C) 2003 Tristan Miller <psychonaut@nothingisreal.com>
66
//
@@ -27,14 +27,14 @@
2727
// -------------------------------------------------------------------
2828
// Print move (<< operator overload)
2929
// -------------------------------------------------------------------
30-
ostream &operator<<(ostream &os, const move &m) {
30+
ostream &operator<<(ostream &os, const chessmove &m) {
3131
return os << (string)m;
3232
}
3333

3434
// -------------------------------------------------------------------
3535
// Cast move to string
3636
// -------------------------------------------------------------------
37-
move::operator string() const {
37+
chessmove::operator string() const {
3838
static char s[6]="\0\0\0\0\0";
3939
s[0] = (char)(ChessBoard::which_file(this->from)+'a');
4040
s[1] = (char)(ChessBoard::which_rank(this->from)+'1');

src/move.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// $Id$
22
//
3-
// move.h: interface for the move struct.
3+
// move.h: interface for the chessmove struct.
44
//
55
// Copyright (C) 2003 Tristan Miller <psychonaut@nothingisreal.com>
66
//
@@ -26,15 +26,15 @@
2626

2727
#include "ChessTypes.h"
2828

29-
struct move {
29+
struct chessmove {
3030
int from;
3131
int to;
3232
piece_type promotion;
3333
operator string() const;
3434
};
3535

36-
typedef list<move> move_list;
36+
typedef list<chessmove> move_list;
3737

38-
ostream &operator<<(ostream &os, const move &m);
38+
ostream &operator<<(ostream &os, const chessmove &m);
3939

4040
#endif // !defined(AFX_MOVE_H__EBEFC224_5256_11D3_BC7B_0080C84DB68D__INCLUDED_)

0 commit comments

Comments
 (0)