Esempio n. 1
0
 def process_ai_move(self, game, ais):
     ref = Referee(game)
     cur_plyr = game.get_cur_plyr()
     cur_ai = ais[cur_plyr.name]
     json = ref.get_current_state_as_json_for_player(cur_plyr.position)
     parsed_json = from_json(json)
     move = cur_ai.decide_what_to_do_json(parsed_json)
     ref.perform_move(move)
     logging.info("After processing ai move, stage is %s ", game.stage)
Esempio n. 2
0
 def process_ai_move(self, game, ais):
     ref = Referee(game)
     cur_plyr = game.get_cur_plyr()
     cur_ai = ais[cur_plyr.name]
     json = ref.get_current_state_as_json_for_player(cur_plyr.position)
     parsed_json = from_json(json)
     move = cur_ai.decide_what_to_do_json(parsed_json)
     ref.perform_move(move)
     logging.info("After processing ai move, stage is %s ", game.stage)
Esempio n. 3
0
 def test_object_to_json(self):
     f = Foo("peter", "purple", 23)
     s = str(util.to_json(f))
     logging.debug("s ==> %s" % s)
     logging.debug("f ==> %s" % s)
     f_as_string = str(
         '{"__class__": "Foo", "__module__": "tests.test_util", "prop1": "peter", "prop2": "purple", "prop3": 23}')
     self.assertEqual(s, f_as_string)
     f2 = util.from_json(s)
     for k in ['prop1', 'prop2', 'prop3']:
         self.assertEqual(f.__dict__[k], f2[k])