Skip to content

Instantly share code, notes, and snippets.

View masouduut94's full-sized avatar
👨‍👩‍👦‍👦
Family comes before Work.

Masoud Masoumi Moghadam masouduut94

👨‍👩‍👦‍👦
Family comes before Work.
View GitHub Profile
class PoolRaveMctsAgent(RaveMctsAgent):
def __init__(self, state: GameState = GameState(8)):
super().__init__(state)
self.black_rave = {}
self.white_rave = {}
def set_gamestate(self, state: GameState) -> None:
"""
Set the root_state of the tree to the passed gamestate, this clears all
class LGRMctsAgent(RaveMctsAgent):
def __init__(self, state: GameState = GameState(8)):
super().__init__(state)
self.black_reply = {}
self.white_reply = {}
def set_gamestate(self, state: GameState) -> None:
"""
Set the root_state of the tree to the passed gamestate, this clears all
class DecisiveMoveMctsAgent(RaveMctsAgent):
def roll_out(self, state: GameState) -> tuple:
"""
Simulate a random game except that we play all known critical cells
first, return the winning player and record critical cells at the end.
"""
moves = state.moves()
good_moves = moves.copy()
good_opponent_moves = moves.copy()
to_play = state.turn()
def would_lose(self, cell: tuple, color: int) -> bool:
"""
Return True is the move indicated by cell and color would lose the game,
False otherwise.
"""
connect1 = False
connect2 = False
if color == GameMeta.PLAYERS['black']:
if cell[1] == 0:
connect1 = True
from tkinter import (Frame, Canvas, ttk, HORIZONTAL, VERTICAL, IntVar, Scale, Button, Label, PhotoImage, BOTH, LEFT, Y,
X, TOP, messagebox)
from numpy import int_
from gamestate import GameState
from meta import GameMeta
from rave_mctsagent import (RaveMctsAgent, LGRMctsAgent, PoolRaveMctsAgent, DecisiveMoveMctsAgent)
from ucb1_tuned_mctsagent import UCB1TunedMctsAgent
from uct_mcstsagent import UctMctsAgent
class RaveMctsAgent(UctMctsAgent):
def __init__(self, state: GameState = GameState(8)):
self.root_state = deepcopy(state)
self.root = RaveNode() # Replace Node with RaveNode
self.run_time = 0
self.node_count = 0
self.num_rollouts = 0
def set_gamestate(self, state: GameState) -> None:
"""
from math import sqrt, log
from copy import deepcopy
from random import choice, random
from time import clock
from gamestate import GameState
from uct_mcstsagent import Node, UctMctsAgent
from meta import *
from tkinter import Tk
from gui import Gui
def main():
root = Tk()
interface = Gui(root)
root.mainloop()
class MCTSMeta:
EXPLORATION = 0.5
RAVE_CONST = 300
RANDOMNESS = 0.5
POOLRAVE_CAPACITY = 10
K_CONST = 10
A_CONST = 0.25
WARMUP_ROLLOUTS = 7
from tkinter import (Frame, Canvas, ttk, HORIZONTAL, VERTICAL, IntVar, Scale, Button, Label, PhotoImage, BOTH, LEFT, Y,
X, TOP, messagebox)
from numpy import int_
from gamestate import GameState
from meta import GameMeta
from uct_mcstsagent import UctMctsAgent