def __init__(self, master, p1, p2): self.HOLEW = 100 #width of hole self.HEIGHT = 250 #height of hole self.BOARDW = 500 #width of board self.PAD = 2 #padding between each hole self.game = MancalaBoard() #call Mancala Board class self.p1 = p1 #player 1 self.p2 = p2 #player 2 self.BINW = self.BOARDW / self.game.NHOLES #get the width of the board to fill the hole NHOLES=6 self.turn = p1 #current player is player 1 self.wait = p2 #player 2 has to wait self.root = master #root = Tk() open window frame = Frame(master,bg='light goldenrod yellow') #open frame frame.pack() #pack frame # Create the board self.makeBoard( frame ) #makeBoard function takes frame as argument displayStr = "Let's play Mancala!" #string # w = Label(master, option, ...) # master-parent window # option-list of commonly used option--text # self.frame is parent window self.status = Label(frame, text=displayStr,bg='light goldenrod yellow',fg='rosybrown4') #display one or more lines of text that cannot be modified by the user self.status.config(font=('Jokerman', 18,'bold')) self.status.pack(side=BOTTOM) #show text in status
def __init__(self, master, p1, p2, enableGUI): self.CUPW = 75 self.HEIGHT = 200 self.BOARDW = 400 self.PAD = 0 self.game = MancalaBoard() self.p1 = p1 self.p2 = p2 self.BINW = self.BOARDW / self.game.NCUPS self.turn = p1 self.wait = p2 self.root = master self.GUI = enableGUI frame = Frame(master) frame.pack() # Create the board self.makeBoard(frame) displayStr = "Welcome to Mancala" self.status = Label(frame, text=displayStr) self.status.pack(side=BOTTOM) self.won = Player(-1, 0, 0)
def __init__(self, playerNum, playerType, ply=0): """Initialize a Player with a playerNum (1 or 2), playerType (one of the constants such as HUMAN), and a ply (default is 0).""" from MancalaBoard import * self.prev_board = MancalaBoard() self.num = playerNum self.opp = 2 - playerNum + 1 self.type = playerType self.ply = ply
import time execfile("MancalaGUI.py") # create mancala pllayers me1 = MancalaPlayer(1, Player.ABPRUNE) me2 = MancalaPlayer(1, Player.MINIMAX) player1 = MancalaPlayer(2, Player.MINIMAX) player2 = Player(2, Player.RANDOM) player3 = Player(2, Player.MINIMAX) #opponents = [player2, player3, player4] mes = [me1, me2] opponents = [player3] myBoard = MancalaBoard() iterations = 2 for meNume, me in enumerate(mes): for oppNum, currentOpponent in enumerate(opponents): #reset the scores p1 = 0 p2 = 0 print "" print "***********************************************" print "me" + str(meNume + 1) + " playing against opponent" + str(oppNum + 1)
def runGame(player_1, p1, player_2, p2, gamesWon): game = MancalaBoard.MancalaBoard() winner = game.hostGame(player_1, player_2) gamesWon[p1] += winner[0] gamesWon[p2] += winner[1] print time.strftime('%H:%M:%S') + ': Finished', p1, 'v', p2
def setUp(self): self.board = MancalaBoard.MancalaBoard() self.player1 = slv398.slv398(1, slv398.Player.MINIMAX, 3) self.player2 = slv398.slv398(2, slv398.Player.ABPRUNE, 3)
def setUp(self): self.board = MancalaBoard.MancalaBoard() self.player1 = slv398.slv398(1, slv398.Player.CUSTOM) self.player2 = slv398.slv398(2, slv398.Player.CUSTOM)