Tournament.resetGlobalVariables = function(){ Tournament.SELECTION = 5; Tournament.NUM_TURNS = 10; Tournament.INITIAL_AGENTS = [ {strategy:"tft", count:3}, {strategy:"all_d", count:3}, {strategy:"all_c", count:3}, {strategy:"grudge", count:3}, {strategy:"prober", count:3}, {strategy:"tf2t", count:3}, {strategy:"pavlov", count:3}, {strategy:"random", count:4} ]; Tournament.FLOWER_CONNECTIONS = false; 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", connection_flower: "assets/tournament/connection_flower.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.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 && _playIndex1 && _playIndex1) _tweenTimer=1; for(var i=0;i=1){ _tweenTimer = 0; self.STAGE = STAGE_REST; publish("tournament/step/completed", ["reproduce"]); } } }; app.ticker.add(_tick); // PLAY A TOURNAMENT self._startPlay = function(){ self.STAGE=STAGE_PLAY; }; listen(self, "tournament/play", self._startPlay); self._startEliminate = function(){ self.STAGE=STAGE_ELIMINATE; }; listen(self, "tournament/eliminate", self._startEliminate); self._startReproduce = function(){ self.STAGE=STAGE_REPRODUCE; }; listen(self, "tournament/reproduce", self._startReproduce); // Add... self.add = function(){ _add(self); }; // Remove... self.remove = function(){ _stopAutoPlay(); for(var i=0; i