Tournament.resetGlobalVariables = function(){ Tournament.SELECTION = 5; Tournament.NUM_TURNS = 10; Tournament.INITIAL_AGENTS = [ {strategy:"tft", count:5}, {strategy:"all_d", count:5}, {strategy:"all_c", count:0}, {strategy:"grudge", count:0}, {strategy:"prober", count:0}, {strategy:"tf2t", count:5}, {strategy:"pavlov", count:5}, {strategy:"random", count:5} ]; publish("pd/defaultPayoffs"); PD.NOISE = 0; }; Tournament.resetGlobalVariables(); subscribe("rules/evolution",function(value){ Tournament.SELECTION = value; }); subscribe("rules/turns",function(value){ Tournament.NUM_TURNS = value; }); // OH THAT'S SO COOL. Mostly C: Pavlov wins, Mostly D: tit for two tats wins (with 5% mistake!) // ALSO, NOISE: tft vs all_d. no random: tft wins. low random: tf2t wins. high random: all_d wins. totally random: nobody wins ////////////////////////////////////////////// ////////////////////////////////////////////// // REGULAR LOAD Loader.addToManifest(Loader.manifest,{ tournament_peep: "assets/tournament/tournament_peep.json" }); function Tournament(config){ var self = this; self.id = config.id; // APP var app = new PIXI.Application(500, 500, {transparent:true, resolution:2}); self.dom = app.view; // DOM self.dom.className = "object"; self.dom.style.width = 500; self.dom.style.height = 500; //self.dom.classList.add("fader"); self.dom.style.left = config.x+"px"; self.dom.style.top = config.y+"px"; //self.dom.style.border = "1px solid rgba(0,0,0,0.2)"; var _convertCountToArray = function(countList){ var array = []; for(var i=0; i0) self.agents[0].kill(); // Convert to an array self.agents = _convertCountToArray(AGENTS); // Put 'em in a ring var count = 0; for(var i=0; i0) self.connections[0].kill(); // Connect all of 'em for(var i=0; i0) self.agents[_playIndex-1].dehighlightConnections(); if(_playIndex=1){ _tweenTimer = 0; self.STAGE = STAGE_REST; // slideshow.objects._b1.activate(); // activate NEXT button! } } }); // PLAY A TOURNAMENT self.deactivateAllButtons = function(){ // slideshow.objects._b1.deactivate(); // slideshow.objects._b2.deactivate(); // slideshow.objects._b3.deactivate(); }; self._startPlay = function(){ self.STAGE=STAGE_PLAY; // self.deactivateAllButtons(); }; listen(self, "tournament/play", self._startPlay); self._startEliminate = function(){ self.STAGE=STAGE_ELIMINATE; // self.deactivateAllButtons(); }; listen(self, "tournament/eliminate", self._startEliminate); self._startReproduce = function(){ self.STAGE=STAGE_REPRODUCE; // self.deactivateAllButtons(); }; listen(self, "tournament/reproduce", self._startReproduce); // Add... self.add = function(INSTANT){ return _add(self); }; // Remove... // TODO: KILL ALL LISTENERS, TOO. // TODO: Don't screw up when paused or looking at new tab self.remove = function(INSTANT){ _stopAutoPlay(); for(var i=0; i