The code behind councilroom.com.
Pull request Compare This branch is 34 commits behind rrenaud:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
card_info
card_ranker
images
oneoff
site_demo
static
testing
trueskill
www-redirect
.gitignore
INSTALL
README.rst
analysis_util.py
analyze.py
analyze2.py
annotate_game.py
buy_template.html
card_filter_blurb.html
check_game.py
check_some_goals.py
client.css
conf.ini.template
count_buys.py
count_plays.py
favicon.ico
frontend.py
frontend_local.py
frontend_wsgi.py
game.py
game_state_features.py
goal_image_check.py
goal_stats.py
goals.py
ideas
incremental_scanner.py
index.html
load_leaderboard.py
load_parsed_data.py
mergeable.py
mongo_queries.txt
name_merger.py
openings_template.html
optimal_card_ratios.py
optimal_card_ratios_table_template.html
optimal_card_ratios_template.html
parse_game.py
player_page_leaderboard_history_template.html
primitive_util.py
queries.py
query_matcher.py
record_summary.py
rf_predict.py
robots.txt
run_trueskill.py
scrape.py
scrape_leaderboard.py
search_query.html
small_gain_stat.py
sofia_predict.py
stats.py
supply_win.html
test_count_buys.py
test_game.py
test_incremental_analyze.py
test_mergeable.py
test_parse_game.py
test_primitive_util.py
test_stats.py
update_loop.py
utils.py
win_graph_template.html

README.rst

dominionstats

This is the code behind http://councilroom.com. Feel free to fork it to make it do interesting new things.

The project is run by rrenaud (rrenaud@gmail.com), with contributions so far by Larry, rspeer, David Lu, and tlstyer.

Installation

Turbo frontend javascript hacking

super easy frontend modifications without any server setup:

checkout code from github.
google-chrome --allow-file-access-from-files
browse to local html pages (eg, dominionstats/supply_win.html).
edit local javascript files.

I just want access to some data!

Send (rrenaud@gmail.com) a mail and I'll see what I can do.

Long, ardous but incredibly rewarding full setup

The code depends on:

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

After install those packages, the system can be setup by running the update_loop.py script, which will take a few hours to download one months of games logs from councilroom, and then parse through it all and load it into a database:

python update_loop.py

And after that is down, this starts webserver running on localhost:8080:

python frontend_local.py

Hacking Guidelines

Python code:
  • Write it in pep8, even if I didn't all the time.

  • Wrap lines at 80 characters.

  • Try not to write super long functions, break them up into logical subfunction even if those functions are only called once.

  • Did you see something in the code is fugly and offends your natural sense of what is good in the world? I'll happily take style cleanups.

  • Anatomy of an analysis.
    • Want analysis to be incremental, can go day at a time.
      • Use an incremental_scanner.
      • Prefer using game.Game objects over raw game docs from the database. game.Game objects are easier to work with, and make maintence easier.
      • Since we want to be incremental, store raw counts in database, normalize them with divisions, etc at presentation time.
      • Want to keep track of a random variable that has some kind of spread? Use a stats.MeanVarStat.
      • Consider using primitive_util for serializing/deserializing objects that store the aggregate information.
  • How to do display?
    • Lots of existing server side templating in Python.
    • Prefer templates to programatically building up strings (even if if the existing code doesn't always).
    • Seriously consider outputting JSON from server like (/supply_win_api) and doing presententation in javascript (/supply_win), since it allows frontend development without running the whole system.
Javascript code:
  • Keep non-trivial bits of Javascript in seperate .js files rather than embedded in HTML. It makes my emacs happier.

Got a technical problem/question/idea? You can send an email to the dev group,

https://groups.google.com/forum/?fromgroups#!forum/councilroom-dev

Happy hacking.