Rev 96 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 96 | Rev 169 | ||
---|---|---|---|
Line 4... | Line 4... | ||
4 | Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, Tord Romstad |
4 | Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, Tord Romstad |
5 | Copyright (C) 2015- |
5 | Copyright (C) 2015-2018 Marco Costalba, Joona Kiiski, Gary Linscott, Tord Romstad |
6 | 6 | ||
7 | Stockfish is free software: you can redistribute it and/or modify |
7 | Stockfish is free software: you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by |
8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation, either version 3 of the License, or |
9 | the Free Software Foundation, either version 3 of the License, or |
10 | (at your option) any later version. |
10 | (at your option) any later version. |
Line 18... | Line 18... | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | */ |
19 | */ |
20 | 20 | ||
21 | #ifndef MOVEGEN_H_INCLUDED |
21 | #ifndef MOVEGEN_H_INCLUDED |
22 | #define MOVEGEN_H_INCLUDED |
22 | #define MOVEGEN_H_INCLUDED |
- | 23 | ||
- | 24 | #include <algorithm> |
|
23 | 25 | ||
24 | #include "types.h" |
26 | #include "types.h" |
25 | 27 | ||
26 | class Position; |
28 | class Position; |
27 | 29 | ||
Line 34... | Line 36... | ||
34 | LEGAL |
36 | LEGAL |
35 | }; |
37 | }; |
36 | 38 | ||
37 | struct ExtMove { |
39 | struct ExtMove { |
38 | Move move; |
40 | Move move; |
39 |
|
41 | int value; |
40 | 42 | ||
41 | operator Move() const { return move; } |
43 | operator Move() const { return move; } |
42 | void operator=(Move m) { move = m; } |
44 | void operator=(Move m) { move = m; } |
- | 45 | ||
- | 46 | // Inhibit unwanted implicit conversions to Move |
|
- | 47 | // with an ambiguity that yields to a compile error. |
|
- | 48 | operator float() const = delete; |
|
43 | }; |
49 | }; |
44 | 50 | ||
45 | inline bool operator<(const ExtMove& f, const ExtMove& s) { |
51 | inline bool operator<(const ExtMove& f, const ExtMove& s) { |
46 | return f.value < s.value; |
52 | return f.value < s.value; |
47 | } |
53 | } |
Line 57... | Line 63... | ||
57 | explicit MoveList(const Position& pos) : last(generate<T>(pos, moveList)) {} |
63 | explicit MoveList(const Position& pos) : last(generate<T>(pos, moveList)) {} |
58 | const ExtMove* begin() const { return moveList; } |
64 | const ExtMove* begin() const { return moveList; } |
59 | const ExtMove* end() const { return last; } |
65 | const ExtMove* end() const { return last; } |
60 | size_t size() const { return last - moveList; } |
66 | size_t size() const { return last - moveList; } |
61 | bool contains(Move move) const { |
67 | bool contains(Move move) const { |
62 |
|
68 | return std::find(begin(), end(), move) != end(); |
63 | return false; |
- | |
64 | } |
69 | } |
65 | 70 | ||
66 | private: |
71 | private: |
67 | ExtMove moveList[MAX_MOVES], *last; |
72 | ExtMove moveList[MAX_MOVES], *last; |
68 | }; |
73 | }; |