Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

New goals, updated install instructions and some artwork

  • Loading branch information...
commit 400a0959c38d32f2f89d9d81a941cb8bd1c64f31 1 parent 4571d53
David Lu!! DLu authored
9 INSTALL
View
@@ -1,12 +1,17 @@
This requires mongodb, pymongo, and webpy to be installed.
mongodb - http://www.mongodb.org/downloads
-pymongo - http://api.mongodb.org/python/1.9%2B/index.html
-webpy - http://webpy.org/
+pymongo - http://api.mongodb.org/python/1.9%2B/index.html (or see below)
+webpy - http://webpy.org/ (or see below)
argparse - http://code.google.com/p/argparse/ - included in Python 2.7/3.2
simplejson - http://pypi.python.org/pypi/simplejson/
rpy2 - http://pypi.python.org/pypi/rpy2/
+Ubuntu Installation Commands for pymongo and webpy:
+sudo pip install pymongo
+sudo easy_install web.py
+
+
mkdir db
Run an instance of mongodb with mongod --dbpath=db
2  README.rst
View
@@ -8,7 +8,7 @@ Larry and rspeer.
The code depends on:
-- mongodb (http://www.mongodb.org)
+- mongodb (http://www.mongodb.org) (1.5.3+ or later)
- pymongo (http://api.mongodb.org/python/1.9%2B/index.html)
- web.py (http://webpy.org)
- argparse (included in Python 2.7/3.2)
1  game.py
View
@@ -214,6 +214,7 @@ def get_player_decks(self, sort_by_turn_order=False):
def all_player_names(self):
return [pd.name() for pd in self.player_decks]
+ #TODO: Nonfunctional?
def get_winning_score(self):
return self.winning_score
167 goals.py
View
@@ -7,20 +7,13 @@
import incremental_scanner
import name_merger
import utils
+import operator
# BOM: Bought only money and Victory.
# BOMMinator: Won buying only money and Victory.
# NegativeSum: Won with a negative score.
# Salted Earth: Had a negative score.
# PileDriver: Owned all copies of a card.
-# Protego: Reacted to all attacks against you (and at least 5).
-# OneTrickPony: Bought seven or more of one card and no other cards.
-# Peer: Scored 60 points.
-# Regent: Scored 70 points.
-# Royal Heir: Scored 80 points.
-# Monarch: Scored 90 points.
-# Imperial: Scored 100 points.
-# Archon: Scored 110 points.
# def CheckMatchGreenMonster(g):
# last_turn = g.Turns()[-1]
@@ -71,7 +64,8 @@ def CheckMatchBOMMinator(g):
})
return ret
-def CheckMatchNegativeSum(g):
+#("I thought it was Golf") Winning with a negative score
+def CheckMatchGolfer(g):
if g.any_resigned():
return []
ret = []
@@ -82,6 +76,7 @@ def CheckMatchNegativeSum(g):
player.Points())})
return ret
+
def CheckMatchPileDriver(g):
accumed_per_player = g.cards_accumalated_per_player()
ret = []
@@ -113,8 +108,149 @@ def CheckMatchOneTrickPony(g):
'reason': 'Bought no action other than %d %s' % (
quant, card_info.pluralize(action, quant))})
return ret
-
-
+
+
+# buy 5 differently named Victory cards
+def CheckMatchMrGreenGenes(g):
+ accumed_per_player = g.cards_accumalated_per_player()
+ ret = []
+ for player, card_dict in accumed_per_player.iteritems():
+ victory_quants = [(c, q) for c, q in card_dict.iteritems() if
+ card_info.is_victory(c)]
+ if len(victory_quants) >= 6:
+ ret.append({'player': player,
+ 'reason': 'Bought %d differently named Victory cards'%len(victory_quants)})
+ return ret
+
+def CheckScore(g, low, high=None):
+ ret = []
+ for player in g.get_player_decks():
+ score = player.points
+ if score >= low and (high is None or score < high):
+ ret.append({'player': player.name(), 'reason': "Scored more than %d points"%low})
+ return ret
+
+# Peer: Scored 60 points.
+# Regent: Scored 70 points.
+# Royal Heir: Scored 80 points.
+# Monarch: Scored 90 points.
+# Imperial: Scored 100 points.
+# Archon: Scored 110 points.
+
+def CheckMatchPeer(g):
+ return CheckScore(g, 60, 70)
+
+def CheckMatchRegent(g):
+ return CheckScore(g, 70, 80)
+
+def CheckMatchRoyalHeir(g):
+ return CheckScore(g, 80, 90)
+
+def CheckMatchMonarch(g):
+ return CheckScore(g, 90, 100)
+
+def CheckMatchImperial(g):
+ return CheckScore(g, 100, 110)
+
+def CheckMatchArchon(g):
+ return CheckScore(g, 110)
+
+#("Buzzer Beater") Winning by exactly one point
+def CheckMatchBuzzerBeater(g):
+ scores = {}
+ for player in g.get_player_decks():
+ score = player.points
+ scores[player.name()] = score
+ s_scores = sorted(scores.iteritems(), key=operator.itemgetter(1), reverse=True)
+ if len(s_scores)>1 and s_scores[0][1] == s_scores[1][1] + 1:
+ return [{'player': s_scores[0][0], 'reason': "Won by exactly one point"}]
+
+# Bought more than 10 green cards in a turn
+# won without ever buying money
+# played 20 actions in a turn
+# Protego: Reacted to all attacks against you (and at least 5).
+#("Penny Pincher") Winning by buying out the Coppers
+#("Estate Sale") Winning by buying out the Estates
+#("This card sucks?") Winning with an Opening Chancellor
+#("Bully") Play an attack every turn after the fourth.
+#("The Biggest Loser") Losing with over 60 points.
+#("Puppet Master") Play more than 4 Possession in one turn.
+#("Dominator") Have at least one of each type of available victory card (and at least 1 chip, if available).
+#buying at least one of every kingdom card in a game
+# gifted a Province or Colony to an opponent (through Masquerade or Ambassador),
+# Researcher: Acquire 7 Alchemists or Laboratories.
+# Evil Overlord: Acquire 7 or more Minions.
+# Badges? We Don't Need No Stinking Badges: Win a game while holding no VP Tokens and your opponent holds 25 or more.
+# It's Good to be the King: Acquire 4 Throne Rooms or King's Courts.
+# 99 Problems: Acquire the majority of Harems.
+# Crucio: Use the Torturer three times in a single turn.
+# Imperio: Use Possession three times in a single turn.
+# Game of Settlers Anyone?: Acquire 7 of a single Village-type card.
+
+def CheckPointsPerTurn(g, low, high=None):
+ ret = []
+ scores = []
+ players = g.all_player_names()
+ for state in g.game_state_iterator():
+ score = []
+ for p in players:
+ score.append(state.player_score(p))
+ scores.append(score)
+
+ for (i,p) in enumerate(players):
+ for turn_no in range(i, len(scores)-1, len(players)):
+ gain = scores[turn_no+1][i] - scores[turn_no][i]
+ if gain >= low and (high is None or gain < high):
+ ret.append({'player': p, 'reason': "Scored %d or more points in one turn"%low})
+ return ret
+
+#Slam: 20 or more points in one turn.
+#Crash: 30 or more points in one turn.
+#Charge: 40 or more points in one turn.
+#KO: 50 or more points in one turn.
+#Blitz: 60 or more points in one turn.
+#Onslaught: 70 or more points in one turn.
+def CheckMatchSlam(g):
+ return CheckPointsPerTurn(g, 20, 30)
+def CheckMatchCrash(g):
+ return CheckPointsPerTurn(g, 30, 40)
+def CheckMatchCharge(g):
+ return CheckPointsPerTurn(g, 40, 50)
+def CheckMatchKO(g):
+ return CheckPointsPerTurn(g, 50, 60)
+def CheckMatchBlitz(g):
+ return CheckPointsPerTurn(g, 60, 70)
+def CheckMatchOnslaught(g):
+ return CheckPointsPerTurn(g, 70)
+
+#Mega-Turn: you buy all the starting Provinces (or Colonies) in a single turn.
+def CheckMatchMegaTurn(g):
+ ret = []
+ scores = []
+ if 'Colony'in g.get_supply():
+ biggest_victory = 'Colony'
+ else:
+ biggest_victory = 'Province'
+
+ victory_copies = card_info.num_copies_per_game(biggest_victory, len(g.get_player_decks()))
+ for turn in g.get_turns():
+ new_cards = turn.buys + turn.gains
+ if len(new_cards) < victory_copies:
+ continue
+ if new_cards.count(biggest_victory)==victory_copies:
+ ret.append({'player': turn.player.name(), 'reason': "Obtained all of the %s cards in one turn"%biggest_victory})
+
+ return ret
+
+#("Oscar The Grouch") Trash more than 7 cards in one turn
+def CheckMatchOscarTheGrouch(g):
+ ret = []
+ for turn in g.get_turns():
+ trashes = len(turn.turn_dict.get('trashes',[]))
+ if trashes>=7:
+ ret.append({'player': turn.player.name(), 'reason': "Trashed %d cards in one turn"%trashes})
+ return ret
+
def MaybeRenderGoals(db, norm_target_player):
goal_matches = list(db.goals.find(
@@ -155,6 +291,10 @@ def MaybeRenderGoals(db, norm_target_player):
ret += '<div style="clear: both;">&nbsp;</div>'
return ret
+def print_totals(checker_output, total):
+ for goal_name, output in sorted(checker_output.iteritems(), key=lambda t: len(t[1]), reverse=True):
+ print "%-15s %8d %5.2f"%(goal_name, len(output), len(output)/float(total))
+
def main():
c = pymongo.Connection()
games_collection = c.test.games
@@ -184,6 +324,8 @@ def main():
scanner.get_num_games()
for g in utils.progress_meter(scanner.scan(games_collection, {})):
total_checked += 1
+# if total_checked % 1000==0:
+# print_totals(checker_output, total_checked)
game_val = game.Game(g)
for goal_name, goal_checker in goal_check_funcs:
output = goal_checker(game_val)
@@ -201,9 +343,8 @@ def main():
print 'ending with id', scanner.get_max_game_id(), 'and num games', \
scanner.get_num_games()
scanner.save()
+ print_totals(checker_output, total_checked)
- for goal_name, output in checker_output.iteritems():
- print goal_name, len(output)
if __name__ == '__main__':
main()
BIN  static/images/BuzzerBeater.jpg
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  static/images/Golfer.jpg
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  static/images/MegaTurn.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  static/images/OscarTheGrouch.jpg
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Please sign in to comment.
Something went wrong with that request. Please try again.