def put(self, where, what): assert GameUtils.is_proper_pawn(what) assert GameUtils.is_proper_index(where) if self.board[where] != GameUtils.EMPTY: return False self.board[where] = what return True
def __init__(self, x, y): self.image1, self.rect1 = GameUtils.load_image( 'player-1.png', rescale=(GameEngine.CELL_SIZE, GameEngine.CELL_SIZE)) self.image2, self.rect2 = GameUtils.load_image( 'player-2.png', rescale=(GameEngine.CELL_SIZE, GameEngine.CELL_SIZE)) self.image3, self.rect3 = GameUtils.load_image( 'player-3.png', rescale=(GameEngine.CELL_SIZE, GameEngine.CELL_SIZE)) self.set_weight(2) # self.rect = self.rect2 super().__init__(x, y)
def __init__(self, x, y): self.image, self.rect = GameUtils.load_image('trajectory.png', rescale=(6, 6)) super().__init__(x, y, x_offset=GameEngine.CELL_SIZE // 2 - 3, y_offset=GameEngine.CELL_SIZE // 2 - 3)
def __init__(self, x, y): self.image, self.rect = GameUtils.load_image('searched.png', rescale=(3, 3)) super().__init__(x, y, x_offset=GameEngine.CELL_SIZE // 2 - 1, y_offset=GameEngine.CELL_SIZE // 2 - 1)
def __init__(self, x, y): self.images = [] self.rects = [] for image_name in self.image_names: image, rect = GameUtils.load_image(image_name, rescale=(GameEngine.CELL_SIZE, GameEngine.CELL_SIZE)) self.images.append(image) self.rects.append(rect) self.set_state(0, False) super().__init__(x, y)
def make_move(self, where): if self.game_finished(): #print("FINISZ") return GameState.END assert GameUtils.is_proper_index(where) player = self.get_next_turn_player() if not self._board.put(where, player.get_pawn()): self._game_state = GameState.BAD_MOVE elif self._check_winner(): self._winner = player self._game_state = GameState.WIN elif not self._board.move_available(): self._game_state = GameState.DRAW else: self._game_state = GameState.UNRESOLVED if (self._do_change_player()): self._change_player() player = self.get_next_turn_player() return self._game_state
def __init__(self, x, y): self.image, self.rect = GameUtils.load_image( 'exit.png', rescale=(GameEngine.CELL_SIZE, GameEngine.CELL_SIZE)) super().__init__(x, y)
def __init__(self, x, y): # name = 'empty%d.png' % (((x + y) % 2) + 1) name = 'empty%d.png' % (((x + y) % 1) + 1) self.image, self.rect = GameUtils.load_image( name, rescale=(GameEngine.CELL_SIZE, GameEngine.CELL_SIZE)) super().__init__(x, y)
def __init__(self, x, y): name = 'wall%d.png' % (np.random.randint(5) + 1) self.image, self.rect = GameUtils.load_image( name, rescale=(GameEngine.CELL_SIZE, GameEngine.CELL_SIZE)) super().__init__(x, y)
from game_utils import GameUtils # This file is meant for smoke testing code utils = GameUtils() utils.read_game('game1_play_data.csv') # utils.print_game() # r1 = utils.get_round_data(1) # print(r1) # utils.print_data(r1) # r1t3p4 = utils.get_trick_data(r1, 3, 4) # utils.print_data(r1t3p4) r1t3p4 = utils.get_current_state(1, 3, 4) # utils.print_data(r1t3p4) utils.print_game()