# make sure you've imported numpy at the start of your script (import numpy as np)
# print the game map as an array using numpy
def print_map(self, game_state):
# note the y-index will be flipped
# since numpy arrays index from top left as (0,0)
# whereas our map follows a cartesian coordinate system with bottom left as (0,0)
cols = game_state.size[0]
rows = game_state.size[1]
game_map = np.zeros((rows, cols)).astype(str)
entity = game_state.entity_at((x,y))
game_map[y][x] = 9 # using 9 here as 'free' since 0 = Player 1
# thank you: @ifitaintbroke for providing a fixed version