fork download
  1. # coding:utf-8
  2.  
  3. class Monopoly:
  4. def __init__(self, *players):
  5. self.board = list(self._init_board())
  6. self.players = list(self._init_players(players))
  7.  
  8. def _init_board(self):
  9. KEYS = ('name', 'color', 'list_price', 'construction_cost', 'remarks')
  10. PROPS = (('GO', 0, 0, 0, 'Starting_point', []),
  11. ('Mediterranean Street', 1, 60, 50, 'No_information', []))
  12. return map(lambda prop: dict(zip(KEYS, prop)), PROPS)
  13.  
  14. def _init_players(self, players):
  15. KEYS = ('name', 'money', 'pos')
  16. return map(lambda name: dict(zip(KEYS, (name, 1500, 0))), players)
  17.  
  18. game = Monopoly('a', 'b')
  19.  
  20. print(game.board)
  21. print(game.players)
Success #stdin #stdout 0.02s 27712KB
stdin
Standard input is empty
stdout
[{'remarks': 'Starting_point', 'color': 0, 'list_price': 0, 'name': 'GO', 'construction_cost': 0}, {'remarks': 'No_information', 'color': 1, 'list_price': 60, 'name': 'Mediterranean Street', 'construction_cost': 50}]
[{'name': 'a', 'pos': 0, 'money': 1500}, {'name': 'b', 'pos': 0, 'money': 1500}]