def agent(obs, config): # read (obs, config) into internal game state object state = State(obs, config) # actions object stores a list of pending ships/yards. as we decide on # actions, we remove the ships/yards from the pending lists and store # them in a dictionary together with their actions actions = Actions(state) # convert appropriate ships into yards convert(state, actions) # plan where we want to spawn new ships spawns = Spawns(state, actions) # place bounties on selected opponent ships/yards and remember # which ships we set bounties on for the future global ship_target_memory bounties = Bounties(state, ship_target_memory) ship_target_memory = bounties.target_list # set destinations for ships and rank moves by how much closer # we get to the destinations targets = Targets(state, actions, bounties, spawns) # decide on moves for ships move(state, actions, targets) # spawn the new ships at unoccupied shipyards spawns.spawn(state, actions) return actions.asdict()
def agent(obs, config): # читаем (obs, config) во внутренний объект состояния игры state = State(obs, config) # Объект actions хранит список ожидающих кораблей / верфей. # после решения, мы удаляем корабли / верфи из списков ожидания и сохраняем # их в словаре вместе с их действиями actions = Actions(state) # преобразовать подходящие корабли в верфи convert(state, actions) # планируем, где мы хотим создавать новые корабли spawns = Spawns(state, actions) # размещение награды за выбранные корабли / верфи противника и запоминание # за какие корабли мы назначили награду на будущее global ship_target_memory bounties = Bounties(state, ship_target_memory) ship_target_memory = bounties.target_list # задаем пункты назначения для кораблей и ранжируем их, насколько ближе # мы добираемся до пунктов назначения targets = Targets(state, actions, bounties, spawns) # решаем ходы кораблей move(state, actions, targets) # создаем новые корабли на незанятых верфях spawns.spawn(state, actions) return actions.asdict()
def delexicalize_instance(input, targets, only_delex_value, has_targets, force_delex_source): delex_candidates = input.get_delex_candidates() if has_targets: input, targets = delexicalize_instance_with_targets( input, targets, delex_candidates, only_delex_value, force_delex_source) return input, targets else: input = delexicalize_instance_without_targets(input, delex_candidates, only_delex_value) return input, Targets("")
def __init__(self, output_dir, log_name): logging.basicConfig( filename=os.path.join(output_dir, f'{log_name}.log'), filemode='a', format='%(asctime)s %(name)s %(levelname)s %(message)s', datefmt='%Y-%m-%d %H:%M:%S', level=logging.DEBUG) # Used to parse prices and analyse results self.analysis = AnalyseResults() # Get scheme targets self.targets = Targets()
class TargetsTest(object): def __init__(self): self.photostore_targets = Targets(True) self.photostore_targets(create) def test_targets(self): curtime = str(time.time()) self.photostore_targets.put('1', 'foo', 'Foo', 'fa-user') self.photostore_targets.put('1', 'bar', 'Bar', 'fa-user') self.photostore_targets.put('1', 'goo', 'goo', 'fa-user') self.photostore_targets.put('1', 'gopa', 'Gopa Kumar', 'fa-user') self.photostore_targets.put('1', 'blar', 'Blar', 'fa-user') data = self.photostore_targets.get('1') for d in data: print 'GET: data target %s, description %s, icon %s, act %s\n' % \ (d['g_uid'], d['TargetDescription'], d['TargetIcon'], d['TargetAccount']) data = self.photostore_targets.get('1', 'foo') for d in data: print 'QUERY: data target %s, description %s, icon %s, act %s\n' % \ (d['g_uid'], d['TargetDescription'], d['TargetIcon'], d['TargetAccount'])
def get_user_targets(username): tgt = Targets() tgt.create() return tgt.get(username, None)
def __init__(self): self.photostore_targets = Targets(True) self.photostore_targets(create)
def __init__(self): self.nodes = NodeGroup(gridUnit, gridUnit) self.nodes.getBoardNodes("field.txt") # initialize agents self.agentRed = Agent(self.nodes.nodeList[randint(0, 2000)]) self.agentRed.color = (255, 0, 0) # print self.clyde1.id self.agentWhite = Agent(self.nodes.nodeList[randint(0, 2000)]) self.agentWhite.color = (255, 255, 255) # print self.clyde2.id self.agentTeal = Agent(self.nodes.nodeList[randint(0, 2000)]) self.agentTeal.color = (0, 255, 255) # print self.clyde3.id self.agentPurple = Agent(self.nodes.nodeList[randint(0, 2000)]) self.agentPurple.color = (100, 100, 200) # print self.clyde4.id self.agentGrey = Agent(self.nodes.nodeList[randint(0, 2000)]) self.agentGrey.color = (150, 150, 150) #print self.clyde5.id # initialize targets self.targetRed1 = Targets(self.nodes.nodeList[randint(0, 2000)], self.agentRed.id) self.targetRed1.color = (250, 1, 1) self.targetRed2 = Targets(self.nodes.nodeList[randint(0, 2000)], self.agentRed.id) self.targetRed2.color = (250, 2, 2) self.targetRed3 = Targets(self.nodes.nodeList[randint(0, 2000)], self.agentRed.id) self.targetRed3.color = (250, 3, 3) self.targetRed4 = Targets(self.nodes.nodeList[randint(0, 2000)], self.agentRed.id) self.targetRed4.color = (250, 4, 4) self.targetRed5 = Targets(self.nodes.nodeList[randint(0, 2000)], self.agentRed.id) self.targetRed5.color = (250, 5, 5) self.targetWhite1 = Targets(self.nodes.nodeList[randint(0, 2000)], self.agentWhite.id) self.targetWhite1.color = (255, 255, 255) self.targetWhite2 = Targets(self.nodes.nodeList[randint(0, 2000)], self.agentWhite.id) self.targetWhite2.color = (255, 255, 255) self.targetWhite3 = Targets(self.nodes.nodeList[randint(0, 2000)], self.agentWhite.id) self.targetWhite3.color = (255, 255, 255) self.targetWhite4 = Targets(self.nodes.nodeList[randint(0, 2000)], self.agentWhite.id) self.targetWhite4.color = (255, 255, 255) self.targetWhite5 = Targets(self.nodes.nodeList[randint(0, 2000)], self.agentWhite.id) self.targetWhite5.color = (255, 255, 255) self.targetTeal1 = Targets(self.nodes.nodeList[randint(0, 2000)], self.agentTeal.id) self.targetTeal1.color = (0, 255, 255) self.targetTeal2 = Targets(self.nodes.nodeList[randint(0, 2000)], self.agentTeal.id) self.targetTeal2.color = (0, 255, 255) self.targetTeal3 = Targets(self.nodes.nodeList[randint(0, 2000)], self.agentTeal.id) self.targetTeal3.color = (0, 255, 255) self.targetTeal4 = Targets(self.nodes.nodeList[randint(0, 2000)], self.agentTeal.id) self.targetTeal4.color = (0, 255, 255) self.targetTeal5 = Targets(self.nodes.nodeList[randint(0, 2000)], self.agentTeal.id) self.targetTeal5.color = (0, 255, 255) self.targetPurple1 = Targets(self.nodes.nodeList[randint(0, 2000)], self.agentPurple.id) self.targetPurple1.color = (100, 100, 200) self.targetPurple2 = Targets(self.nodes.nodeList[randint(0, 2000)], self.agentPurple.id) self.targetPurple2.color = (100, 100, 200) self.targetPurple3 = Targets(self.nodes.nodeList[randint(0, 2000)], self.agentPurple.id) self.targetPurple3.color = (100, 100, 200) self.targetPurple4 = Targets(self.nodes.nodeList[randint(0, 2000)], self.agentPurple.id) self.targetPurple4.color = (100, 100, 200) self.targetPurple5 = Targets(self.nodes.nodeList[randint(0, 2000)], self.agentPurple.id) self.targetPurple5.color = (100, 100, 200) self.targetGrey1 = Targets(self.nodes.nodeList[randint(0, 2000)], self.agentGrey.id) self.targetGrey1.color = (150, 150, 150) self.targetGrey2 = Targets(self.nodes.nodeList[randint(0, 2000)], self.agentGrey.id) self.targetGrey2.color = (150, 150, 150) self.targetGrey3 = Targets(self.nodes.nodeList[randint(0, 2000)], self.agentGrey.id) self.targetGrey3.color = (150, 150, 150) self.targetGrey4 = Targets(self.nodes.nodeList[randint(0, 2000)], self.agentGrey.id) self.targetGrey4.color = (150, 150, 150) self.targetGrey5 = Targets(self.nodes.nodeList[randint(0, 2000)], self.agentGrey.id) self.targetGrey5.color = (150, 150, 150) self.Agents = [self.agentRed, self.agentWhite, self.agentTeal, self.agentPurple, self.agentGrey] self.Targets = [self.targetRed1, self.targetRed2, self.targetRed3, self.targetRed4, self.targetRed5, self.targetWhite1, self.targetWhite2, self.targetWhite3, self.targetWhite4, self.targetWhite5, self.targetTeal1, self.targetTeal2, self.targetTeal3, self.targetTeal4, self.targetTeal5, self.targetPurple1, self.targetPurple2, self.targetPurple3, self.targetPurple4, self.targetPurple5, self.targetGrey1, self.targetGrey2, self.targetGrey3, self.targetGrey4, self.targetGrey5] self.checkList = []