diff --git a/2024-25/2025-09-18-Note-09-07_annoté.pdf b/2024-25/2025-09-18-Note-09-07_annoté.pdf new file mode 100644 index 0000000..eadfd28 Binary files /dev/null and b/2024-25/2025-09-18-Note-09-07_annoté.pdf differ diff --git a/2024-25/javaAPI/fr/iut_fbleau/GameAPI/AbstractBoard.java b/2024-25/javaAPI/fr/iut_fbleau/GameAPI/AbstractBoard.java new file mode 100644 index 0000000..2f6d79c --- /dev/null +++ b/2024-25/javaAPI/fr/iut_fbleau/GameAPI/AbstractBoard.java @@ -0,0 +1,99 @@ +package fr.iut_fbleau.GameAPI; + +import java.util.Iterator; +import java.util.Deque; + +/** + * An abstract class implementing the interface IBoard. + * + * used to implement some things to do with the update of the next player + * which is the same for all games and provides also a minimal + * implantation of the history mechanism. + */ +public abstract class AbstractBoard implements IBoard{ + + private Player currentPlayer ; + + private Deque history; + + private void setNextPlayer(){ + if (this.currentPlayer==Player.PLAYER1){ + this.currentPlayer= Player.PLAYER2; + } + else + this.currentPlayer= Player.PLAYER1; + } + + // Beware not checking if move is legal. + // To be used in do(AbstractPly c) + private void addPlyToHistory(AbstractPly c){ + this.history.addLast(c); + } + + // Beware not checking if history is not empty + // To be used in undo() + private void removePlyFromHistory(){ + return this.history.removeLast(); + } + + + /** + * @return the current player + */ + public Player getcurrentPlayer(){ + return this.currentPlayer; + } + + /** + * Returns the game status + * + * @return true iff the game is over + */ + public abstract boolean isGameOver(); + + /** + * + * @return the result (null if not over) + */ + public abstract Result getResult(); + + /** + * checker of legal moves from this position + * + * @throws NullPointerException if the game is over + * @return the iterator + */ + public abstract boolean isLegal(AbstractPly c); + + + + /** + * constructor of Iterator over legal moves from this position + * + * @throws NullPointerException if the game is over + * @return the iterator + */ + public abstract Iterator iterator(); + + + + /** + * 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 + * + * @param AbstractPly to be played + * + */ + public abstract void doPly(AbstractPly c); + + /** + * Resets the plateau to the position before the last move. + * + * @throws IllegalStateException if nothing to undo in history + * + */ + public abstract void undoPly(); + +} diff --git a/2024-25/javaAPI/fr/iut_fbleau/GameAPI/AbstractGamePlayer.java b/2024-25/javaAPI/fr/iut_fbleau/GameAPI/AbstractGamePlayer.java new file mode 100644 index 0000000..75888d0 --- /dev/null +++ b/2024-25/javaAPI/fr/iut_fbleau/GameAPI/AbstractGamePlayer.java @@ -0,0 +1,26 @@ +package fr.iut_fbleau.GameAPI; + +import java.util.Iterator; + +/** + * The abstract class for a game Player. + */ +public abstract class AbstractGamePlayer { + + // not a band, but which type of player I am in the game (PLAYER1 or PLAYER2). + private iAm Player; + + // Le joueur réel pourrait avoir besoin de connaître un constructeur de coup? + // pas pour l'instant. + + + /** + * + * + * @throws UnsupportedOperationException if the method is not yet implemented + * + * @throws IllegalStateException if the Situation is already in the bookmarks + */ + public abstract AbstractPly (IBoard p); + +} diff --git a/2024-25/javaAPI/fr/iut_fbleau/GameAPI/AbstractPly.java b/2024-25/javaAPI/fr/iut_fbleau/GameAPI/AbstractPly.java new file mode 100644 index 0000000..f831b22 --- /dev/null +++ b/2024-25/javaAPI/fr/iut_fbleau/GameAPI/AbstractPly.java @@ -0,0 +1,5 @@ +package fr.iut_fbleau.GameAPI; + +public abstract class AbstractPly { + private Player joueur; +} diff --git a/2024-25/javaAPI/fr/iut_fbleau/GameAPI/IBoard.java b/2024-25/javaAPI/fr/iut_fbleau/GameAPI/IBoard.java new file mode 100644 index 0000000..2bf6d91 --- /dev/null +++ b/2024-25/javaAPI/fr/iut_fbleau/GameAPI/IBoard.java @@ -0,0 +1,69 @@ +package fr.iut_fbleau.GameAPI; + +import java.util.Iterator; + +/** + * The interface Board. + */ +public interface IBoard { + + + /** + * @return the current player + */ + public Player getcurrentPlayer(); + + /** + * Returns the game status + * + * @return true iff the game is over + */ + public boolean isGameOver(); + + /** + * + * @return the result (null if not over) + */ + public Result getResult(); + + /** + * checker of legal moves from this position + * + * @throws NullPointerException if the game is over + * @return the iterator + */ + public boolean isLegal(AbstractPly c); + + + + /** + * constructor of Iterator over legal moves from this position + * + * @throws NullPointerException if the game is over + * @return the iterator + */ + public Iterator iterator(); + + + + /** + * 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 + * + * @param AbstractPly to be played + * + */ + public void doPly(AbstractPly c); + + /** + * Resets the plateau to the position before the last move. + * + * @throws IllegalStateException if nothing to undo in history + * + */ + public void undoPly(); + + +} diff --git a/2024-25/javaAPI/fr/iut_fbleau/GameAPI/Player.java b/2024-25/javaAPI/fr/iut_fbleau/GameAPI/Player.java new file mode 100644 index 0000000..2831093 --- /dev/null +++ b/2024-25/javaAPI/fr/iut_fbleau/GameAPI/Player.java @@ -0,0 +1,6 @@ +package fr.iut_fbleau.GameAPI; + +public enum Player { + PLAYER1, + PLAYER2 +} diff --git a/2024-25/javaAPI/fr/iut_fbleau/GameAPI/Result.java b/2024-25/javaAPI/fr/iut_fbleau/GameAPI/Result.java new file mode 100644 index 0000000..9417e13 --- /dev/null +++ b/2024-25/javaAPI/fr/iut_fbleau/GameAPI/Result.java @@ -0,0 +1,11 @@ +package fr.iut_fbleau.GameAPI; + +/** + * To output the result of a 2 player game that is symmetric. + * from the perspective of the player PLAYER1. + */ +public enum Result { + WIN, + DRAW, + LOSS; +}