Skip to content

Commit

Permalink
add mons game stub
Browse files Browse the repository at this point in the history
  • Loading branch information
grachyov committed May 2, 2024
1 parent 4322fb9 commit 0d5dff7
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,14 @@ checkpoints/
# For PyCharm users
.idea/

# Virtual environment directories
venv/
env/
ENV/

# Python virtual environment specific files
*.py[cod]
__pycache__/
pyvenv.cfg
pip-log.txt
pip-delete-this-directory.txt
121 changes: 121 additions & 0 deletions mons/MonsGame.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
from __future__ import print_function
import sys
sys.path.append('..')
from Game import Game
import numpy as np

# TODO: implement

class MonsGame(Game):
"""
This class specifies the base Game class. To define your own game, subclass
this class and implement the functions below. This works when the game is
two-player, adversarial and turn-based.
Use 1 for player1 and -1 for player2.
See othello/OthelloGame.py for an example implementation.
"""
def __init__(self):
pass

def getInitBoard(self):
"""
Returns:
startBoard: a representation of the board (ideally this is the form
that will be the input to your neural network)
"""
pass

def getBoardSize(self):
"""
Returns:
(x,y): a tuple of board dimensions
"""
pass

def getActionSize(self):
"""
Returns:
actionSize: number of all possible actions
"""
pass

def getNextState(self, board, player, action):
"""
Input:
board: current board
player: current player (1 or -1)
action: action taken by current player
Returns:
nextBoard: board after applying action
nextPlayer: player who plays in the next turn (should be -player)
"""
pass

def getValidMoves(self, board, player):
"""
Input:
board: current board
player: current player
Returns:
validMoves: a binary vector of length self.getActionSize(), 1 for
moves that are valid from the current board and player,
0 for invalid moves
"""
pass

def getGameEnded(self, board, player):
"""
Input:
board: current board
player: current player (1 or -1)
Returns:
r: 0 if game has not ended. 1 if player won, -1 if player lost,
small non-zero value for draw.
"""
pass

def getCanonicalForm(self, board, player):
"""
Input:
board: current board
player: current player (1 or -1)
Returns:
canonicalBoard: returns canonical form of board. The canonical form
should be independent of player. For e.g. in chess,
the canonical form can be chosen to be from the pov
of white. When the player is white, we can return
board as is. When the player is black, we can invert
the colors and return the board.
"""
pass

def getSymmetries(self, board, pi):
"""
Input:
board: current board
pi: policy vector of size self.getActionSize()
Returns:
symmForms: a list of [(board,pi)] where each tuple is a symmetrical
form of the board and the corresponding pi vector. This
is used when training the neural network from examples.
"""
pass

def stringRepresentation(self, board):
"""
Input:
board: current board
Returns:
boardString: a quick conversion of board to a string format.
Required by MCTS for hashing.
"""
pass

0 comments on commit 0d5dff7

Please sign in to comment.