SHARE
TWEET

Untitled

Eddy_S May 29th, 2020 332 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def grid_to_string(grid, player):
  2.     """Turns a grid and player into a string
  3.  
  4.    Arguments:
  5.        grid -- list of list of Cells
  6.        player -- a Player with water buckets
  7.  
  8.    Returns:
  9.        string: A string representation of the grid and player.
  10.    """
  11.     string = ""
  12.     for i, ls in enumerate(grid):
  13.         for j, cells in enumerate(ls):
  14.             if i == player.row and j == player.col:
  15.                 string += player.display
  16.             else:
  17.                 string += cells.display
  18.         string += "\n"
  19.     if player.num_water_buckets == 1:
  20.         string += f"\nYou have {player.num_water_buckets} water bucket."
  21.     else:
  22.         string += f"\nYou have {player.num_water_buckets} water buckets."
  23.     return string
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top