iterated
This commit is contained in:
parent
1a17694633
commit
ec0f50f460
15 changed files with 164 additions and 94 deletions
|
@ -63,13 +63,29 @@
|
|||
"trimmed": false,
|
||||
"spriteSourceSize": {"x":0,"y":0,"w":502,"h":502},
|
||||
"sourceSize": {"w":502,"h":502}
|
||||
},
|
||||
"iterated_payoffs0008":
|
||||
{
|
||||
"frame": {"x":1034,"y":1034,"w":502,"h":502},
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": {"x":0,"y":0,"w":502,"h":502},
|
||||
"sourceSize": {"w":502,"h":502}
|
||||
},
|
||||
"iterated_payoffs0009":
|
||||
{
|
||||
"frame": {"x":10,"y":1546,"w":502,"h":502},
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": {"x":0,"y":0,"w":502,"h":502},
|
||||
"sourceSize": {"w":502,"h":502}
|
||||
}},
|
||||
"meta": {
|
||||
"app": "Adobe Animate",
|
||||
"version": "15.2.0.66",
|
||||
"image": "iterated_payoffs.png",
|
||||
"format": "RGBA8888",
|
||||
"size": {"w":2048,"h":2048},
|
||||
"size": {"w":2048,"h":4096},
|
||||
"scale": "1"
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 140 KiB After Width: | Height: | Size: 164 KiB |
|
@ -1,19 +0,0 @@
|
|||
{"frames": {
|
||||
|
||||
"iterated_scoreboard0000":
|
||||
{
|
||||
"frame": {"x":10,"y":10,"w":402,"h":202},
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": {"x":0,"y":0,"w":402,"h":202},
|
||||
"sourceSize": {"w":402,"h":202}
|
||||
}},
|
||||
"meta": {
|
||||
"app": "Adobe Animate",
|
||||
"version": "15.2.0.66",
|
||||
"image": "iterated_scoreboard.png",
|
||||
"format": "RGBA8888",
|
||||
"size": {"w":512,"h":512},
|
||||
"scale": "1"
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 4 KiB After Width: | Height: | Size: 3.1 KiB |
|
@ -59,17 +59,15 @@ body{
|
|||
top:-270px;
|
||||
|
||||
}
|
||||
#slideshow .object{
|
||||
.object{
|
||||
position: absolute;
|
||||
transition: left 0.5s ease-in-out, top 0.5s ease-in-out;
|
||||
}
|
||||
|
||||
/********* Fader *********/
|
||||
|
||||
.fader{
|
||||
-webkit-transition: opacity 0.3s ease-in-out;
|
||||
-mos-transition: opacity 0.3s ease-in-out;
|
||||
-ms-transition: opacity 0.3s ease-in-out;
|
||||
transition: opacity 0.3s ease-in-out;
|
||||
transition: opacity 0.5s ease-in-out;
|
||||
}
|
||||
|
||||
/******** Text Box ********/
|
||||
|
@ -293,6 +291,31 @@ body{
|
|||
z-index: 200;
|
||||
}
|
||||
|
||||
/*************************/
|
||||
/******* SCOREBOARD *******/
|
||||
/*************************/
|
||||
|
||||
#scoreboard{
|
||||
position: absolute;
|
||||
width:200px; height:100px;
|
||||
background: url(../assets/iterated/iterated_scoreboard.png);
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
#scoreboard > div{
|
||||
position: absolute;
|
||||
width: 60px; height: 60px;
|
||||
text-align: center;
|
||||
font-size: 50px;
|
||||
color: #666666;
|
||||
}
|
||||
#scoreboard > div:nth-child(1){
|
||||
left: 20px;
|
||||
top: 21px;
|
||||
}
|
||||
#scoreboard > div:nth-child(2){
|
||||
right: 15px;
|
||||
top: 21px;
|
||||
}
|
||||
|
||||
/*************************/
|
||||
/***** SLIDE SELECT ******/
|
||||
|
|
|
@ -18,14 +18,8 @@ function Background(config){
|
|||
self.dom.style.height = height+"px";
|
||||
self.dom.style.background = config.color;
|
||||
|
||||
// Add...
|
||||
self.add = function(INSTANT){
|
||||
return _addFade(self, INSTANT);
|
||||
};
|
||||
|
||||
// Remove...
|
||||
self.remove = function(INSTANT){
|
||||
return _removeFade(self, INSTANT);
|
||||
};
|
||||
// Add & Remove
|
||||
self.add = function(){ _add(self); };
|
||||
self.remove = function(){ _remove(self); };
|
||||
|
||||
}
|
|
@ -72,15 +72,8 @@ function Button(config){
|
|||
listen(self, self.id+"/deactivate", self.deactivate);
|
||||
}
|
||||
|
||||
// Add...
|
||||
self.add = function(INSTANT){
|
||||
return _addFade(self, INSTANT);
|
||||
};
|
||||
|
||||
// Remove...
|
||||
self.remove = function(INSTANT){
|
||||
unlisten(self);
|
||||
return _removeFade(self, INSTANT);
|
||||
};
|
||||
// Add & Remove
|
||||
self.add = function(){ _add(self); };
|
||||
self.remove = function(){ _remove(self); };
|
||||
|
||||
}
|
|
@ -14,14 +14,14 @@ function Slideshow(config){
|
|||
// Reset: INITIAL VARIABLES
|
||||
self.reset = function(){
|
||||
|
||||
// CLEAR
|
||||
if(self.clear) self.clear();
|
||||
|
||||
// On End?
|
||||
if(self.currentSlide && self.currentSlide.onend){
|
||||
self.currentSlide.onend(self);
|
||||
}
|
||||
|
||||
// CLEAR
|
||||
if(self.clear) self.clear();
|
||||
|
||||
// Reset
|
||||
self.dom.innerHTML = "";
|
||||
self.slideIndex = -1;
|
||||
|
@ -36,7 +36,7 @@ function Slideshow(config){
|
|||
//////////////////////////////////////////////////
|
||||
|
||||
// Go to next slide
|
||||
self.nextSlide = function(INSTANT){
|
||||
self.nextSlide = function(){
|
||||
|
||||
// On End?
|
||||
if(self.currentSlide && self.currentSlide.onend){
|
||||
|
@ -73,9 +73,7 @@ function Slideshow(config){
|
|||
self.objects = {};
|
||||
|
||||
// Add Object
|
||||
self.add = function(objectConfig, INSTANT){
|
||||
|
||||
INSTANT = true; // hack, sure.
|
||||
self.add = function(objectConfig){
|
||||
|
||||
// Create object
|
||||
var Classname = window[objectConfig.type];
|
||||
|
@ -87,29 +85,25 @@ function Slideshow(config){
|
|||
self.objects[objectConfig.id] = obj;
|
||||
|
||||
// Add it for real!
|
||||
return obj.add(INSTANT); // return a possible promise
|
||||
return obj.add();
|
||||
|
||||
};
|
||||
|
||||
// Remove Object
|
||||
self.remove = function(objectID, INSTANT){
|
||||
|
||||
INSTANT = true; // hack, sure.
|
||||
self.remove = function(objectID){
|
||||
|
||||
// Find it...
|
||||
var obj = self.objects[objectID];
|
||||
|
||||
// Remove from memory & DOM
|
||||
delete self.objects[objectID];
|
||||
return obj.remove(INSTANT); // return a possible promise
|
||||
return obj.remove();
|
||||
|
||||
};
|
||||
|
||||
// Clear: Remove ALL objects
|
||||
self.clear = function(INSTANT){
|
||||
for(var id in self.objects){
|
||||
self.remove(id, INSTANT);
|
||||
}
|
||||
self.clear = function(){
|
||||
for(var id in self.objects) self.remove(id);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -30,16 +30,10 @@ function TextBox(config){
|
|||
self.text_id = id;
|
||||
self.setText(Words.get(self.text_id));
|
||||
};
|
||||
self.setTextID(config.text_id);
|
||||
if(config.text_id) self.setTextID(config.text_id);
|
||||
|
||||
// Add...
|
||||
self.add = function(INSTANT){
|
||||
return _addFade(self, INSTANT);
|
||||
};
|
||||
|
||||
// Remove...
|
||||
self.remove = function(INSTANT){
|
||||
return _removeFade(self, INSTANT);
|
||||
};
|
||||
// Add & Remove
|
||||
self.add = function(){ _add(self); };
|
||||
self.remove = function(){ _remove(self); };
|
||||
|
||||
}
|
|
@ -135,7 +135,7 @@ function Iterated(config){
|
|||
self.dehighlightPayoff();
|
||||
|
||||
// End Round
|
||||
publish("iterated/round/end");
|
||||
publish("iterated/round/end", payoffs);
|
||||
|
||||
});
|
||||
|
||||
|
@ -166,19 +166,62 @@ function Iterated(config){
|
|||
///////////////////////////////////////////////
|
||||
|
||||
// Add...
|
||||
self.add = function(INSTANT){
|
||||
return _add(self);
|
||||
self.add = function(){
|
||||
_add(self);
|
||||
};
|
||||
|
||||
// Remove...
|
||||
self.remove = function(INSTANT){
|
||||
self.remove = function(){
|
||||
app.destroy();
|
||||
unlisten(self);
|
||||
return _remove(self);
|
||||
_remove(self);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
function IteratedScoreboard(config){
|
||||
|
||||
var self = this;
|
||||
self.config = config;
|
||||
|
||||
// DOM
|
||||
self.dom = document.createElement("div");
|
||||
self.dom.id = "scoreboard";
|
||||
self.dom.className = "object";
|
||||
self.dom.style.left = config.x+"px";
|
||||
self.dom.style.top = config.y+"px";
|
||||
|
||||
// Left score
|
||||
var left = document.createElement("div");
|
||||
self.dom.appendChild(left);
|
||||
|
||||
// Right score
|
||||
var right = document.createElement("div");
|
||||
self.dom.appendChild(right);
|
||||
|
||||
// Reset
|
||||
self.score = [0,0];
|
||||
self.reset = function(){
|
||||
self.score = [0,0];
|
||||
self.showScore();
|
||||
};
|
||||
self.addScore = function(a,b){
|
||||
self.score[0] += a;
|
||||
self.score[1] += b;
|
||||
self.showScore();
|
||||
};
|
||||
self.showScore = function(){
|
||||
left.innerHTML = self.score[0];
|
||||
right.innerHTML = self.score[1];
|
||||
};
|
||||
self.reset();
|
||||
|
||||
// Add & Remove
|
||||
self.add = function(){ _add(self); };
|
||||
self.remove = function(){ _remove(self); };
|
||||
|
||||
}
|
||||
|
||||
function IteratedPeep(config){
|
||||
|
||||
var self = this;
|
||||
|
|
|
@ -410,16 +410,16 @@ function SandboxUI(config){
|
|||
/////////////////////////////////////////
|
||||
|
||||
// Add...
|
||||
self.add = function(INSTANT){
|
||||
return _add(self);
|
||||
self.add = function(){
|
||||
_add(self);
|
||||
};
|
||||
|
||||
// Remove...
|
||||
self.remove = function(INSTANT){
|
||||
self.remove = function(){
|
||||
for(var i=0;i<numbers.length;i++) unlisten(numbers[i]);
|
||||
for(var i=0;i<sliders.length;i++) unlisten(sliders[i]);
|
||||
unlisten(self);
|
||||
return _remove(self);
|
||||
_remove(self);
|
||||
};
|
||||
|
||||
}
|
|
@ -101,14 +101,14 @@ function Splash(config){
|
|||
///////////////////////////////////////////////
|
||||
|
||||
// Add...
|
||||
self.add = function(INSTANT){
|
||||
return _add(self);
|
||||
self.add = function(){
|
||||
_add(self);
|
||||
};
|
||||
|
||||
// Remove...
|
||||
self.remove = function(INSTANT){
|
||||
self.remove = function(){
|
||||
app.destroy();
|
||||
return _remove(self);
|
||||
_remove(self);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -371,19 +371,17 @@ function Tournament(config){
|
|||
listen(self, "tournament/reproduce", self._startReproduce);
|
||||
|
||||
// Add...
|
||||
self.add = function(INSTANT){
|
||||
return _add(self);
|
||||
self.add = function(){
|
||||
_add(self);
|
||||
};
|
||||
|
||||
// Remove...
|
||||
// TODO: KILL ALL LISTENERS, TOO.
|
||||
// TODO: Don't screw up when paused or looking at new tab
|
||||
self.remove = function(INSTANT){
|
||||
self.remove = function(){
|
||||
_stopAutoPlay();
|
||||
for(var i=0; i<self.agents.length; i++) unlisten(self.agents[i]);
|
||||
unlisten(self);
|
||||
app.destroy();
|
||||
return _remove(self);
|
||||
_remove(self);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -5,17 +5,36 @@ SLIDES.push({
|
|||
onjump: function(self){
|
||||
|
||||
// Iterated Simulation
|
||||
self.add({id:"iterated", type:"Iterated", x:130, y:133});
|
||||
self.add({id:"iterated", type:"Iterated", x:130, y:183});
|
||||
self.objects.iterated.dehighlightPayoff();
|
||||
|
||||
},
|
||||
|
||||
onstart: function(self){
|
||||
|
||||
// Move it
|
||||
self.objects.iterated.dom.style.top = 183;
|
||||
|
||||
// Scoreboard!
|
||||
self.add({id:"scoreboard", type:"IteratedScoreboard", x:378, y:85});
|
||||
|
||||
// Extra info up top
|
||||
_.yourTotalScore = 0;
|
||||
self.add({
|
||||
id:"info", type:"TextBox",
|
||||
x:378, y:45, width:200, height:50, align:"center", size:15
|
||||
});
|
||||
var _showInfo = function(){
|
||||
var infoWords = Words.get("iterated_info_1")+ROUND_INDEX+"/"+ROUNDS.length;
|
||||
infoWords += "<br>";
|
||||
infoWords += Words.get("iterated_info_2")+_.yourTotalScore;
|
||||
self.objects.info.setText(infoWords);
|
||||
};
|
||||
|
||||
// ROUNDS
|
||||
var ROUNDS = [
|
||||
{id:"tft", num:5},
|
||||
//{id:"all_d", num:4},
|
||||
{id:"all_d", num:4},
|
||||
//{id:"all_c", num:4},
|
||||
//{id:"grudge", num:5},
|
||||
//{id:"prober", num:7}
|
||||
|
@ -24,13 +43,13 @@ SLIDES.push({
|
|||
ROUND_NUM = 0;
|
||||
|
||||
self.add({
|
||||
id:"buttonCheat", type:"Button", x:275, y:403, uppercase:true,
|
||||
id:"buttonCheat", type:"Button", x:275, y:453, uppercase:true,
|
||||
text_id:"label_cheat",
|
||||
message:"iterated/cheat"
|
||||
});
|
||||
|
||||
self.add({
|
||||
id:"buttonCooperate", type:"Button", x:495, y:400, uppercase:true,
|
||||
id:"buttonCooperate", type:"Button", x:495, y:450, uppercase:true,
|
||||
text_id:"label_cooperate",
|
||||
message:"iterated/cooperate"
|
||||
});
|
||||
|
@ -39,11 +58,16 @@ SLIDES.push({
|
|||
publish("buttonCheat/deactivate");
|
||||
publish("buttonCooperate/deactivate");
|
||||
});
|
||||
listen(self, "iterated/round/end", function(){
|
||||
listen(self, "iterated/round/end", function(payoffA, payoffB){
|
||||
|
||||
publish("buttonCheat/activate");
|
||||
publish("buttonCooperate/activate");
|
||||
|
||||
// Add score!
|
||||
self.objects.scoreboard.addScore(payoffA, payoffB);
|
||||
_.yourTotalScore += payoffA;
|
||||
_showInfo();
|
||||
|
||||
// Next round
|
||||
ROUND_NUM++;
|
||||
if(ROUND_NUM >= ROUNDS[ROUND_INDEX].num){
|
||||
|
@ -55,12 +79,16 @@ SLIDES.push({
|
|||
publish("slideshow/scratch"); // NEXT SLIDE, WHATEVER
|
||||
}else{
|
||||
publish("iterated/newOpponent",[ROUNDS[ROUND_INDEX].id]);
|
||||
self.objects.scoreboard.reset();
|
||||
_showInfo();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
_showInfo();
|
||||
|
||||
},
|
||||
|
||||
onend: function(self){
|
||||
|
|
|
@ -83,6 +83,12 @@ blah blah blah blah. But what if...
|
|||
<!-- - - - - - ITERATED - - - - - - - -->
|
||||
<!-- - - - - - - - - - - - - - - - - -->
|
||||
|
||||
<p id="iterated_info_1">
|
||||
opponent:
|
||||
</p>
|
||||
<p id="iterated_info_2">
|
||||
your total score:
|
||||
</p>
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - -->
|
||||
<!-- - - - - TOURNAMENT! - - - - - - -->
|
||||
|
|
Loading…
Reference in a new issue