commit 9700af5c657622d3db8d097d852108ea600ba08e Author: kerboul Date: Tue Apr 7 14:41:05 2026 +0200 Initial commit — sujet TP1 IIA (Minimax / Alpha-Beta) Co-Authored-By: Claude Sonnet 4.6 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b7c7969 --- /dev/null +++ b/.gitignore @@ -0,0 +1,78 @@ +# Directories # +/build/ +/bin/ +target/ + +# OS Files # +.DS_Store + +*.class + +# Package Files # +*.jar +*.war +*.ear +*.db + +###################### +# Windows +###################### + +# Windows image file caches +Thumbs.db + +# Folder config file +Desktop.ini + +###################### +# OSX +###################### + +.DS_Store +.svn + +# Thumbnails +._* + +# Files that might appear on external disk +.Spotlight-V100 +.Trashes + + +###################### +# Eclipse +###################### + +*.pydevproject +.project +.metadata +bin/** +tmp/** +tmp/**/* +*.tmp +*.bak +*.swp +*~.nib +local.properties +.classpath +.settings/ +.loadpath +/src/main/resources/rebel.xml +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# PDT-specific +.buildpath + + +###################### +# Gradle +###################### + +.gradle/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..560090e --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# TP 3-4 + +Structure de départ pour le TP 3-4. \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..a11ac18 --- /dev/null +++ b/build.gradle @@ -0,0 +1,35 @@ +/* + * This file was generated by the Gradle 'init' task. + * + * This generated file contains a sample Java Library project to get you started. + * For more details take a look at the Java Libraries chapter in the Gradle + * User Manual available at https://docs.gradle.org/6.3/userguide/java_library_plugin.html + */ + +plugins { + // Apply the java-library plugin to add support for Java Library + id 'java-library' + id 'eclipse' +} + +sourceCompatibility = 11.0 +targetCompatibility = 11.0 + + +repositories { + // Use jcenter for resolving dependencies. + // You can declare any Maven/Ivy/file repository here. + jcenter() +} + +dependencies { + // This dependency is exported to consumers, that is to say found on their compile classpath. + //api 'org.apache.commons:commons-math3:3.6.1' + + // This dependency is used internally, and not exposed to consumers on their own compile classpath. + //implementation 'com.google.guava:guava:28.2-jre' + + // Use JUnit test framework + testImplementation 'junit:junit:4.12' +} + diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..b8c2d95 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,10 @@ +/* + * This file was generated by the Gradle 'init' task. + * + * The settings file is used to specify which projects to include in your build. + * + * Detailed information about configuring a multi-project build in Gradle can be found + * in the user manual at https://docs.gradle.org/6.3/userguide/multi_project_builds.html + */ + +rootProject.name = 'iialib' diff --git a/src/main/java/games/dominos/DominosBoard.java b/src/main/java/games/dominos/DominosBoard.java new file mode 100644 index 0000000..b5f6f2d --- /dev/null +++ b/src/main/java/games/dominos/DominosBoard.java @@ -0,0 +1,186 @@ +package games.dominos; + +import iialib.games.model.IBoard; +import iialib.games.model.Player; +import iialib.games.model.Score; + +import java.util.ArrayList; + +public class DominosBoard implements IBoard { + + private static int DEFAULT_GRID_SIZE = 7; + + // --------- Class Attribute --------- + + public static int GRID_SIZE = DEFAULT_GRID_SIZE; + + private enum SQUARE { + EMPTY, VERTICAL, HORIZONTAL + }; + + // ---------------------- Attributes --------------------- + + private final SQUARE[][] boardGrid; + + // ---------------------- Constructors --------------------- + + public DominosBoard() { + boardGrid = new SQUARE[GRID_SIZE][GRID_SIZE]; + for (int i = 0; i < GRID_SIZE; i++) + for (int j = 0; j < GRID_SIZE; j++) + boardGrid[i][j] = SQUARE.EMPTY; + } + + // Constructors + + public DominosBoard(DominosBoard other) { + boardGrid = other.copyGrid(); + } + + + private DominosBoard(SQUARE[][] other) { + boardGrid = new SQUARE[GRID_SIZE][GRID_SIZE]; + for (int i = 0; i < GRID_SIZE; i++) + System.arraycopy(other[i], 0, boardGrid[i], 0, GRID_SIZE); + } + + // ------------------- Getters / Setters ------------------- + + protected int retGridSize(int n) { + return GRID_SIZE; + } + + protected void setGridSize(int n) { + GRID_SIZE = n; + } + + // --------------------- IBoard Methods --------------------- + + @Override + public DominosBoard play(DominosMove move, DominosRole playerRole) { + SQUARE[][] newGrid = copyGrid(); + int x = move.x; + int y = move.y; + if (playerRole == DominosRole.VERTICAL) { + newGrid[x][y] = SQUARE.VERTICAL; + newGrid[x + 1][y] = SQUARE.VERTICAL; + } else { + newGrid[x][y] = SQUARE.HORIZONTAL; + newGrid[x][y + 1] = SQUARE.HORIZONTAL; + } + return new DominosBoard(newGrid); + } + + @Override + public ArrayList possibleMoves(DominosRole playerRole) { + if (playerRole == DominosRole.VERTICAL) { + return freeVerticalMoves(); + } else { + return freeHorizontalMoves(); + } + } + + @Override + public boolean isValidMove(DominosMove move, DominosRole playerRole) { + int x = move.x; + int y = move.y; + return (boardGrid[x][y] == SQUARE.EMPTY) + && ((playerRole == DominosRole.VERTICAL) ? (boardGrid[x + 1][y] == SQUARE.EMPTY) + : (boardGrid[x][y + 1] == SQUARE.EMPTY)); + + } + + @Override + public boolean isGameOver() { + return (this.nbHorizontalMoves() == 0) || (this.nbVerticalMoves() == 0); + } + + // --------------------- Other Methods --------------------- + + + private ArrayList freeVerticalMoves() { + ArrayList allPossibleMoves = new ArrayList<>(); + for (int i = 0; i < GRID_SIZE- 1; i++) { // lines + for (int j = 0; j < GRID_SIZE ; j++) { // columns + if ((boardGrid[i][j] == SQUARE.EMPTY) && (boardGrid[i + 1][j] == SQUARE.EMPTY)) // possible move + allPossibleMoves.add(new DominosMove(i, j)); + } + } + return allPossibleMoves; + } + + private ArrayList freeHorizontalMoves() { + ArrayList allPossibleMoves = new ArrayList<>(); + for (int i = 0; i < GRID_SIZE; i++) { // lines + for (int j = 0; j < GRID_SIZE - 1; j++) { // columns + if ((boardGrid[i][j] == SQUARE.EMPTY) && (boardGrid[i ][j+ 1] == SQUARE.EMPTY)) // possible move + allPossibleMoves.add(new DominosMove(i, j)); + } + } + return allPossibleMoves; + } + + private SQUARE[][] copyGrid() { + SQUARE[][] newGrid = new SQUARE[GRID_SIZE][GRID_SIZE]; + for (int i = 0; i < GRID_SIZE; i++) + System.arraycopy(boardGrid[i], 0, newGrid[i], 0, GRID_SIZE); + return newGrid; + } + + public String toString() { + StringBuilder retstr = new StringBuilder(new String("")); + for (int i = 0; i < GRID_SIZE; i++) { + for (int j = 0; j < GRID_SIZE; j++) + if (boardGrid[i][j] == SQUARE.EMPTY) + retstr.append("-"); + else if (boardGrid[i][j] == SQUARE.VERTICAL) + retstr.append("V"); + else // damier[i][j] == NOIR + retstr.append("H"); + retstr.append("\n"); + } + return retstr.toString(); + } + + public int nbHorizontalMoves() { + int nbMoves = 0; + for (int i = 0; i < GRID_SIZE; i++) { + for (int j = 0; j < GRID_SIZE - 1; j++) { + if (boardGrid[i][j] == SQUARE.EMPTY && boardGrid[i][j + 1] == SQUARE.EMPTY) + nbMoves++; + } + } + return nbMoves; + } + + public int nbVerticalMoves() { + int nbMoves = 0; + for (int i = 0; i < GRID_SIZE; i++) { + for (int j = 0; j < GRID_SIZE - 1; j++) { + if (boardGrid[j][i] == SQUARE.EMPTY && boardGrid[j + 1][i] == SQUARE.EMPTY) + nbMoves++; + } + } + return nbMoves; + } + + @Override + public ArrayList> getScores() { + ArrayList> scores = new ArrayList>(); + if(this.isGameOver()) { + if (nbHorizontalMoves() == 0) { + scores.add(new Score(DominosRole.HORIZONTAL,Score.Status.LOOSE,0)); + scores.add(new Score(DominosRole.VERTICAL,Score.Status.WIN,1)); + } + else { + scores.add(new Score(DominosRole.HORIZONTAL,Score.Status.WIN,1)); + scores.add(new Score(DominosRole.VERTICAL,Score.Status.LOOSE,0)); + } + } + else { + + } + return scores; + } + +} diff --git a/src/main/java/games/dominos/DominosGame.java b/src/main/java/games/dominos/DominosGame.java new file mode 100644 index 0000000..6c79c62 --- /dev/null +++ b/src/main/java/games/dominos/DominosGame.java @@ -0,0 +1,45 @@ +package games.dominos; + +import java.util.ArrayList; + +import iialib.games.algs.AIPlayer; +import iialib.games.algs.AbstractGame; +import iialib.games.algs.GameAlgorithm; +import iialib.games.algs.algorithms.MiniMax; + +public class DominosGame extends AbstractGame { + + DominosGame(ArrayList> players, DominosBoard board) { + super(players, board); + } + + public static void main(String[] args) { + + DominosRole roleV = DominosRole.VERTICAL; + DominosRole roleH = DominosRole.HORIZONTAL; + + GameAlgorithm algV = new MiniMax( + roleV, roleH, DominosHeuristics.hVertical, 4); // Minimax depth 4 + + GameAlgorithm algH = new MiniMax( + roleH, roleV, DominosHeuristics.hHorizontal, 2); // Minimax depth 2 + + AIPlayer playerV = new AIPlayer( + roleV, algV); + + AIPlayer playerH = new AIPlayer( + roleH, algH); + + ArrayList> players = new ArrayList>(); + + players.add(playerV); // First Player + players.add(playerH); // Second Player + + // Setting the initial Board + DominosBoard initialBoard = new DominosBoard(); + + DominosGame game = new DominosGame(players, initialBoard); + game.runGame(); + } + +} \ No newline at end of file diff --git a/src/main/java/games/dominos/DominosHeuristics.java b/src/main/java/games/dominos/DominosHeuristics.java new file mode 100644 index 0000000..9ea8e96 --- /dev/null +++ b/src/main/java/games/dominos/DominosHeuristics.java @@ -0,0 +1,23 @@ +package games.dominos; + +import iialib.games.algs.IHeuristic; + +public class DominosHeuristics { + + public static IHeuristic hVertical = (board,role) -> { + /* TODO */ + + + return 0; // TODO + }; + + + public static IHeuristic hHorizontal = (board,role) -> { + /* TODO */ + + + return 0; // TODO + }; + +} + \ No newline at end of file diff --git a/src/main/java/games/dominos/DominosMove.java b/src/main/java/games/dominos/DominosMove.java new file mode 100644 index 0000000..2882503 --- /dev/null +++ b/src/main/java/games/dominos/DominosMove.java @@ -0,0 +1,19 @@ +package games.dominos; + +import iialib.games.model.IMove; + +public class DominosMove implements IMove { + + public final int x; + public final int y; + + DominosMove(int x, int y){ + this.x = x; + this.y = y; + } + + @Override + public String toString() { + return "Move{" + x + "," + y + "}"; + } +} diff --git a/src/main/java/games/dominos/DominosRole.java b/src/main/java/games/dominos/DominosRole.java new file mode 100644 index 0000000..12d374f --- /dev/null +++ b/src/main/java/games/dominos/DominosRole.java @@ -0,0 +1,8 @@ +package games.dominos; + +import iialib.games.model.IRole; + +public enum DominosRole implements IRole{ + HORIZONTAL, // For the player playing its tiles hally + VERTICAL // For the player playing its tiles vertically +} diff --git a/src/main/java/games/otherGame/otherGameBoard.java b/src/main/java/games/otherGame/otherGameBoard.java new file mode 100644 index 0000000..2cf67d6 --- /dev/null +++ b/src/main/java/games/otherGame/otherGameBoard.java @@ -0,0 +1,54 @@ +package games.otherGame; + +import iialib.games.model.IBoard; +import iialib.games.model.Player; +import iialib.games.model.Score; + +import java.util.ArrayList; + +public class otherGameBoard implements IBoard { + + + + // ---------------------- Attributes --------------------- + // Attributes + + //TODO + + // --------------------- IBoard Methods --------------------- + + @Override + public ArrayList possibleMoves(otherGameRole playerRole) { + // TODO Auto-generated method stub + return null; + } + + @Override + public otherGameBoard play(otherGameMove move, otherGameRole playerRole) { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean isValidMove(otherGameMove move, otherGameRole playerRole) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean isGameOver() { + // TODO Auto-generated method stub + return false; + } + + @Override + public ArrayList> getScores() { + // TODO Auto-generated method stub + return null; + } + + // --------------------- Other Methods --------------------- + + + +} diff --git a/src/main/java/games/otherGame/otherGameMove.java b/src/main/java/games/otherGame/otherGameMove.java new file mode 100644 index 0000000..0e80389 --- /dev/null +++ b/src/main/java/games/otherGame/otherGameMove.java @@ -0,0 +1,19 @@ +package games.otherGame; + +import iialib.games.model.IMove; + +public class otherGameMove implements IMove { + + public final int x; + public final int y; + + otherGameMove(int x, int y){ + this.x = x; + this.y = y; + } + + @Override + public String toString() { + return "Move{" + x + "," + y + "}"; + } +} diff --git a/src/main/java/games/otherGame/otherGameRole.java b/src/main/java/games/otherGame/otherGameRole.java new file mode 100644 index 0000000..c5c8a7b --- /dev/null +++ b/src/main/java/games/otherGame/otherGameRole.java @@ -0,0 +1,8 @@ +package games.otherGame; + +import iialib.games.model.IRole; + +public enum otherGameRole implements IRole{ + HORIZONTAL, // For the player playing its tiles hally + VERTICAL // For the player playing its tiles vertically +} diff --git a/src/main/java/iialib/games/algs/AIPlayer.java b/src/main/java/iialib/games/algs/AIPlayer.java new file mode 100644 index 0000000..e491e4f --- /dev/null +++ b/src/main/java/iialib/games/algs/AIPlayer.java @@ -0,0 +1,33 @@ +package iialib.games.algs; + +import iialib.games.model.IBoard; +import iialib.games.model.IMove; +import iialib.games.model.IRole; +import iialib.games.model.Player; + +public class AIPlayer> extends Player { + + private GameAlgorithm< Move,Role,Board> ai; + + public void setAi(GameAlgorithm ai) { + this.ai = ai; + } + + public AIPlayer(Role role) { + super(role); + } + + public AIPlayer(Role role,GameAlgorithm alg) { + super(role); + this.ai = alg; + } + + public Move bestMove(Board board) { + return(ai.bestMove(board,this.getRole())); + } + + public Board playMove(Board board, Move move) { + return(board.play(move, this.getRole())); + } + +} diff --git a/src/main/java/iialib/games/algs/AbstractGame.java b/src/main/java/iialib/games/algs/AbstractGame.java new file mode 100644 index 0000000..9e8453b --- /dev/null +++ b/src/main/java/iialib/games/algs/AbstractGame.java @@ -0,0 +1,56 @@ +package iialib.games.algs; + +import java.util.ArrayList; + +import iialib.games.model.IBoard; +import iialib.games.model.IMove; +import iialib.games.model.IRole; +import iialib.games.model.Score; + +public abstract class AbstractGame> { + + // Attributes + Board currentBoard; + + ArrayList> players; + + + // Constructor + public AbstractGame(ArrayList> players,Board initialBoard){ + this.currentBoard = initialBoard; + this.players = players; + } + + // Methods + public void runGame() { + int index = 0; + AIPlayer currentPlayer = players.get(index); + System.out.println("Game begining - First player is : " + currentPlayer); + System.out.println("The board is :"); + System.out.println(currentBoard); + + while(!currentBoard.isGameOver()) { + System.out.println("Next player is :" + currentPlayer); + Move nextMove = currentPlayer.bestMove(currentBoard); + System.out.println("Best Move is :" + nextMove); + currentBoard = currentPlayer.playMove(currentBoard, nextMove); + System.out.println("The board is :"); + System.out.println(currentBoard); + index = 1 - index; + currentPlayer = players.get(index); + } + + System.out.println("Game over !"); + ArrayList> scores = currentBoard.getScores(); + for(AIPlayer p: players) + for(Score s : scores) + if(p.getRole() == s.getRole()) + System.out.println("" + p + " score is : " + s.getStatus() + " " + s.getScore()); + ; + + } + + + + +} diff --git a/src/main/java/iialib/games/algs/GameAlgorithm.java b/src/main/java/iialib/games/algs/GameAlgorithm.java new file mode 100644 index 0000000..ea10f52 --- /dev/null +++ b/src/main/java/iialib/games/algs/GameAlgorithm.java @@ -0,0 +1,12 @@ +package iialib.games.algs; + +import iialib.games.model.IBoard; +import iialib.games.model.IMove; +import iialib.games.model.IRole; +import iialib.games.model.Player; + +public interface GameAlgorithm< Move extends IMove, Role extends IRole, Board extends IBoard> { + + Move bestMove(Board board,Role playerRole); + +} diff --git a/src/main/java/iialib/games/algs/IHeuristic.java b/src/main/java/iialib/games/algs/IHeuristic.java new file mode 100644 index 0000000..8401904 --- /dev/null +++ b/src/main/java/iialib/games/algs/IHeuristic.java @@ -0,0 +1,17 @@ +package iialib.games.algs; + +import iialib.games.model.IBoard; +import iialib.games.model.IMove; +import iialib.games.model.IRole; +import iialib.games.model.Player; + +@FunctionalInterface +public interface IHeuristic,Role extends IRole> { + + public static int MIN_VALUE = java.lang.Integer.MIN_VALUE; + public static int MAX_VALUE = java.lang.Integer.MAX_VALUE; + + int eval(Board board,Role role); + +} + \ No newline at end of file diff --git a/src/main/java/iialib/games/algs/algorithms/MiniMax.java b/src/main/java/iialib/games/algs/algorithms/MiniMax.java new file mode 100644 index 0000000..c634305 --- /dev/null +++ b/src/main/java/iialib/games/algs/algorithms/MiniMax.java @@ -0,0 +1,84 @@ +package iialib.games.algs.algorithms; + +import iialib.games.algs.GameAlgorithm; +import iialib.games.algs.IHeuristic; +import iialib.games.model.IBoard; +import iialib.games.model.IMove; +import iialib.games.model.IRole; + +public class MiniMax> implements GameAlgorithm { + + // Constants + /** Defaut value for depth limit + */ + private final static int DEPTH_MAX_DEFAUT = 4; + + // Attributes + /** Role of the max player + */ + private final Role playerMaxRole; + + /** Role of the min player + */ + private final Role playerMinRole; + + /** Algorithm max depth + */ + private int depthMax = DEPTH_MAX_DEFAUT; + + + /** Heuristic used by the max player + */ + private IHeuristic h; + + // + /** number of internal visited (developed) nodes (for stats) + */ + private int nbNodes; + + /** number of leaves nodes nodes (for stats) + + */ + private int nbLeaves; + + // --------- Constructors --------- + + public MiniMax(Role playerMaxRole, Role playerMinRole, IHeuristic h) { + this.playerMaxRole = playerMaxRole; + this.playerMinRole = playerMinRole; + this.h = h; + } + + // + public MiniMax(Role playerMaxRole, Role playerMinRole, IHeuristic h, int depthMax) { + this(playerMaxRole, playerMinRole, h); + this.depthMax = depthMax; + } + + /* + * IAlgo METHODS ============= + */ + + @Override + public Move bestMove(Board board, Role playerRole) { + System.out.println("[MiniMax]"); + + Move bestMove = null; + // TODO + return bestMove; + } + + /* + * PUBLIC METHODS ============== + */ + + public String toString() { + return "MiniMax(ProfMax=" + depthMax + ")"; + } + + /* + * PRIVATE METHODS =============== + */ + + //TODO +} diff --git a/src/main/java/iialib/games/model/IBoard.java b/src/main/java/iialib/games/model/IBoard.java new file mode 100644 index 0000000..a350465 --- /dev/null +++ b/src/main/java/iialib/games/model/IBoard.java @@ -0,0 +1,53 @@ +package iialib.games.model; + +import java.util.ArrayList; + +/** + * Used to chararacterize the boards.he + * It has to be impemented by some class in a real game. + * + * @param Class implementing the moves for the game + * @param Class implementing the roles for the game + * @param Class implementing the boards for the game + * + * + */ +public interface IBoard> { + + /** + * returns the possible moves a player having the playerRole + * @param playerRole + * @return a list of all possible moves for the player having the playerRole + */ + ArrayList possibleMoves(Role playerRole); + + /** play move on the board, played by a player having the playerRole + * + * @param move + * @param playerRole + * @return the successor board + */ + Board play(Move move, Role playerRole); + + /** + * checks that move is valid for the player having the playerRole + * @param move + * @param playerRole + * @return yes if the move is valid for playerRole + */ + boolean isValidMove(Move move, Role playerRole); + + /** + * checks that the board corresponds to an end of game + * @return yes if the game completed + */ + boolean isGameOver(); + + + /** + * returns the scores for each role (when the game is over) + * @return + */ + ArrayList> getScores(); + +} diff --git a/src/main/java/iialib/games/model/IMove.java b/src/main/java/iialib/games/model/IMove.java new file mode 100644 index 0000000..8177f3d --- /dev/null +++ b/src/main/java/iialib/games/model/IMove.java @@ -0,0 +1,11 @@ +package iialib.games.model; + +/** + * used to characterize game moves + * It has to be implemented by some class in a real game + */ +public interface IMove { + + + +} diff --git a/src/main/java/iialib/games/model/IRole.java b/src/main/java/iialib/games/model/IRole.java new file mode 100644 index 0000000..2e1439f --- /dev/null +++ b/src/main/java/iialib/games/model/IRole.java @@ -0,0 +1,15 @@ +package iialib.games.model; + +/** + * Used to represent characterize the role in the game of the different players + * + * It has to be implemented by some class for a real game. + * Generally it is just an enum for representing what distinguishes the players in the game + * e.g. the colors( BLACK, WHITE), the Position (NORTH, SOUTH), ... + * + * Exemple + * enum Colors {BLACK,WHITE} implements IRole + */ +public interface IRole { + +} diff --git a/src/main/java/iialib/games/model/Player.java b/src/main/java/iialib/games/model/Player.java new file mode 100644 index 0000000..fad0401 --- /dev/null +++ b/src/main/java/iialib/games/model/Player.java @@ -0,0 +1,56 @@ +package iialib.games.model; + + +/** + * used to associate an real player identifier to a role + * + * @param + */ + + +public class Player { + + // ----------- Attributes ------------ + + /** + * the role of the player in the game + */ + Role role; + /** + * An (optional) identifier characterizing the player having that role in the game + * This is useful for instance in a tournament, for keeping tra + */ + String id; + + // ----------- Getters / Setters ------------ + + public String getId() { + return id; + } + + public Role getRole() { + return role; + } + + public void setRole(Role role) { + this.role = role; + } + // ----------- Constructors ------------ + + public Player(Role role) { + this.role = role; + this.id = ""; +} + + public Player(Role role, String id) { + this(role); + this.id = id; + } + + // ----------- Other Methods ------------ + public String toString() { + return "" + role + ( id.isEmpty() ? "" : " (" + id + ")"); + } + + +} diff --git a/src/main/java/iialib/games/model/Score.java b/src/main/java/iialib/games/model/Score.java new file mode 100644 index 0000000..ad9c19a --- /dev/null +++ b/src/main/java/iialib/games/model/Score.java @@ -0,0 +1,60 @@ +package iialib.games.model; + +/** + * class used to describe the score corresponding to each player role when the game is over + */ +public class Score { + + /** + * + */ + public enum Status {WIN,LOOSE,TIE}; + + // ----------- Attributes ------------ + + /** + * + */ + private Role role; + + /** + * + */ + private Status status; + + /** + * score can be just 1/0 or a real score depending on the game + */ + private int score; + + // ----------- Constructors ------------ + + + public Score(Role role, Status status, int score) { + super(); + this.role = role; + this.status = status; + this.score = score; + } + + // ----------- Getter / Setters ------------ + + public Role getRole() { + return role; + } + + public Status getStatus() { + return status; + } + + public int getScore() { + return score; + } + + // ----------- Other public methods ------------ + + public String toString() { + return "Score <" + role + "," + status + "," + score + ">"; + } + +} \ No newline at end of file