control loop in AbstractGame + minor update in API documentation + minor change of name in a getter

This commit is contained in:
2025-09-19 09:59:13 +02:00
parent bb2b77d208
commit f7f50f9ca8
3 changed files with 95 additions and 18 deletions

View File

@@ -11,7 +11,7 @@ public interface IBoard {
/**
* @return the current player
*/
public Player getcurrentPlayer();
public Player getCurrentPlayer();
/**
* Returns the game status
@@ -27,10 +27,9 @@ public interface IBoard {
public Result getResult();
/**
* checker of legal moves from this position
* checker of the legality of a ply from this position
*
* @throws NullPointerException if the game is over
* @return the iterator
* @return true iff the ply is legal
*/
public boolean isLegal(AbstractPly c);
@@ -39,7 +38,6 @@ public interface IBoard {
/**
* constructor of Iterator over legal moves from this position
*
* @throws NullPointerException if the game is over
* @return the iterator
*/
public Iterator<AbstractPly> iterator();
@@ -48,7 +46,7 @@ public interface IBoard {
/**
* Plays a given move on the plateau.
* Should update history using
*
* @throws IllegalArgumentException if the move is always illegal (say from the wrong game)
* @throws IllegalStateException if the move is not legal in this position
*
@@ -60,10 +58,22 @@ public interface IBoard {
/**
* Resets the plateau to the position before the last move.
*
* @throws IllegalStateException if nothing to undo in history
* @throws IllegalStateException if nothing to undo
*
*/
public void undoPly();
/**
* Creates a safe copy of the board.
*
* Intended to prevent cheating from a human via some interface,
* or from a bot playing via the API, or from a badly coded bot.
*
* Beware that the default implantation is unsafe and returns this.
*
* @return the copy
*/
public default IBoard safeCopy(){
return this;
}
}