diff options
Diffstat (limited to 'doc/diagrams')
34 files changed, 558 insertions, 66 deletions
diff --git a/doc/diagrams/ASTNode.pumlc b/doc/diagrams/ASTNode.pumlc index 05c13ac..945b24d 100644 --- a/doc/diagrams/ASTNode.pumlc +++ b/doc/diagrams/ASTNode.pumlc @@ -1,10 +1,14 @@ @startuml class ASTNode { - ASTNode[] children - Property properties - void addtoSequence() - GameTree toGameTree() + ASTNode[] children + Property[] props + + addtoSequence() + toGameTree() + toGameMoveTree(previousMove) + hasProperty(propertyName) + getPropertyValue(propertyName) } @enduml diff --git a/doc/diagrams/ConvNeuralNetwork.pumlc b/doc/diagrams/ConvNeuralNetwork.pumlc new file mode 100644 index 0000000..2254e5d --- /dev/null +++ b/doc/diagrams/ConvNeuralNetwork.pumlc @@ -0,0 +1,7 @@ +@startuml + +class ConvNeuralNetwork { + +} + +@enduml diff --git a/doc/diagrams/DecisionAlgorithm.pumlc b/doc/diagrams/DecisionAlgorithm.pumlc new file mode 100644 index 0000000..c3e9e8a --- /dev/null +++ b/doc/diagrams/DecisionAlgorithm.pumlc @@ -0,0 +1,9 @@ +@startuml + +interface DecisionAlgorithm { + {abstract} forceNextMove(coords) + {abstract} pickMove() + {abstract} clearBoard() +} + +@enduml diff --git a/doc/diagrams/DenseNeuralNetwork.pumlc b/doc/diagrams/DenseNeuralNetwork.pumlc new file mode 100644 index 0000000..a9e7d1c --- /dev/null +++ b/doc/diagrams/DenseNeuralNetwork.pumlc @@ -0,0 +1,7 @@ +@startuml + +class DenseNeuralNetwork { + +} + +@enduml diff --git a/doc/diagrams/GameBoard.pumlc b/doc/diagrams/GameBoard.pumlc new file mode 100644 index 0000000..ebeedd7 --- /dev/null +++ b/doc/diagrams/GameBoard.pumlc @@ -0,0 +1,29 @@ +@startuml + +class GameBoard { + int[][] board + int capturesBlack + int capturesWhite + + getBoard() + getBoardHeight() + getBoardWidth() + getDeepCopy() + getGroupLiberties(row, col) + getGroupLibertiesCount(row, col) + getGroupVertices(row, col) + getGroupVerticesCount(row, col) + moveAndCapture(row, col, player) + isMoveInBoardBounds(row, col) + isCellEmpty(row, col) + isCellEye(row, col) + isMoveSuicidal(row, col, player) + isMoveKoIllegal(row, col, player, prevBoards) + isPlayable(row, col, player, prevBoards) + isSensible(row, col, player, prevBoards) + score() + equals(otherBoard) + printBoard() +} + +@enduml diff --git a/doc/diagrams/GameEngine.pumlc b/doc/diagrams/GameEngine.pumlc new file mode 100644 index 0000000..62b892e --- /dev/null +++ b/doc/diagrams/GameEngine.pumlc @@ -0,0 +1,18 @@ +@startuml + +class GameEngine { + int komi + GameState gameState + Enum daId + DecisionAlgorithm da + + setBoardsize(newSize) + clearBoard() + setKomi(komi) + setFixedHandicap(stones) + play(color, vertex) + genmove(color) + undo() +} + +@enduml diff --git a/doc/diagrams/GameMove.pumlc b/doc/diagrams/GameMove.pumlc index 7dcb5e3..a1d0d73 100644 --- a/doc/diagrams/GameMove.pumlc +++ b/doc/diagrams/GameMove.pumlc @@ -1,13 +1,28 @@ @startuml class GameMove { - int player - int row - int col - int[2] makesKo - int[] board + GameBoard board GameMove[] nextMoves GameMove previousMove + boolean isPass + int[] coords + Player playerWhoPassed + + getRow() + getCol() + getPlayer() + getNextPlayer() + getGameLength() + getThisAndPrevBoards() + getPlayableVertices() + getSensibleVertices() + addMove(row, col) + addMoveBcoords(coords) + addMoveForPlayer(row, col, player) + addPass() + addPassForPlayer() + getMainLineOfPlay() + printBoard() } @enduml diff --git a/doc/diagrams/GameState.pumlc b/doc/diagrams/GameState.pumlc index db39d8f..a913855 100644 --- a/doc/diagrams/GameState.pumlc +++ b/doc/diagrams/GameState.pumlc @@ -1,14 +1,18 @@ @startuml class GameState { - int player - int capturesBlack - int capturesWhite - List board - List prevBoards # for ko - GameTree gameTree + int size GameMove lastMove - GameData gameData + + getCurrentPlayer() + getPlayerCode() + getBoard() + clearBoard() + playMove(row, col) + playMoveForPlayer(row, col, player) + playPass() + playPassForPlayer(player) + undo() } @enduml diff --git a/doc/diagrams/GameTree.pumlc b/doc/diagrams/GameTree.pumlc index 85859d8..10b9251 100644 --- a/doc/diagrams/GameTree.pumlc +++ b/doc/diagrams/GameTree.pumlc @@ -1,8 +1,8 @@ @startuml class GameTree { - GameNode[] firstMoves - GameData gameData + GameMove[] firstMoves + 'GameData gameData } @enduml diff --git a/doc/diagrams/ImagoIO.pumlc b/doc/diagrams/ImagoIO.pumlc new file mode 100644 index 0000000..848a173 --- /dev/null +++ b/doc/diagrams/ImagoIO.pumlc @@ -0,0 +1,10 @@ +@startuml + +class ImagoIO { + function[] commands_set + GameEngine gameEngine + + start() +} + +@enduml diff --git a/doc/diagrams/Keras.pumlc b/doc/diagrams/Keras.pumlc new file mode 100644 index 0000000..1fa40b2 --- /dev/null +++ b/doc/diagrams/Keras.pumlc @@ -0,0 +1,12 @@ +@startuml + +class Keras { + GameMove currentMove + NeuralNetwork neuralNetwork + + forceNextMove(self, coords) + pickMove(self) + loadNetwork(self) +} + +@enduml diff --git a/doc/diagrams/MCTS.pumlc b/doc/diagrams/MCTS.pumlc new file mode 100644 index 0000000..ff00c62 --- /dev/null +++ b/doc/diagrams/MCTS.pumlc @@ -0,0 +1,11 @@ +@startuml + +class MCTS { + MCTSNode root + + forceNextMove(coords) + pickMove() + clearBoard() +} + +@enduml diff --git a/doc/diagrams/MCTSNode.pumlc b/doc/diagrams/MCTSNode.pumlc new file mode 100644 index 0000000..6ae8f35 --- /dev/null +++ b/doc/diagrams/MCTSNode.pumlc @@ -0,0 +1,18 @@ +@startuml + +class MCTSNode { + int visits + int score + GameMove move + MCTSNode parent + MCTSNode[] children + (int, int)[] unexploredVertices + + ucbForPlayer() + selection() + expansion() + expansionForCoords(coords) + simulation(nMatches, scoreDiffHeur) +} + +@enduml diff --git a/doc/diagrams/NeuralNetwork.pumlc b/doc/diagrams/NeuralNetwork.pumlc new file mode 100644 index 0000000..f6c0e1c --- /dev/null +++ b/doc/diagrams/NeuralNetwork.pumlc @@ -0,0 +1,13 @@ +@startuml + +class NeuralNetwork { + int boardSize + string path + + trainModel(games) + saveModel(modelPath) + pickMove(gameMove, player) + saveModelPlot(path) +} + +@enduml diff --git a/doc/diagrams/Property.pumlc b/doc/diagrams/Property.pumlc new file mode 100644 index 0000000..bb06b47 --- /dev/null +++ b/doc/diagrams/Property.pumlc @@ -0,0 +1,10 @@ +@startuml + +class Property { + string name + object value + + addValue(value) +} + +@enduml diff --git a/doc/diagrams/SGF.pumlc b/doc/diagrams/SGF.pumlc index 2c30202..5ab248a 100644 --- a/doc/diagrams/SGF.pumlc +++ b/doc/diagrams/SGF.pumlc @@ -1,8 +1,7 @@ @startuml -class SGF { - GameTree loadGameTree(file) - void saveGameTree(file) +object SGF { + loadGameTree(file) } @enduml diff --git a/doc/diagrams/analysisClasses.puml b/doc/diagrams/analysisClasses.puml new file mode 100644 index 0000000..7685ea1 --- /dev/null +++ b/doc/diagrams/analysisClasses.puml @@ -0,0 +1,56 @@ +@startuml + +!include skinparams.puml + +() Player +package "Game module" { + class GameIO + class GameState + class GameBoard + class GameMove + + Player -> GameIO + GameIO ..> GameState + GameState ..> GameMove + GameMove ..> GameBoard +} + +() "Engine user" as EU +() "Model files" as MF +package "Engine module" { + class EngineIO + class EngineLogic + interface DecisionAlgorithm + class MonteCarloTreeSearch + class MCTSNode + class Keras + class NeuralNetwork + + EU -> EngineIO + EngineIO ..> EngineLogic + EngineLogic ..> DecisionAlgorithm + DecisionAlgorithm <|.. MonteCarloTreeSearch + DecisionAlgorithm <|.. Keras + MonteCarloTreeSearch ..> MCTSNode + Keras ..> NeuralNetwork + NeuralNetwork --> MF +} + +() "SGF files" as SGF +package "Training module" { + class Trainer + class Parser + class ASTNode + + Parser -> SGF + Trainer ..> Parser + Parser ..> ASTNode +} + +DecisionAlgorithm .> GameMove + +ASTNode .> GameMove + +Trainer .> NeuralNetwork + +@enduml diff --git a/doc/diagrams/engineModule.puml b/doc/diagrams/engineModule.puml new file mode 100644 index 0000000..c6f3a3e --- /dev/null +++ b/doc/diagrams/engineModule.puml @@ -0,0 +1,32 @@ +@startuml + +!include skinparams.puml + +package "Engine module" { + + !include ImagoIO.pumlc + !include GameEngine.pumlc + !include DecisionAlgorithm.pumlc + !include MCTS.pumlc + !include MCTSNode.pumlc + !include Keras.pumlc + !include NeuralNetwork.pumlc + !include DenseNeuralNetwork.pumlc + !include ConvNeuralNetwork.pumlc + + ImagoIO ..> GameEngine + GameEngine ..> DecisionAlgorithm + + DecisionAlgorithm <|.. MCTS + MCTSNode <. MCTS + MCTSNode -> MCTSNode + MCTSNode o--> MCTSNode + + DecisionAlgorithm <|.. Keras + Keras ..> NeuralNetwork + NeuralNetwork <|-- DenseNeuralNetwork + NeuralNetwork <|-- ConvNeuralNetwork + +} + +@enduml diff --git a/doc/diagrams/fullClasses.puml b/doc/diagrams/fullClasses.puml new file mode 100644 index 0000000..d7fe4d8 --- /dev/null +++ b/doc/diagrams/fullClasses.puml @@ -0,0 +1,16 @@ +@startuml + +!include skinparams.puml + +!include gameModule.puml +!include engineModule.puml +!include trainingModule.puml + +GameEngine --> GameState + +MCTSNode --> GameMove +Keras --> GameMove + +ASTNode --> GameMove + +@enduml diff --git a/doc/diagrams/gameModule.puml b/doc/diagrams/gameModule.puml new file mode 100644 index 0000000..9a60d3f --- /dev/null +++ b/doc/diagrams/gameModule.puml @@ -0,0 +1,18 @@ +@startuml + +!include skinparams.puml + +package "Game module" { + + !include GameState.pumlc + !include GameMove.pumlc + !include GameBoard.pumlc + + GameState ..> GameMove + GameMove -> GameMove : Previous move + GameMove o--> GameMove : Next moves + GameMove ..> GameBoard + +} + +@enduml diff --git a/doc/diagrams/gameRepresentation.puml b/doc/diagrams/gameRepresentation.puml deleted file mode 100644 index 9a869f1..0000000 --- a/doc/diagrams/gameRepresentation.puml +++ /dev/null @@ -1,14 +0,0 @@ -@startuml - -!include skinparams.puml - -!include GameState.pumlc -!include GameTree.pumlc -!include GameMove.pumlc - -GameState --> GameTree -GameState --> GameMove: Current move -GameTree *--> GameMove -GameMove -> GameMove - -@enduml diff --git a/doc/diagrams/gtpEngine.puml b/doc/diagrams/gtpEngine.puml deleted file mode 100644 index c4caf32..0000000 --- a/doc/diagrams/gtpEngine.puml +++ /dev/null @@ -1,29 +0,0 @@ -@startuml - -!include skinparams.puml - -class EngineCore { -} - -class IO { - processComand() -} - -!include GameState.pumlc - -'class EngineBoard { -' setSize() -' setKomi() -' play() -' undo() -'} - -class EngineAI { - genmove(board) -} - -EngineCore --> IO -EngineCore --> GameState -EngineCore --> EngineAI - -@enduml diff --git a/doc/diagrams/interfaces.puml b/doc/diagrams/interfaces.puml new file mode 100644 index 0000000..3ade81e --- /dev/null +++ b/doc/diagrams/interfaces.puml @@ -0,0 +1,20 @@ +@startuml + +!include ./skinparams.puml + +component Game +component Engine +component Trainer + +interface "Game text interface" as GTI +interface "Engine text interface" as ETI +interface "Neural network model" as NNM +interface "SGF files" as SGF + +Game -- GTI +Engine -- ETI +Engine -- NNM +Trainer -- NNM +Trainer -- SGF + +@enduml diff --git a/doc/diagrams/keras.puml b/doc/diagrams/keras.puml new file mode 100644 index 0000000..98776d1 --- /dev/null +++ b/doc/diagrams/keras.puml @@ -0,0 +1,13 @@ +@startuml + +!include skinparams.puml + +!include DecisionAlgorithm.pumlc +!include Keras.pumlc +!include NeuralNetwork.pumlc + +DecisionAlgorithm <|.. Keras + +Keras -> NeuralNetwork + +@enduml diff --git a/doc/diagrams/modules.puml b/doc/diagrams/modules.puml index 064be1d..5b8d78c 100644 --- a/doc/diagrams/modules.puml +++ b/doc/diagrams/modules.puml @@ -1,6 +1,6 @@ @startuml -!include ./skinparams.puml +!include skinparams.puml !include GameState.pumlc !include SGF.pumlc diff --git a/doc/diagrams/planificationWorkPlanEngine.puml b/doc/diagrams/planificationWorkPlanEngine.puml new file mode 100644 index 0000000..9caad40 --- /dev/null +++ b/doc/diagrams/planificationWorkPlanEngine.puml @@ -0,0 +1,46 @@ +@startgantt + +!include skinparams.puml +!include skinparamsGantt.puml + +printscale weekly +Saturday are closed +Sunday are closed + +Project starts 2021-01-11 + +-- Preliminary research -- +[Previous works research] as [PWR] lasts 1 week +[Algorithms research] as [AR] lasts 2 weeks + +-- Engine Implementation -- +[Engine modelling] as [EM] lasts 1 week +[Engine implementation] as [EI] lasts 4 weeks + +-- Algorithms Implementations -- +[Monte Carlo implementation] as [MCI] lasts 4 weeks +[Neural networks research] as [NNR] lasts 2 weeks +[Neural networks implementation] as [NNI] lasts 3 weeks + +-- Testing -- +[Engine unit testing] as [EUT] lasts 4 weeks +[System testing] as [ST] lasts 1 week + +-- Analysis -- +[Algorithms comparison] as [AC] lasts 2 weeks + +[PWR] -> [AR] +[AR] -> [EM] + +[EM] -> [MCI] +[EM] -> [EI] +[EM] -> [EUT] + +[MCI] -> [NNR] +[NNR] -> [NNI] + +[NNI] -> [ST] + +[ST] -> [AC] + +@endgantt diff --git a/doc/diagrams/planificationWorkPlanGame.puml b/doc/diagrams/planificationWorkPlanGame.puml new file mode 100644 index 0000000..ffaf72c --- /dev/null +++ b/doc/diagrams/planificationWorkPlanGame.puml @@ -0,0 +1,30 @@ +@startgantt + +!include skinparams.puml +!include skinparamsGantt.puml + +printscale weekly zoom 2 +Saturday are closed +Sunday are closed + +Project starts 2020-11-02 + +-- Preliminary research -- +[Previous works research] as [PWR] lasts 1 week + +-- Game Implementation -- +[Domain modelling] as [DM] lasts 1 week +[Domain implementation] as [DI] lasts 6 weeks + +-- Testing -- +[Unit testing] as [UT] lasts 6 weeks +[System testing] as [ST] lasts 1 week + +[PWR] -> [DM] + +[DM] -> [DI] +[DM] -> [UT] + +[DI] -> [ST] + +@endgantt diff --git a/doc/diagrams/skinparams.puml b/doc/diagrams/skinparams.puml index cde3da7..d9dce03 100644 --- a/doc/diagrams/skinparams.puml +++ b/doc/diagrams/skinparams.puml @@ -1,9 +1,19 @@ @startuml +'Old style +'skin rose + skinparam { - monochrome true + 'monochrome true shadowing false linetype polyline } +'skinparam { +' shadowing false +' ActorBorderColor #339933 +' ActorBackgroundColor #88FF88 +' linetype polyline +'} + @enduml diff --git a/doc/diagrams/skinparamsGantt.puml b/doc/diagrams/skinparamsGantt.puml new file mode 100644 index 0000000..38a4b9b --- /dev/null +++ b/doc/diagrams/skinparamsGantt.puml @@ -0,0 +1,14 @@ +@startuml + +<style> +ganttDiagram { + task { + FontSize 10 + } + separator { + FontSize 15 + } +} +</style> + +@enduml diff --git a/doc/diagrams/trainingModule.puml b/doc/diagrams/trainingModule.puml new file mode 100644 index 0000000..81d5d72 --- /dev/null +++ b/doc/diagrams/trainingModule.puml @@ -0,0 +1,20 @@ +@startuml + +!include skinparams.puml + +package "Training module" { + + !include SGF.pumlc + !include sgflex.pumlc + !include sgfyacc.pumlc + !include ASTNode.pumlc + !include Property.pumlc + + SGF ..> sgfyacc + sgfyacc .> sgflex + sgfyacc ..> ASTNode + ASTNode .> Property + +} + +@enduml diff --git a/doc/diagrams/useCase_generateAMove.puml b/doc/diagrams/useCase_generateAMove.puml new file mode 100644 index 0000000..fa76edb --- /dev/null +++ b/doc/diagrams/useCase_generateAMove.puml @@ -0,0 +1,24 @@ +@startuml + +!include skinparams.puml + +actor "GUI program / Human user" as user + +boundary "Engine CLI" as cli +control "Play a stone" as playStone +control "Think next move" as think +entity "Board state" as state + +loop until desired board is set + user -> cli : play stone + cli -> playStone + playStone -> state + cli <- state +end + +user -> cli : ask for move +cli -> think +think -> state +cli <- state : Show move + +@enduml diff --git a/doc/diagrams/useCase_playAMatch.puml b/doc/diagrams/useCase_playAMatch.puml new file mode 100644 index 0000000..65d1517 --- /dev/null +++ b/doc/diagrams/useCase_playAMatch.puml @@ -0,0 +1,20 @@ +@startuml + +!include skinparams.puml + +actor "Player" as player + +boundary "Game CLI" as cli +control "Play a stone" as playStone +control "Show board" as showBoard +entity "Board state" as state + +loop until game ends + player -> cli + cli -> playStone + playStone -> state + showBoard <- state + cli <- showBoard +end + +@enduml diff --git a/doc/diagrams/useCase_useAsBackend.puml b/doc/diagrams/useCase_useAsBackend.puml new file mode 100644 index 0000000..9076769 --- /dev/null +++ b/doc/diagrams/useCase_useAsBackend.puml @@ -0,0 +1,32 @@ +@startuml + +!include skinparams.puml + +actor "Opponent" as opponent +actor "GUI Program" as program + +boundary "Engine CLI" as cli +control "Play a stone" as playStone +control "Think next move" as think +entity "Board state" as state + +loop until starting board is set + program -> cli : play stone + cli -> playStone + playStone -> state + cli <- state +end + +loop until game ends + program -> cli : ask for move + cli -> think + think -> state + cli <- state : Show move + opponent -> program : give input + program -> cli : play stone + cli -> playStone + playStone -> state + cli <- state +end + +@enduml diff --git a/doc/diagrams/useCases.puml b/doc/diagrams/useCases.puml new file mode 100644 index 0000000..8d4aa71 --- /dev/null +++ b/doc/diagrams/useCases.puml @@ -0,0 +1,18 @@ +@startuml + +!include skinparams.puml + +actor "Human Player" as player +actor "GUI Program" as gui +actor "Human User" as user + +usecase "Play a match" as play +usecase "Use as backend for machine player" as backend +usecase "Generate a move" as genMove + +player --> play +gui --> backend +user --> genMove +gui --> genMove + +@enduml |