diff --git a/Diagrammes/Diagramme_Avalam.mmd b/Diagrammes/Diagramme_Avalam.mmd new file mode 100644 index 0000000..d6e08ea --- /dev/null +++ b/Diagrammes/Diagramme_Avalam.mmd @@ -0,0 +1,218 @@ +--- +title: Avalam - Diagramme de classes (complet) +--- +classDiagram + + class AvalamBoard{ + +SIZE: int + -MAX_HEIGHT: int + -grid: Tower[][] + -gameOver: boolean + -result: Result + + +AvalamBoard(Tower[][] initialGrid, Player startingPlayer) + +AvalamBoard(Tower[][] initialGrid) + -AvalamBoard(Tower[][] grid, Player current, boolean gameOver, Result result) + +getTowerAt(int row, int col): Tower + -inBounds(int r, int c): boolean + -areAdjacent(int r1, int c1, int r2, int c2): boolean + -colorForPlayer(Player p): Color + +isGameOver(): boolean + +getResult(): Result + +isLegal(AbstractPly c): boolean + +doPly(AbstractPly c): void + +iterator(): Iterator + +safeCopy(): IBoard + } + + AvalamBoard "1" *-- "many" Tower + AvalamBoard ..> AvalamPly + + class AvalamPly{ + -xFrom : int + -yFrom : int + -xTo : int + -yTo : int + + +AvalamPly(Player player, int xFrom, int yFrom, int xTo, int yTo) + +getXFrom(): int + +getXFrom(): int + +getXFrom(): int + +getXFrom(): int + + +toString(): String + } + + + + class AvalamWindow{ + -board : AvalamBoard + -scoreView : ScoreView + -turnView : TurnView + -boardView : BoardView + -mode: GameMode + -botPlayer: Player + -idiotBot: IdiotBot + -alphaBot: AlphaBetaBot + -divineBot: Object + -botAnimating: boolean + + +AvalamWindow() + +AvalamWindow(GameMode mode) + +AvalamWindow(GameMode mode, int alphaDepth) + +onBoardUpdated(): void + -maybePlayBotTurn(): void + -computeScore(Color c): int + -turnMessage(): String + } + + AvalamWindow *-- AvalamBoard + AvalamWindow *-- BoardView + AvalamWindow *-- ScoreView + AvalamWindow *-- TurnView + AvalamWindow --> GameMode + + class BoardLoader{ + +loadFromFile(String resourcePath): Tower[][] + } + + + + class BoardView{ + -board: AvalamBoard + -backgroundLayer: BackgroundLayer + -highlightLayer: HighlightLayer + -pieceLayer: PieceLayer + -controller: InteractionController + -size: int + -spacing: int + -xBase: int + -yBase: int + -boardUpdateCallback: Runnable + + +BoardView(AvalamBoard board, Runnable boardUpdateCallback) + +getController(): InteractionController + +setInteractionEnabled(boolean enabled): void + +onBoardUpdated(): void + +refresh(): void + -boardGrid(): Tower[][] + -boardGrid(): Tower[][] + } + + BoardView *-- BackgroundLayer + BoardView *-- HighlightLayer + BoardView *-- PieceLayer + BoardView *-- InteractionController + BoardView --> AvalamBoard + + class BackgroundLayer{ + -img: Image + +BackgroundLayer(String resourcePath) + #paintComponent(Graphics g): void + } + + + + class Color{ + -YELLOW(int r, int g, int b) + -RED(int r, int g, int b) + -swingColor: java.awt.Color + +Color(int r, int g, int b) + +getSwingColor(): java.awt.Color + +toPlayer(): fr.iut_fbleau.GameAPI.Player + } + + class GameMode{ + PVP + PVBOT + PVALPHA + PVGOD + } + + class HighlightLayer{ + -xBase: int + -yBase: int + -spacing: int + -size: int + -legalMoves: List + + +HighlightLayer(int xBase, int yBase, int spacing, int size) + +setLegalMoves(List moves): void + #paintComponent(Graphics g): void + } + + class InteractionController{ + -board: AvalamBoard + -selectedRow: int + -selectedCol: int + -legalMoves: List + -view: BoardView + + +InteractionController(AvalamBoard board, BoardView view) + +onPieceClicked(int r, int c): void + +selectTower(int r, int c): void + -clearSelection(): void + -computeLegalMoves(): void + -tryMove(int r, int c): void + } + + InteractionController --> AvalamBoard + InteractionController --> BoardView + + class Main{ + +main(String[] args): void + } + + Main ..> AvalamWindow + Main ..> GameMode + + class PieceButton{ + -color: java.awt.Color + -height: int + -hover: boolean + +row: int + +col: int + + +PieceButton(java.awt.Color c, int height, int row, int col) + #paintComponent(Graphics g): void + +contains(int x, int y): boolean + + } + + class PieceLayer{ + +PieceLayer() + +displayGrid(Tower[][] grid, int xBase, int yBase, int spacing, int size, java.util.function.BiConsumer clickCallback): void + } + + class ScoreView{ + -scoreY: JLabel + -scoreR: JLabel + + +ScoreView(int y, int r) + +updateScores(int y, int r): void + } + + class Tower{ + -height: byte + -color: Color + + +Tower(int height, Color color) + +createTower(Color color): Tower + +getHeight(): int + +getColor(): Color + +mergeTower(Tower src): void + +toString(): String + } + + Tower --> Color + + class TurnView{ + -text: JLabel + + +TurnView(String initial) + +setTurn(String s): void + } + + BoardLoader ..> Tower + PieceLayer ..> Tower + PieceButton ..> Tower \ No newline at end of file diff --git a/Diagrammes/Diagramme_Bot.mmd b/Diagrammes/Diagramme_Bot.mmd new file mode 100644 index 0000000..c142a5f --- /dev/null +++ b/Diagrammes/Diagramme_Bot.mmd @@ -0,0 +1,27 @@ +--- +title: Bot - Diagramme de classes (complet) +--- +classDiagram + + class AlphaBetaBot{ + -me: Player + -maxDepth: int + -rng: Random + + +AlphaBetaBot(Player p, int maxDepth) + +giveYourMove(IBoard board): AbstractPly + -alphaBeta(IBoard board, int depth, int alpha, int beta): int + -terminalValue(IBoard board): int + -evaluate(IBoard board): int + -listMoves(IBoard board): List + } + + class DivineBot{ + + } + + class IdiotBot{ + -rng: Random + +IdiotBot(Player p) + +giveYourMove(IBoard board): AbstractPly + } \ No newline at end of file diff --git a/Diagrammes/Diagramme_GameAPI b/Diagrammes/Diagramme_GameAPI new file mode 100644 index 0000000..fa21675 --- /dev/null +++ b/Diagrammes/Diagramme_GameAPI @@ -0,0 +1,73 @@ +--- +title: GameAPI - Diagramme de classes (complet) +--- +classDiagram + + class AbstractBoard{ + <> + -currentPlayer: Player + -history: Deque + + +AbstractBoard(Player p, Deque h) + #setNextPlayer(): void + #addPlyToHistory(AbstractPly c): void + #removePlyFromHistory(): AbstractPly + #getLastPlyFromHistory(): AbstractPly + +getCurrentPlayer() + +isGameOver(): boolean + +getResult(): Result + +isLegal(AbstractPly c): boolean + +iterator(): Iterator + +doPly(AbstractPly c): void + +undoPly(): void + +safeCopy(): IBoard + } + + class AbstractGame{ + <> + -currentBoard: IBoard + -mapPlayers: EnumMap + + +AbstractGame(IBoard b, EnumMap m) + +run(): Result + } + + class AbstractGamePlayer{ + <> + -iAm: Player + + +AbstractGamePlayer(Player p) + +giveYourMove(IBoard p): AbstractPly + } + + class AbstractPly{ + <> + -joueur: Player + + +AbstractPly(Player j) + +getPlayer(): Player + } + + class IBoard{ + +getCurrentPlayer(): Player + +isGameOver(): boolean + +getResult(): Result + +isLegal(AbstractPly c): boolean + +iterator(): Iterator + +doPly(AbstractPly c): void + +undoPly(): void + +safeCopy(): IBoard + } + + class Player{ + <> + PLAYER1 + PLAYER2 + } + + class Result{ + <> + WIN + DRAW + LOSS + } \ No newline at end of file