Skip to content
Open
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
42 changes: 32 additions & 10 deletions MyBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ def get_winning_stance(stance):
elif stance == "Scissors":
return "Rock"



def node_value(node, map):
return random.randint(0,10)



def best_stance(map):
return random.randint(0,2)



# main player script logic
# DO NOT CHANGE BELOW ----------------------------
for line in fileinput.input():
Expand All @@ -33,25 +45,35 @@ def get_winning_stance(stance):

me = game.get_self()

if me.location == me.destination: # check if we have moved this turn
# get all living monsters closest to me
monsters = game.nearest_monsters(me.location, 1)
opponent = game.get_opponent()

if me.location == me.destination:

adjacent_nodes = game.get_adjacent_nodes
adjacent_nodes.append(me.location)

maxVal = node_value(adjacent_nodes[0], game)

destination_node = me.location

for i in game.get_adjacent_nodes(me.location):

# choose a monster to move to at random
monster_to_move_to = monsters[random.randint(0, len(monsters)-1)]
current_value = node_value(i, game)

# get the set of shortest paths to that monster
paths = game.shortest_paths(me.location, monster_to_move_to.location)
destination_node = paths[random.randint(0, len(paths)-1)][0]
if (current_value > maxVal):
destination_node = i
maxVal = current_value
else:
destination_node = me.destination

if game.has_monster(me.location):
if opponent.location != me.location:
chosen_stance = stances[best_stance(game)]
elif game.has_monster(me.location):
# if there's a monster at my location, choose the stance that damages that monster
chosen_stance = get_winning_stance(game.get_monster(me.location).stance)
else:
# otherwise, pick a random stance
chosen_stance = stances[random.randint(0, 2)]

# submit your decision for the turn (This function should be called exactly once per turn)
game.submit_decision(destination_node, chosen_stance)
game.submit_decision(destination_node, chosen_stance)