Just realised I absolutely have to optimise the variable length function into something else; creating a new random variable every 200th move might be too expensive, or might not now that I think about it
variable length works
[from now] 2012/06/16 03:28:20

diff --git a/main.coffee b/main.coffee
index 2f2a2b0..7475b85 100644
--- a/main.coffee
+++ b/main.coffee
@@ -22,7 +22,7 @@ evolution = false
 ###
 variable_length = true
 message_corruption = false
-game_length = 100
+game_length = 50

 ###
     Logging
@@ -58,7 +58,7 @@ class Writer
       for ky, vl of d
         valz += ",#{vl}"
       valz += "\n"
-      @pen.write valz
+      @pen.write valz[1..valz.length]

 if round_robin
diff --git a/manager.coffee b/manager.coffee
index 51c126f..e7db72d 100644
--- a/manager.coffee
+++ b/manager.coffee
@@ -134,10 +134,13 @@ variablise = (length, typemap) ->
       (-1*(Math.log(Math.random())))*10
     when 'poisson'
       console.log "unimplemented"
+      length
     when 'cauchy'
       console.log "unimplemented"
+      length
     else
       console.log "incorrect specification! assuming small uniform :P"
+      ((Math.random() * length) - (length / 2)) / 3
[from now] 2012/06/16 03:33:24

diff --git a/main.coffee b/main.coffee
index 7475b85..a4e2e03 100644
--- a/main.coffee
+++ b/main.coffee
@@ -50,8 +50,8 @@ class Writer
       for ky, vl of d
         keyz += "#{ky},"
         valz += "#{vl},"
-      keyz += "\n" + valz + "\n"
-      @pen.write keyz
+      blobz = keyz[0..(keyz.length - 2)] + "\n" + valz[0..(valz.length - 2)] + "\n"
+      @pen.write blobz
       @first_write = false
     else
       valz = ""
Merge branch 'variable-length'
[from now] 2012/06/16 03:39:41

diff --git a/README.md b/README.md
index 5b2dd5a..2ad782c 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,3 @@
-Variable Length
-===============
-
-Distributions: exponential from N onwards - standard distribution N as mean, s as sigma -
-
-
-
-original readme follows:
-
 lesswrong-dilemma
 =================
[from now] 2012/06/16 04:00:40

diff --git a/game.coffee b/game.coffee
index 89f3600..3782250 100644
--- a/game.coffee
+++ b/game.coffee
@@ -30,11 +30,11 @@ class root.Game
           @gameinfo

   maybe_corrupt: (move, factor) =>
-    if (Math.random() > factor) then corrupt[move] else move
+    if (Math.random() > factor) then @corrupt[move] else move

   tick: =>
-    [p1m, p2m] = [maybe_corrupt(@player_one.move(@info 1), @message_corruption), maybe_corrupt(@player_two.move(@info 2), @message_corruption)]
-    @history = [maybe_corrupt(p1m, @information_corruption), maybe_corrupt(p2m, @information_corruption)]
+    [p1m, p2m] = [@maybe_corrupt(@player_one.move(@info 1), @message_corruption), @maybe_corrupt(@player_two.move(@info 2), @message_corruption)]
+    @history = [@maybe_corrupt(p1m, @information_corruption), @maybe_corrupt(p2m, @information_corruption)]
     @player_one_results += @payoffs[p1m][p2m]
     @player_two_results += @payoffs[p2m][p1m]
     @turn++
diff --git a/manager.coffee b/manager.coffee
index e7db72d..31c794d 100644
--- a/manager.coffee
+++ b/manager.coffee
@@ -76,10 +76,11 @@ root.natural_selection = (botlist, writer, game_length) ->
     for n in [1..numl]
       pool.push new bot

+
   # now iterate!
   while generations > 0
     # shuffle the pool
-    pool.sort( -> 0.5 - Math.random())
+    pool = shuffle(pool)

     # run this generation
     records = []
@@ -142,6 +143,14 @@ variablise = (length, typemap) ->
       console.log "incorrect specification! assuming small uniform :P"
       ((Math.random() * length) - (length / 2)) / 3

+shuffle = (arr) ->
+  # Fisher Yates Knuth Durstenfeld
+  i = arr.length
+  while --i
+    j = Math.floor(Math.random() * (i+1))
+    [arr[i], arr[j]] = [arr[j], arr[i]]
+  arr
+
Fisher Yates, variable length now returns integer...