This file contains hidden or 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
| class Doctor extends PlayerRole | |
| teamName: 'Doctor' | |
| advice: | |
| 'unless:hunt': -> | |
| # if the doctor chooses the same player | |
| # as the wolves choose to hunt | |
| # prevent the hunt method | |
| @choosePlayer() is @chooseInnocent() |
This file contains hidden or 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 Advice = function (type, advice) { | |
| this.type = type; | |
| this.advice = advice; | |
| }; | |
| Advice.adviseMethod = function (method, advice, combine) { | |
| if (typeof combine != 'function') { // TODO: don't use typeof | |
| combine = Advice.Types[combine] || Advice.Types.none; | |
| } |
This file contains hidden or 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
| // Chitchat Source | |
| // ----------------- | |
| // | |
| // ;;; OrderedSet | |
| // ;;; ---------- | |
| // ;;; | |
| // ;;; A Collection class that wraps an Array. | |
| // ;;; It maintains immutability, an order, and | |
| // ;;; does not contain duplicates | |
| // ;;; |
This file contains hidden or 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
| {Primitive} = require './primitive.coffee' | |
| {Symbol} = require './symbol.coffee' | |
| define = new Primitive (stx, env, evaluate) -> | |
| [place, expr] = stx | |
| throw new SyntaxError() unless place instanceof Symbol | |
| throw new Error("#{place.value} already defined") if env.contains(place.value) | |
| env.set place.value, evaluate(expr, env) |
This file contains hidden or 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
| ;;; OrderedSet | |
| ;;; ---------- | |
| ;;; | |
| ;;; A Collection class that wraps an Array. | |
| ;;; It maintains immutability, an order, and | |
| ;;; does not contain duplicates | |
| ;;; | |
| ;;; Items of the Ordered Set should implement 'Ord' | |
| (class OrderedSet | |
| (constructor (items, ordered, distinct) |
This file contains hidden or 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
| ### | |
| A Parser from A to B is a function that takes A and returns | |
| a Parsing Result where the 'value' is a Tree of B and the 'rest' | |
| is a B | |
| e.g. a Parser<String, Syntax> will consume a string and return a Parsing | |
| Result that contains a Tree of Syntax and a String of the Remainder to | |
| Parse. | |
This file contains hidden or 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 let | |
| for (let i = 0; i < children.length; ++i) { | |
| let (child = children[i]) | |
| setTimeout(function(){ doSomethingTo(child) }, 1000) | |
| } |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title> test </title> | |
| </head> | |
| <body> | |
| <canvas id="myCanvas" width="512" height="512" style="border:1px solid #c3c3c3;">Your browser is bad and you should feel bad (no canvas support)</canvas> |
This file contains hidden or 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 initParticles () { | |
| for (var i = 0; i < 10; i++) { | |
| particles.push(new particle()); | |
| particles[i].setValues( | |
| Math.random() * 50, // x | |
| Math.random() * 50, // u | |
| Math.random() * 10, // vx | |
| Math.random() * 10, // vy | |
| 1, // radius | |
| "#0000FF", // color |
This file contains hidden or 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
| // nuevo(Klass, [arg, ...]) is roughly the same as | |
| // new Klass(arg, ...) | |
| // | |
| // This should (hopefully) illustrate the relationship between | |
| // Object.create and 'new' | |
| // | |
| // new Constructor ties together | |
| // - creating an instance of the prototype | |
| // - initializing it | |
| // - possibly returning a totally different value |