Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def grid_to_string(grid, player):
- """Turns a grid and player into a string
- Arguments:
- grid -- list of list of Cells
- player -- a Player with water buckets
- Returns:
- string: A string representation of the grid and player.
- """
- string = ""
- for i, ls in enumerate(grid):
- for j, cells in enumerate(ls):
- if i == player.row and j == player.col:
- string += player.display
- else:
- string += cells.display
- string += "\n"
- if player.num_water_buckets == 1:
- string += f"\nYou have {player.num_water_buckets} water bucket."
- else:
- string += f"\nYou have {player.num_water_buckets} water buckets."
- return string
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement