Skip to content

Instantly share code, notes, and snippets.

@andrewheiss
Created July 12, 2012 00:40
Show Gist options
  • Save andrewheiss/3094757 to your computer and use it in GitHub Desktop.
Save andrewheiss/3094757 to your computer and use it in GitHub Desktop.
Excerpt from basic algorithm
def a_ask_b_to_join():
print "Inviting B"
if b_delta_if_move >= 0 and b_delta_if_move > b_delta_if_stay:
print "This is the ideal situation; {0} will gain {1} points and {2} will gain {3}. Permission granted.".format(player_a.name, a_delta_if_stay, player_b.name, b_delta_if_move)
player_b.joinTeam(team_a)
return True
elif b_delta_if_stay >= 0 and b_delta_if_stay > b_delta_if_move:
print "It's better if B stays... but why not... join!" # TODO: Maybe base this on a percentage?
player_b.joinTeam(team_a)
return True
elif b_delta_if_move == b_delta_if_stay and b_delta_if_move > 0:
print "It doesn't matter to B. Permission granted."
player_b.joinTeam(team_a)
return True
else:
print "Permission denied"
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment