Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from __main__ import Adventurer
- class DeepDiver(Adventurer):
- def get_action(self, state):
- if state.treasures:
- tvals = {}
- for i in range(len(state.treasures)):
- itm = state.treasures[i]
- w = itm.weight
- v = itm.value
- if w + state.carry_weight > self.max_total_weight or w > self.max_single_weight:
- w = 100
- if v / w < state.room * self.min_value_ratio:
- v = 0
- tvals[i] = v / w
- besttind = max(tvals, key=lambda x: tvals[x])
- bestt = (besttind,
- state.treasures[besttind].value,
- state.treasures[besttind].weight)
- else:
- bestt = None
- if state.room < self.max_dive_dist and state.carry_weight == 0:
- return 'next'
- if bestt and state.carry_weight + bestt[2] <= self.max_total_weight and bestt[1] > 0 and bestt[2] <= self.max_single_weight:
- return 'take',bestt[0],bestt[2]
- return 'previous'
- def enter_ruins(self):
- self.max_single_weight = 2
- self.max_total_weight = 15
- self.min_value_ratio = 2
- self.max_dive_dist = 43
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement