2015-01-17

7 Wonders

This post is about the board game 7 Wonders. Sometimes there is a bit of confusion about calculating the victory points from the green cards (scientific structures). Each of the green cards has a symbol (tablet, compass or gear). The player receives 7 victory points for a set of all three symbols and additionally the number of the symbols squared for every symbol. Moreover there is a purple 'joker' card (guild) that can count as any type of green card.

The following few lines of Python can be used to compute the maximum amount of victory points that can be obtained for a given amount of tablet, compass, gear and joker cards. It does this by recursively finding the best allocation for the purple joker cards.

 
#!/usr/bin/env python
""" compute max nr of points for science cards """

#type1 : gear
#type2 : tablet
#type3 : compass

def get_score(type1, type2, type3):

    a = type1**2+type2**2+type3**2
    b = min([type1, type2, type3]) * 7 #sets

   return a+b


def max_points(type1=0, type2=0, type3=0, joker=0):

    if joker==0:
        return get_score(type1, type2, type3)
    else:
        return max([
            max_points(type1+1,type2 , type3 , joker-1),
            max_points(type1 ,type2+1, type3 , joker-1),
            max_points(type1 ,type2 , type3+1, joker-1)
        ])

No comments:

Post a Comment