Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arctic scavengers #31

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion agents/random_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ class RandomAgent(Agent):
agent_type_id : str = "random"

def take_action(self, rules : Rules, observation: Observation, available_actions: AvailableActions, show_state : bool):
actions = list(available_actions.predefined.keys())
actions = list(available_actions.predefined.keys()) + list(available_actions.openended.keys())
return Action(action_id=random.choice(actions))
11 changes: 7 additions & 4 deletions games/arctic_scavengers/arctic_scavengers.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,12 @@ def update_resource_gather(self, action : Action, available_actions : Available
else:
try:
action_items = list(ast.literal_eval(str(action.openended_response)))
if len(action_items) == 0:
raise ValueError
except:
action_items = [[random.choice(player.cards["draw"])]]
types = [a for a in action_items[0][0].actions.keys()]
choice = random.choice(player.cards["draw"])
action_items = [[choice]]
types = [a for a in choice.actions.keys()] if choice.actions else []
action_items.insert(0, random.choice(types + ["TRASH"])) # No random hiring or stopping


Expand Down Expand Up @@ -291,7 +294,7 @@ def update_resource_gather(self, action : Action, available_actions : Available
break
for card in player.cards["draw"]:
if card.title == card_name:
if "MEDICINE" in card.actions:
if card.actions != None and "MEDICINE" in card.actions:
med_currency += card.actions["MEDICINE"].value
if food_cost > player.food or med_cost > med_currency:
valid = False
Expand All @@ -301,7 +304,7 @@ def update_resource_gather(self, action : Action, available_actions : Available
mercenary_names.append(m[0].title)
if action_items[2] not in mercenary_names:
valid = False
if player.actions[id] > 0: # If action has already been taken
if id not in player.actions or player.actions[id] > 0: # If action has already been taken
valid = False
if self.show_state: print("Action already taken")
if self.show_state: print(valid)
Expand Down