""" This class handles the client side of the backgammon player. Students should run this class to view games """ from ui import display_constants from ui.screens import menu, ingame # online import pygame import sys # Below are the agents used in "Play Offline" # To change, simply add an import and change p1 or p2 to desired Agent from agents import randomAgent, backgammon_ssbg, backgammon_dsbg, backgammon_dsbg_1 player1 = backgammon_ssbg.BackgammonPlayer() player2 = randomAgent.BackgammonPlayer() DETERMINISTIC = False # deterministic version: dice are loaded to give 1 and 6 # stochastic version (DETERMINISTIC = false): dice are rolled normally. # Student's UW net-id username = "******" # DO NOT CHANGE ANY CODE BELOW THIS # ------------------------------------------------------------------------------------------------------------------ pygame.init() pygame.display.init() pygame.display.set_caption("Backgammon") window = pygame.display.set_mode( (display_constants.WINDOW_WIDTH, display_constants.WINDOW_HEIGHT)) DEBUG = False try:
1. There is duplicate methods in this class and in genmoves.py. Some of the methods in genmoves.py do not seem to be the finished versions (as they were slightly different from the original code in this method), but I don't know which to keep. """ from game_engine import genmoves from game_engine.boardState import * import copy GENMOVES_INSTANCE = genmoves.GenMoves() DONE = False # Below are the agents used in "Play Offline" # To change, simply add an import and change p1 or p2 to desired Agent from agents import randomAgent, SkeletonAgent, backgammon_dsbg, backgammon_ssbg ##agent1 represents the white checkers and agent2 the red checkers agent1 = backgammon_ssbg.BackgammonPlayer() agent2 = SkeletonAgent.BackgammonPlayer() DETERMINISTIC = False # deterministic version: dice are loaded to give 1 and 6 # stochastic version (DETERMINISTIC = false): dice are rolled normally. def run(white_player, red_player, max_secs_per_move, deterministic, print_to_console, initial_state): """Start and monitor a game of Simplified Backgammon. The two players are white and red, which must be instances of a class that implements method named "move". max_secs_per_move is the time limit. If it's 0, then no time limit. initial_state is a function that should return a valid state from which the game should start. The default is to start from the beginning -- the standard starting board for Backgammon.