Skip to content

Instantly share code, notes, and snippets.

View harold's full-sized avatar
:bowtie:

Harold harold

:bowtie:
View GitHub Profile
function post( o, f )
{
o.type = "web"
$.post("/req", o, f)
}
function updateeffort(e,o)
{
var x = e.pageX - o.offsetLeft;
var percent = Math.floor(100*(x/$(o).width()))
namespace MonsterBrain
type turnoption = Doms.TurnOption
type MonsterBrain() =
let calcCoeff (o:turnoption) =
let first = o.board.[0]
let last = o.board.[o.board.Count-1]
let mutable hasFirst = false
let mutable hasLast = false
@harold
harold / F# is the winner
Created October 30, 2011 02:03
First inter-language battle.
Using c extension for JSON.
Loaded games: [Domohnoes]
RECV 84 bytes from : {"command":"start_game","gametype":"com.danceliquid.domohnoes","nick":"RandomMatch"}
RECV 87 bytes from : {"gametype":"com.danceliquid.domohnoes","command":"start_game","nick":"F# Doms Player"}
### Turn #1 #########################
SEND 90 bytes to RandomMatch: {"command":"move","state":{"hand":[[0,1],[5,6],[0,4],[6,6],[1,2],[4,4],[1,1]],"board":[]}}
RECV 49 bytes from RandomMatch: {"command":"move","action":"play","domino":[1,1]}
### Turn #2 #########################
SEND 95 bytes to F# Doms Player: {"command":"move","state":{"hand":[[4,6],[0,2],[1,4],[0,5],[0,0],[3,4],[3,3]],"board":[[1,1]]}}
RECV 63 bytes from F# Doms Player: {"command":"move","action":"play","domino":[1,4],"edge":"back"}
@harold
harold / gist:1323855
Created October 28, 2011 23:41
--- server output ---
Using c extension for JSON.
Loaded games: [Domohnoes]
RECV 84 bytes from : {"command":"start_game","gametype":"com.danceliquid.domohnoes","nick":"RandomMatch"}
RECV 87 bytes from : {"gametype":"com.danceliquid.domohnoes","nick":"F# Doms Player","command":"start_game"}
### Turn #1 #########################
SEND 90 bytes to RandomMatch: {"command":"move","state":{"hand":[[0,0],[0,4],[3,3],[0,3],[4,6],[2,3],[1,6]],"board":[]}}
RECV 49 bytes from RandomMatch: {"command":"move","action":"play","domino":[0,3]}
Validating {:command=>"move", :action=>"play", :domino=>[0, 3]} for RandomMatch vs. RandomMatch @ []
Validating {:command=>"move", :action=>"play", :domino=>[0, 3]} for RandomMatch vs. RandomMatch @ []
### Turn #2 #########################
using System;
using System.Collections;
using System.Collections.Generic;
namespace Doms
{
public class Dom
{
public int l;
public int r;
@harold
harold / gist:1303000
Created October 21, 2011 02:56
Computers are fast
#include "stdafx.h"
#include "time.h"
#define d 5
int _tmain(int argc, _TCHAR* argv[])
{
time_t t = time(0);
int a[d*d], results[d*d+1];
for( int i=0; i<d*d; ++i ) a[i] = 0;
@harold
harold / gist:1301087
Created October 20, 2011 13:04
Histograms and timing for d=4 and d=5
d = 4
0: 16
2: 256
3: 512
4: 1472
5: 4608
6: 7936
7: 11264
8: 13408
9: 11264
@harold
harold / gist:1300340
Created October 20, 2011 03:21
Imperative code in functional languages is fun
let d = 4
let a = Array.create (d*d) 0
let results = System.Collections.Generic.Dictionary<int,int>()
for n=0 to (1<<<d*d)-1 do
// make a new a
for i=0 to d*d-1 do
if ((n &&& (1<<<i)) <> 0) then
a.[i] <- 1