Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created February 11, 2014 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/8933530 to your computer and use it in GitHub Desktop.
Save zeffii/8933530 to your computer and use it in GitHub Desktop.
coffee_templatefux_wide
{"description":"coffee_templatefux_wide","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"data2.csv":{"default":true,"vim":false,"emacs":false,"fontSize":12},"util.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"injet.coffee":{"default":true,"vim":false,"emacs":false,"fontSize":12},"inlet.coffee":{"default":true,"vim":false,"emacs":false,"fontSize":12},"utils.coffee":{"default":true,"vim":false,"emacs":false,"fontSize":12},"details.ssv":{"default":true,"vim":false,"emacs":false,"fontSize":12},"details.txt":{"default":true,"vim":false,"emacs":false,"fontSize":12},"details.tsv":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/rUN41qB.png"}
svg = d3.select("svg")
svg.append("rect").attr({width:"100%", height:"100%", fill: '#E2E2E2'})
# roulette genetic selection, based on larger chance of selection
# if fitness is large.
# get size of population
# calc their propbability from fitness
# generate a weighted index picker function that favours indices
# towards the higher end,
# these indices are remapped to population indices
# in this example I prefer to pick index length-1, but should
# expect fluctuation and not be suprised of infrequently picking
# chromosomes which are much less suitable.
population = [11,11,11,11,22,22,22,33,33,33,33,44,55,55,55,66,66,77]
console.log('----', population.length)
tb1 = []
for i in [0..290]
pick = 1-Math.random()
pick *= pick # turns it into a crve
pick *= pick # sharpens the slope
pick *= population.length # adjusts for range
largest = Math.floor pick
console.log(largest)
tb1.push(largest)
# console.log(largest)
g1 = svg.append("g").classed "brim1", true
g1.attr
transform: "translate(" + [30,60] + ")"
g1.selectAll("circle").data(tb1).enter()
.append("circle")
.attr
r:28
transform: (d,i) -> "translate(" + [i*2,d*22.8] + ")"
.style
stroke: "none"
'stroke-opacity': 0.2
'fill-opacity': 0.1
.cm-s-elegant.CodeMirror { background: #1e2426; color: #696969; }
.cm-s-elegant div.CodeMirror-selected {background: #064968 !important;} /* 33322B*/
.cm-s-elegant span.cm-variable { color:#22EFFF; }
.cm-s-elegant span.cm-variable-2 { color: #FFCCB4; }
.cm-s-elegant span.cm-variable-3 { color: white; }
.cm-s-elegant span.cm-string { color: Chartreuse; }
.cm-s-elegant span.cm-string-2 {color: Chartreuse;}
.cm-s-elegant span.cm-def {color: #FFCCB4; opacity: 1.0}
.cm-s-elegant span.cm-bracket { color: #EBEFE7; }
.cm-s-elegant pre { color:#FFF; }
.cm-s-elegant span.cm-qualifier { color:#C0C0C0; }
.cm-s-elegant span.cm-comment { color: #AFB4B4;}
.cm-s-elegant span.cm-property {color: #FDA676;}
.cm-s-elegant span.cm-number { color: #FF92EE;}
.cm-s-elegant span.cm-keyword { color: #FFFF18; }
.cm-s-elegant .CodeMirror-cursor { border-left: 1px solid white !important; }
.cm-s-elegant .CodeMirror-gutters {background: #505050;}
.cm-s-elegant .CodeMirror-linenumber {color: #D3D3D3;}
#panel{
width: 550px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment