Skip to content

Instantly share code, notes, and snippets.

View lifedispenser's full-sized avatar

Spencer Ying lifedispenser

View GitHub Profile
/**
* Copy paste in the console, then restart the game (space bar)
*
* Greedy Algorithm for : http://gabrielecirulli.github.io/2048/
* Plays the game using a naive greedy method. i.e. Local maximum
*
* Azaan
*
* ---
* Added Simple Heuristics to the algorithm. Tuning ftw! And... it won!
@lifedispenser
lifedispenser / setOps.js
Created July 29, 2016 18:58 — forked from jabney/setOps.js
Fast JavaScript set operations: union, intersection, difference, complement, and equals. Includes support for objects.
// setOps.js MIT License © 2014 James Abney http://github.com/jabney
// Set operations union, intersection, symmetric difference,
// relative complement, equals. Set operations are fast.
(function(so) {
'use strict';
var uidList = [], uid;
// Create and push the uid identity method.

Keybase proof

I hereby claim:

  • I am lifedispenser on github.
  • I am spencerying (https://keybase.io/spencerying) on keybase.
  • I have a public key ASBRaL8UT1adSppx2u2IWyKeDt6BeVIt-ylXIEBxbTsCrAo

To claim this, I am signing this object:

class Person extends IdyllModel
belongs_to :working_population
define_attribute :stress, type: integer, min: 0, max: 100, init: random
define_attribute :environment, type: enum, ['high income', 'low income', 'normal']
define_attribute :group, type: classification, |model| => { case model.stress; when 50..100: "high risk"; when 0..49: "low risk" }
def next_step
self.stress += 5 if self.environment == "high income"
self.stress -= 5 if self.environment == "low income"