Skip to content

Instantly share code, notes, and snippets.

@bonnici
bonnici / fair-and-square.ts
Created May 29, 2013 01:03
Code Jam 2013 qualification round files
///<reference path='app.d.ts' />
import fs = module("fs")
import _ = module("underscore")
import winston = module("winston")
import async = module("async")
var s = require('string');
// Usage: node appname input-file [output-file] [test]
@bonnici
bonnici / ZombieBot_QaDBFRvR.py
Created December 2, 2012 01:05
Quick-and-Dirty Brute Force Risk vs Reward bot
# Quick-and-Dirty Brute Force Risk vs Reward bot
# Before each roll (except the first), do a brute force calculation of risk vs reward. In this case,
# risk is the probability of having 3 shotgun dice after the roll, and reward is the probability of
# getting an extra 1, 2, or 3 brains. If P(death) - rewardBonus[1]*P(1 brain) -
# rewardBonus[2]*P(2 brain) - rewardBonus[3]*P(3 brain) > rvrCutoff, then roll.
# If behindBonus and/or aheadPenalty are not zero, then those amounts are added to or subtracted from
# the risk vs reward depending on weather the bot is winning or losing, encouraging risky play when
# behind and safer play when ahead
@bonnici
bonnici / dateutils.ts
Created November 25, 2012 23:01
Util class for formatting dates in specific timezones (TypeScript)
/// <reference path="./node-definitions/moment.d.ts" />
/// <reference path="./node-definitions/timezone-js.d.ts" />
import moment = module("moment")
import tzjs = module("timezone-js")
import fs = module('fs');
export function init() {
tzjs.timezone.zoneFileBasePath = './tz';
tzjs.timezone.loadingScheme = tzjs.timezone.loadingSchemes.PRELOAD_ALL;
@bonnici
bonnici / timezone-js.d.ts
Created November 25, 2012 22:33
TimezoneJs node definition (WIP)
declare module "timezone-js" {
export var timezone : TimezoneJs;
export var Date: {
new (timezone?: string): TimezoneJsDate;
new (time: string, timezone?: string): TimezoneJsDate;
new (year?: number, month?: number, day?: number, hour?: number, minute?: number, second?: string, timezone?: string): TimezoneJsDate;
};
}