Skip to content

Commit

Permalink
fix: add updateBoard to geneticAlgAgentJon.py
Browse files Browse the repository at this point in the history
  • Loading branch information
JonBergland committed Apr 29, 2024
1 parent afa8615 commit f41ee8c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/agents/geneticAlgAgentJon.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ def play_game(self, agg_height, max_height, lines_cleared, bumpiness, holes):
move += 1
# Advance the game by one frame
board.doAction(Action.SOFT_DROP)
if board.blockHasLanded:
board.updateBoard()
#board.printBoard()

total_cleared += board.rowsRemoved
Expand Down Expand Up @@ -116,7 +118,7 @@ def paring_pop(self, pop_list: list[list[list[float], float]]) -> list[list[floa
norm = np.linalg.norm(new_pop[0])
if norm == 0:
norm = 1e-10 # or some small constant
new_pop[0] = (new_pop[0] / norm).tolist()
new_pop[0] = [i / norm for i in new_pop[0]]

# Mutate 5% of children pops
if random.randrange(0,1000)/1000 < 0.05:
Expand Down

0 comments on commit f41ee8c

Please sign in to comment.