ghohl30 / Hivemind

python implementation of the board game Hive
0 stars 0 forks source link

Problem in Aggressive player --> get_matrices #5

Closed ghohl30 closed 4 months ago

ghohl30 commented 5 months ago

when running a game with the aggressive player using the evaulate.py I get the following error:

Simulating games: 0%| | 0/100 [00:00<?, ?it/s]2 Traceback (most recent call last): File "/Users/gregor30/Documents/Programmieren/Python/Hivemind/src/scripts/evaluate.py", line 116, in wins, num_moves = evaluate_player(player, 100) File "/Users/gregor30/Documents/Programmieren/Python/Hivemind/src/scripts/evaluate.py", line 73, in evaluate_player game.turn.make_move() File "/Users/gregor30/Documents/Programmieren/Python/Hivemind/src/scripts/../../src/ComputerPlayers.py", line 44, in make_move mask = self.active_game.board.move_mask() File "/Users/gregor30/Documents/Programmieren/Python/Hivemind/src/scripts/../../src/hive.py", line 343, in move_mask idxs = [(self.labels.index(move.piece.name), self.labels.index(p.name), ((k+3)%6)+1) for k, p in enumerate(move.edge) if p is not None] File "/Users/gregor30/Documents/Programmieren/Python/Hivemind/src/scripts/../../src/hive.py", line 343, in idxs = [(self.labels.index(move.piece.name), self.labels.index(p.name), ((k+3)%6)+1) for k, p in enumerate(move.edge) if p is not None] ValueError: 'wB3' is not in list

ghohl30 commented 4 months ago

the same happens when running the random_game file with two random players so it seems to be a problem with the matrix stuff

Move number: 1 Traceback (most recent call last): File "/Users/gregor30/Documents/Programmieren/Python/Hivemind/src/scripts/random_game.py", line 37, in A, M, firstPiece = game.board.get_matrices() File "/Users/gregor30/Documents/Programmieren/Python/Hivemind/src/scripts/../../src/hive.py", line 367, in get_matrices index = self.labels.index(piece.name) ValueError: 'wB3' is not in list

ghohl30 commented 4 months ago

Actually the issue was just that I had messed with the game mode and it no longer made sense with the lables:

here you can play with the number and types of pieces

game_mode = [('QueenBee', 1), ('Ant',3), ('Beetle', 2), ('Spider', 2), ('Grasshopper', 3)]
# game_mode = [('Bee', 1), ('Beetle', 2)]

# List of labels
labels = ['wQ1', 'wA1', 'wA2', 'wA3', 'wG1', 'wG2', 'wG3', 'wB1', 'wB2', 'wS1', 'wS2', 
            'bQ1', 'bA1', 'bA2', 'bA3', 'bG1', 'bG2', 'bG3', 'bB1', 'bB2', 'bS1', 'bS2']

I will create an issue. The lables should be generated from the game_mode