This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const START_GAME_ID = 1580000; | |
const co = require('co'); | |
const wait = require('co-wait'); | |
const pg = require('pg'); | |
const cpg = require('co-pg')(pg); | |
let databaseUrl = process.env.DATABASE_URL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function binom(n,k) { | |
k = Math.min(k, n - k); | |
assert(k >= 0); | |
var r = 1; | |
for (var i = 0; i < k; ++i) | |
r = (r * (n - i)) / (i + 1); | |
return r; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Bit = I | O | |
deriving Show | |
type Bits = [Bit] | |
factorial :: Integer -> Integer | |
factorial 0 = 1 | |
factorial n = n * factorial (n-1) | |
binom :: Integer -> Integer -> Integer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH t AS | |
(SELECT | |
user_id, | |
(COALESCE(sum(cash_out - bet), 0::numeric) | |
+ COALESCE(sum(bonus), 0::numeric))::bigint AS gross_profit, | |
(COALESCE(sum(cash_out), 0::numeric) | |
+ COALESCE(sum(bonus), 0::numeric) | |
- COALESCE(sum(bet), 0::numeric))::bigint AS net_profit, | |
COUNT(*) AS games_played | |
FROM plays |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _ = require('lodash'); | |
var a = [0.2,0.1]; | |
var b = [10,30]; | |
var a0 = 1 - _.reduce(a, function(s, n) { return s + n; }); | |
function concave(x) { | |
var result = a0 * Math.log(1 - x); | |
for (var i = 0; i < a.length; ++i) | |
result += a[i] * Math.log(1 + b[i] * x); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var readline = require('readline'); | |
var fp = process.argv[2]; | |
var st = fs.createReadStream(fp, 'utf8'); | |
var rl = readline.createInterface({input: st}); | |
rl.on('line', function(line) { | |
var fields = line.split(','); | |
var id = parseInt(fields[0]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/gnuplot | |
reset | |
# set terminal png size 1280,600 | |
# set output "moneypot-houseedge.png" | |
set terminal svg enhanced size 1920 1080 | |
set output "moneypot-houseedge.svg" | |
set ylabel "house edge %" | |
set xlabel "cashout multiplier" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/gnuplot | |
reset | |
set terminal png size 1920,1200 | |
set output "moneypot-wagered.png" | |
set title "MoneyPot - Wagered and profit" | |
set xlabel "Time" | |
set xtics 2592000 # 30 days in seconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT vs.* FROM | |
GENERATE_SERIES(1e6::bigint, (SELECT max(id) FROM games)) vs | |
LEFT JOIN games ON vs = games.id | |
WHERE games.id IS null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/gnuplot | |
reset | |
set terminal png size 1920,1200 | |
set output "moneypot-profit.png" | |
set xlabel "Time" | |
set ylabel "Profit" | |
set title "MoneyPot - Profit" | |
set xtics 2592000 # 30 days in seconds |
NewerOlder