Skip to content

Instantly share code, notes, and snippets.

@tulioz
Last active December 25, 2015 01:38
Show Gist options
  • Select an option

  • Save tulioz/6896195 to your computer and use it in GitHub Desktop.

Select an option

Save tulioz/6896195 to your computer and use it in GitHub Desktop.
class OfersZombie(object):
"""
This bot rolls dice as long as continue_rolling returns True
continue_rolling returns true as long as there's a good chance to get more
brains due to presence of green dice
"""
def __init__(self, name):
self.name = name
def turn(self, gameState):
shotgun_count = 0
brains = 0
dice_left = {"green": 6,
"yellow": 4,
"red": 3}
while self.continue_rolling(shotgun_count, dice_in_hand, dice_left, brains):
dice_in_hand = {"green": 0,
"yellow": 0,
"red": 0}
results = roll()
if results == []:
return
for result in results:
color = result['color']
icon = result['icon']
if icon == 'shotgun':
shotgun_count += 1
dice_left[color] -= 1
elif icon == 'brains':
brains += 1
dice_left[color] -= 1
else:
dice_in_hand[color] += 1
def continue_rolling(self, shotgun_count, dice_in_hand, dice_left, brains):
if brains <= 1:
return True
if shotgun_count == 2:
if brains >= 3:
return False
elif dice_in_hand['green'] >= 2:
return True
else:
return False
if dice_in_hand['green'] >= 2:
return True
if dice_left['green'] >= 3 and dice_in_hand['red'] < 2:
return True
else:
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment