Translate Ludii to GDL
code the translator via Jupyter-notebook which is draft version
code the translator as seperate files, but there are some bugs which could lead to failure currently. Those bug will be fixed later
- ReadFile.py: read the ludii file and get the key information
- CONSTANT.py: containing the constant which is global variables
- Ludii2GDL.py: calling the translating component(tanslate game, players, equipment, rules) and write GDL file
- main.py: run the translator
- Ludii_keyword: translate the Ludii to GDL based on keyword
- Ludii_file: existing ludii file
- GDL_file: translated gdl filee
KEYWORD-1: Game, Players, Equipment, Board, Piece, Region, Rules, Start, Play, End.
KEYWORD-2: Square, Line, Each, ForEach, Top, Bottom.
KEYWORD-3: Mover, Empty, Add, Apply, Expand, Remove, Stack(FIX BUG)
KEYWORD-4: ColumnSize, IsEnemyAt, StepForwardToEmpty, ReachWin.
Format: (Game <string>)
- <string>: the name of Game
Format: (Players <int|list>)
- <int|list>:
- int: the number of players
- list: the list of players
Format: (Equipment )
- : the ludii that including basic information of game
Format: (Board (<square|line> ))
- <square|line>:
- square: square game
- line: line game
- : the size of game:
if it is board game, the size is NxN; if it is line game, the size is 1xN.
Format: (Piece <string> <KEYWORD>)
- <string>: the name of Piece
- <KEYWORD>:
- if is <P1|P2|etc.>, it indicates the the player-1 is
- if is , it indicates that all piece in this game is (it always is 'Pawn')
Format: format: ((regions <P1|P2|etc> (sites <Top|Bottom>)))
- <P1|P2|etc>: the player
- sites <Top|Bottom>: the PX sites on the Top or Bottom of board
Format: (Rules <Ludii>)
- <Ludii>: it is ludii that descript the rules of game
Format: (start {(place <string-Piece> (), etc})
- place: a keyword
- <string-Piece>: the name of Piece, which is defined on keyword-Piece
- : define the move of game
Format: (play <Ludii-Move>)
- <Ludii-Move>: define the move of game
Format: format: (end <Ludii-End>)
- <Ludii-End>: define the terminal of game
it is square game
it is line game
The Top area of board
the bottom area of board
define the name of each piece
define the legal move of each piece
current players
the cell is blank
add the piece on a cell
Format: (move add(to <Ludii-Cell>))
- : the status of the cell
excuting the move
Format: (Apply <Ludii-Move>):
- <Ludii-Move>: define the move of game
expand direction{From top to bottom; From bottom to Top}
Format: (Expand (sites <Top|Bottom>)):
- <Top|Bottom>: if it is Top, expanding from bottom to Top; if it is Bottom, expanding from Top to Bottom
Any piece owned by the current player can be removed from the board.
Format: (remove (sites )):
- : existing piece on this cell
specifies if the piece is added on top of a stack or not.
count the size of special column
judge special cell is empty or not
the legal move for a piece is move forward, including front-left, front & front-right
if mover reaches the opponent's start point, the mover win the game
There are two version for determine the Line
- the version-1: it contains the variable and using (++ x1 x2) etc. to determine the Line
- the version-2: it is more complicated. It means that it wirte down all situation that it is Line, which means that larger board size has more situation For GDL, the version-1 is more effective, because it could describe the game with less code. Moreover, convert to PropNet, the Version-1 PropNet is smaller than the Verson-2 PropNet. However, the Version-2 PropNet is more effective on training NN. The connect-4 as the example, training NN using version-1 PropNet takes 1408s for 50 self-play games; training NN using version-2 PropNet takes 1087s for 50 self-play games. Currently, I will explore the reason of this condition if i have enough time.