def run_test(input_data): state = input_data["state"] state_double = copy.deepcopy(state) world = lab.World(state_double) GC.init() if input_data["test"] == "i": return run_init(world) return run_moves(input_data, world)
def ui_init(input_data): global ui_world parameters = None with open("resources/world.json", 'r') as f: parameters = json.loads(f.read()) state = {} suspects = parameters["suspects"] weapons = parameters["weapons"] rooms = parameters["rooms"] random.shuffle(suspects) random.shuffle(weapons) random.shuffle(rooms) state["players"] = parameters["players"] state["envelope"] = [ suspects.pop(), weapons.pop(), rooms.pop() ] num_players = len(parameters["players"]) num_rooms = (len(rooms)-1)/num_players num_weapons = (len(weapons)-1)/num_players num_suspects = (len(suspects)-1)/num_players card_assignments = {} for player in parameters["players"]: card_assignments[player] = {} c = card_assignments[player] #assign rooms c["rooms"] = [ rooms.pop() for x in range(num_rooms) ] c["weapons"] = [ weapons.pop() for x in range(num_weapons) ] c["suspects"] = [ suspects.pop() for x in range(num_suspects) ] state["playersCards"] = card_assignments ui_world = lab.World(state) return GC.init()