]> git.sesse.net Git - stockfish/blobdiff - src/movegen.h
Improve grammar of comments
[stockfish] / src / movegen.h
index d46b8ddb7c9b4d5021fdbbcd13ff5dd59d2872ca..5eee2f1acf8647cdbefce1ce5f60cc0153c29678 100644 (file)
@@ -1,7 +1,6 @@
 /*
   Stockfish, a UCI chess playing engine derived from Glaurung 2.1
-  Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
-  Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, Tord Romstad
+  Copyright (C) 2004-2023 The Stockfish developers (see AUTHORS file)
 
   Stockfish is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
 #ifndef MOVEGEN_H_INCLUDED
 #define MOVEGEN_H_INCLUDED
 
+#include <algorithm> // IWYU pragma: keep
+#include <cstddef>
+
 #include "types.h"
 
+namespace Stockfish {
+
 class Position;
 
 enum GenType {
@@ -35,9 +39,14 @@ enum GenType {
 
 struct ExtMove {
   Move move;
-  Value value;
+  int value;
 
   operator Move() const { return move; }
+  void operator=(Move m) { move = m; }
+
+  // Inhibit unwanted implicit conversions to Move
+  // with an ambiguity that yields to a compile error.
+  operator float() const = delete;
 };
 
 inline bool operator<(const ExtMove& f, const ExtMove& s) {
@@ -47,8 +56,9 @@ inline bool operator<(const ExtMove& f, const ExtMove& s) {
 template<GenType>
 ExtMove* generate(const Position& pos, ExtMove* moveList);
 
-/// The MoveList struct is a simple wrapper around generate(). It sometimes comes
-/// in handy to use this class instead of the low level generate() function.
+/// The MoveList struct wraps the generate() function and returns a convenient
+/// list of moves. Using MoveList is sometimes preferable to directly calling
+/// the lower level generate() function.
 template<GenType T>
 struct MoveList {
 
@@ -57,12 +67,13 @@ struct MoveList {
   const ExtMove* end() const { return last; }
   size_t size() const { return last - moveList; }
   bool contains(Move move) const {
-    for (const auto& m : *this) if (m == move) return true;
-    return false;
+    return std::find(begin(), end(), move) != end();
   }
 
 private:
   ExtMove moveList[MAX_MOVES], *last;
 };
 
+} // namespace Stockfish
+
 #endif // #ifndef MOVEGEN_H_INCLUDED