diff --git a/README.md b/README.md index 6f73380..c591992 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ *The Evolution of Trust* is dedicated to the public domain, and is made thanks to the many Creative Commons & open source resources out there! Here is a full list of music, sounds, and code used: -**Music:** "Bleu" by Komiku (CC Zero). Download their full album on [Free Music Archive](http://freemusicarchive.org/music/Komiku/Its_time_for_adventure_/) +**Music:** "Bleu" by Komiku (CC Zero). [Download their full album on Free Music Archive](http://freemusicarchive.org/music/Komiku/Its_time_for_adventure_/) **Sound Effects:** diff --git a/en/index.html b/en/index.html new file mode 100644 index 0000000..2d19c3c --- /dev/null +++ b/en/index.html @@ -0,0 +1,107 @@ + + +
+ + +This interactive guide is heavily based off Robert Axelrod's groundbreaking 1984 book, The Evolution of Cooperation! I was also heavily inspired by his 1997 sequel, The Complexity of Cooperation, and Robert Putnam's 2000 book on America's declining "social capital", Bowling Alone.
+ +yes i'm a bookworm nerd, plz don't bully me
+ +To see a thorough statistical take on this, check out Our World In Data. Mmmm stats
+ +This game is also known in game theory as the infamous Prisoner's Dilemma. The Prisoner's Dilemma is named after a story where two suspects can either squeal on their partner-in-crime ("cheat"), or stay silent ("cooperate"). I chose not to do this story because 1) in this case, both players "cooperating" would be bad for society, and 2) it's unrealistic, everyone knows that snitches get stitches
+ +In the repeated game of trust (also known as Iterated Prisoner's Dilemma), it's important that neither player knows when the last round is. Why? Think about it - on the last round, both players would know their action has no consequence, so they'd both cheat. But that means in the second-last round, their actions can't change the next round, so they'd also both cheat. But that means in the third-last round... etc etc.
+ +This strategy is better known in game theory as Tit For Tat. It was created by Anatol Rapoport in 1980, for Robert Axelrod's game theory tournament. I chose not to use the name "Tit For Tat" because 1) it sounds mean, although it's a nice & fair strategy, and 2) a lot of the public have already heard about Tit For Tat, so if I used that name, players might just place their bets on this character because they've already heard of "Tit For Tat".
+ +There was another guy who was skeptical, too. During the truce, a German corporal remarked with disgust, "Such a thing should not happen in wartime. Have you no German sense of honor?"
+ +That man was Adolf Hitler.
+ +You can't make this sh*t up.
+ +There's a new, super-young interdisciplinary field that I'm really excited by, called Cultural Evolution. Admittedly, it's a bad name, not least because it sounds uncomfortably close to "Social Darwinism". Which it's not. Pinky promise.
+ +One core part of Cultural Evolution Theory is culture evolves the same way life does: through variation & selection. Variation: people differ in beliefs & behaviors, and invent new ones almost every day. Selection: people try to imitate their heroes & elders, and adopt their beliefs/behaviors.
+ +(Note: this is not quite Richard Dawkin's "meme" theory. "Meme" implies, that, like genes, ideas come in discrete chunks & replicate with high fidelity. This is obviously untrue. Also you can't say "meme" with a straight face these days, so whatever)
+ +The reason why I think Cultural Evolution is so promising, is that it could integrate all the human sciences: psychology, sociology, economics, anthropology, political science, neuroscience, biology. The greatest problems of our time do not obey conventional academic boundaries -- so, it's about dang time we created a common language between the sciences and humanities.
+ +If you want to learn more about Cultural Evolution Theory, I highly recommend Joseph Heinlich's 2015 book, The Secret of Our Success!
+ +You may have heard that someone found a player strategy that can "exploit evolution". From the Scientific American: "[Press & Dyson's results] suggested the best strategies were selfish ones that led to extortion, not cooperation."
+ +Press & Dyson's findings are really important, but Scientific American confused two different uses of the word "evolutionary". The first use, the way this interactive guide used it, was to mean that the tournament's population changes over time. The second use, the way P&D meant it, was that the player's rules changes over time. For example: Detective is "evolutionary" since it changes its own rules, while Copycat is not "evolutionary" since it sticks to its principles.
+ +So, P&D found strategies that could exploit "evolutionary" players like Detective, but their strategies still could not exploit the evolution of the tournament, because in the long run, fair & nice strategies still win.
+ +Seriously, go read Robert Putnam's 2000 book, Bowling Alone. Yeah it's a bit outdated by now, 17 years later, but its core findings and lessons are still true as ever -- probably even more so.
+ +This is kinda cheesy, but I still adore the 1989 book, The Seven Habits of Highly Effective People -- especially Habit #4: Think Win-Win.
+ +Because, contrary to popular belief, coming up with Win-Win solutions is hard, takes lots of effort, and is emotionally painful. Heck, I'd go even further – I'd say our culture's default stance of Win-Lose "us versus them" is the easy path, the lazy path, the equivalent of activism junk food.
+ +Anyway. Exaggerations aside, I strongly believe "Win-Win" / "Non-Zero-Sum" is something we all urgently need -- in our personal lives, social lives, and definitely political lives.
+ +Just like how Copycat's original name was Tit For Tat, Copykitten's original name is Tit For Two Tats. Same rule: Cooperate, unless the other players cheats twice in a row.
+ +There's another forgiving variant of Tit For Tat called Generous Tit For Tat. It's got a similar but slightly different rule: Cooperate, but when the other player cheats, forgive them with a X% chance. This design, with the variable "X", lets you set different "forgiveness" levels for the player.
+ +Also known as Pavlov, or Win-Shift-Lose-Stay.
+ +I'm only in my twenties, I don't know why I always sound like an old grump shaking my fist at a cloud. But, yeah, anyway, go read Neil Postman's 1985 book, Amusing Ourselves To Death. It's about how the communications technology we use subtly shapes our culture ("the medium is the message") and how technology that is biased towards quick & fast information (TV in 1985, social media now) turns us all into trivial, short-term thinkers.
+ +Although I don't agree with everything in his book, it's a real eye-opener, and surprisingly prescient for 1985. His rant against Sesame Street is kinda weird, though.
+ +Giving advice can come off as condescending, so let me be perfectly honest: I do not have any of this figured out, personally. I'm bad at developing friendships, especially with people of different political views than me. I occasionally forget about win-wins, and lapse into "us versus them" thinking. And judging by this rambling, I'm also still terrible at communicating clearly.
+ +But I want to get better. This stuff is hard. Building peace & trust in the world, from the bottom up, is hard.
+ +And that's why it's worth it. <3
+ + ++ “The Evolution of Trust” was created thanks to the generosity + of my supporters on Patreon! + Speaking of whom, here they are. THE COOLEST PEEPS: +
++ and a special thanks to my friends who let me pester them to do playtests... +
++The Evolution of Trust +
++an interactive guide to the game theory of why & how we trust each other +
++loading... +
++ON +
++OFF +
+ + + + + + +
+THE
+EVOLUTION
+OF TRUST
+
+playing time: 30 min • by nicky case, july 2017 +
+ ++loading... +
++PLAY → +
+ + + + + + + + +
+During World War I, peace broke out.
+
+
+It was Christmas 1914 on the Western Front.
+Despite strict orders not to chillax with the enemy, British
+and German soldiers left their trenches, crossed No Man's Land,
+and gathered to bury their dead, exchange gifts, and play games.
+
+
+Meanwhile: it's 2017, the West has been at peace for decades, and
+wow, we suck at trust. Surveys show that, over the past forty years,
+fewer and fewer people say they trust each other. So here's our puzzle:
+
+
+Why, even in peacetime, do friends become enemies?
+And why, even in wartime, do enemies become friends?
+
+
+I think game theory can help explain our epidemic of distrust –
+and how we can fix it! So, to understand all this...
+
+you
cooperate
+
+you
cheat
+
+they
cooperate
+
+they
cheat
+
+you
↙
+
+other player
↘
+
+
+THE GAME OF TRUST
+
+You have one choice.
+In front of you is a machine: if you put a coin in the machine,
+the other player gets three coins – and vice versa.
+You both can either choose to COOPERATE (put in coin), or CHEAT (don't put in coin).
+
+Let's say the other player cheats, and doesn't put in a coin.
+What should you do?
+
+Exactly! Why let that moocher mooch off of you? +
+ ++Alas, turning the other cheek just gets you slapped! +
+ ++If you cooperate & they cheat, you lose a coin while they gain three. (score: -1 vs +3) +However, if you both cheat, neither of you gain or lose anything. (score: 0 vs 0) +Therefore: you should CHEAT. +
+ +
+But let's say the other player cooperates, and puts in a coin.
+What should you do now?
+
+Wow, that's mean... and also the correct answer! +
+ ++Sure, seems like the right thing to do... OR IS IT?? +
+ ++Because if you both cooperate, you both give up a coin to gain three. (score: +2 vs +2) +But if you cheat & they cooperate, you gain three coins at their cost of one. (score: +3 vs -1) +Therefore: you "should" still CHEAT. +
+ ++And that's our dilemma. +Trust is nice, but it can let others take advantage of you -- or shoot you as you come unarmed out of a trench. +Sometimes, distrust is rational! +But now, what happens if we play this game... +
+ + + + + + + ++Now, let's play for real. +You'll be playing against 5 different opponents, each with their own game "strategy". +With each opponent, you'll play anywhere between 3 to 7 rounds. +(You won't know in advance when the last round is) +Can you trust them? Or rather... can they trust you? +
+ ++Pick your first, real move. Choose wisely. +
+ ++opponent: [X] of [Y] +
+ ++your total score: +
+ ++And your total score is... +
++which is, wow, actually impressively bad. +
++which, uh, could be worse! +
++which ain't bad! +
++which is pretty good! +
++which is perfect! Congrats you have too much time on your hands. +
++...i have no idea how you did that. +
++(the lowest & highest possible scores are 8 and 49, respectively) +
+ ++So who were these strange characters you just played against? +
+ ++COPYCAT: +Hello! I start with Cooperate, and afterwards, I just copy whatever you did in the last round. Meow +
+ ++ALWAYS CHEAT: +the strong shall eat the weak +
+ ++ALWAYS COOPERATE: +Let's be best friends! <3 +
+ ++GRUDGER: +Listen, pardner. I'll start cooperatin', and keep cooperation', +but if y'all ever cheat me, I'LL CHEAT YOU BACK 'TIL THE END OF TARNATION. +
+ ++DETECTIVE: +First: I analyze you. I start: Cooperate, Cheat, Cooperate, Cooperate. +If you cheat back, I'll act like Copycat. +If you never cheat back, I'll act like Always Cheat, to exploit you. +Elementary, my dear Watson. +
+ + + + + + + + + +
+It's tournament time!
+Each character will now play against every other character:
+that's 10 paired matches, and 10 rounds per match.
+
+Who do you think will get the highest total score?
+Think carefully about it... and then
+PLACE YOUR BETS:
+
+Alright, you placed your bet on [CHAR]! +Let's go through the matches one by one, and see how the tournament plays out... +
+ ++first match → +
+ ++next match → +
+ ++Match #[N]: [A] vs [B] +
++Rounds: +
++Total Scores: [A] vs [B] +
+ ++Oh, by the way... +
++...You may be skeptical about that Christmas Truce story about the World War I trenches. +Surely that was just a fluke? +
++Yes, the truce was dramatic, but it was neither unique, nor unusual. +
++Not every trench joined in the peace, but it was pretty widespread. +Many front-lines came up with the idea independently, and again: despite specific, strict orders not to. +
++And in fact, even before Christmas, several front-lines already had +established an unofficial, secret peace. +
++They called it: the "live and let live" system. +Basically, you don't shoot me, I don't shoot you. And this worked, in a lot of places! +
++You may still be skeptical. Most soldiers don't spontaneously form peace with the enemy. +What's so special about trench warfare? +
++Well, here's what's unique about the trenches: +unlike almost every other form of war, +you have to face the same specific soldiers every day. +
++It's a repeated game. And that makes all the difference. +
++Anyway. And the winner is... +
+ ++(drumroll please...) → +
+ ++COPYCAT! +
++Congrats, you placed your bet on the right horse. +
++(Apologies to your bet, [CHAR].) +
+
+Copycat goes by many names.
+The Golden Rule, reciprocal altruism, tit for tat, or... live and let live.
+That's why "peace" could emerge in the trenches of World War I:
+when you're forced to play the same game with the
+same specific people (not just the same generic "enemy") over and over again --
+Copycat doesn't just win the battle, it wins the war.
+
+But if things change a lot when you play multiple rounds of the same game, what if we play...
+
+Now, let's let our population of players evolve over time. It's a 3-step dance: +
+
+1. PLAY A TOURNAMENT
+Let them all play against each other, and tally up their scores.
+
+2. ELIMINATE LOSERS
+Get rid of the 5 worst players. (if there's a tie, pick randomly between them)
+
+3. REPRODUCE WINNERS
+Clone the 5 best players. (if there's a tie, pick randomly between them)
+
+Say we start with the following population of players:
+15 Always Cooperates,
+5 Always Cheats, and
+5 Copycats.
+(We'll ignore Grudger & Detective for now)
+
+We're going to do the tournament-eliminate-reproduce dance a dozen times or so.
+Let's make another bet! Who do you think will win the first tournament?
+PLACE YOUR BETS, AGAIN:
+
+Makes sense, Always Cooperate outnumbers everyone else right now... +
++Makes sense, Always Cheat has a lot of Always Cooperates to exploit... +
++Makes sense, Copycat won the tournament last time, why not again?... +
++Let's see if you're correct: +
+ ++1) play tournament +
++2) eliminate bottom 5 +
++3) reproduce top 5 +
+ ++Alas, Always Cooperate got eaten up by +Always Cheat, whose numbers have now increased by 5. +
++Sadly, you were correct! The Always Cheaters won this time, +and their numbers increased by 5. +
++Alas, Copycat did not win – but at least they didn't do as bad +as Always Cooperate. They got eaten up by Always Cheat, +whose numbers have now increased by 5. +
++But let's try a few more rounds of this... +
+ ++Always Cheat is still growing, +at the expense of Always Cooperate... +
+ ++And now, all the Always Cooperates are dead. +But, wait... +
+ ++That's right: the Always Cheats became a victim of their own success! +They exploited the naive Always Cooperators, +but once they ran out of them, they had to face the Copycats: +who are nice, but not naive. +
+ + + ++By simply copying the other player's moves, +Copycats can play nice with each other, +while Always Cheats just cheat themselves! +Not only that, but it also means Copycat +can give Always Cheat +a taste of their own medicine. +
+ ++And so, as a result... +
+ ++...Copycat inherits the earth. +
++So, although your bet was off -- the nice-but-naive Always Cooperators +were doomed from the start -- in the end, a smart form of niceness prevailed, +and the Always Cheaters were squashed. +
++So, in the short run you were right - Always Cheat won the first few rounds, +but in the end, its exploitativeness was its downfall. +
++So, in the long run, you were right - Copycat wins! +Always Cheat may have won in the short run, +but its exploitativeness was its downfall. +
+
+This reminds me of a quote:
+
+"We are punished by our sins, not for them."
+~ Elbert Hubbard
+
+(oh, and by the way...) +
+ ++(...this result is similar even if we put +Grudger & Detective back in:) +
+ ++start the evolution process! +
++stop the evolution process +
+ +
+(Note: sometimes, a few Grudgers may stick around,
+because when all players except Grudger & Copycat
+are eliminated, the two tie.)
+
+So, it seems the math of game theory is telling us something:
+that Copycat's philosophy,
+"Do unto others as you would have them do unto you", may be not just a
+moral truth, but also a mathematical truth.
+However...
+
+...there's a problem: → +
+ +
+Look around. The world's full of total jerkwads.
+
+If Copycat is the strategy in this repeated game of trust that's so powerful --
+that even soldiers in World War I trenches independently "evolved" a similar strategy, called "live and let live" --
+why, then, are there so many un-trusting, un-trustworthy people?
+What's causing our epidemic of un-trust?
+
+A clue's in that sentence itself. "In this repeated game of trust."
+So far we've only talked about change in the players:
+what about a change in the game?
+What could lead to...
+
+...the evolution of distrust? +
+ + + + + +
+Before everything goes to heck, let's start with something nice!
+Here's a world filled entirely with Always Cooperates,
+except for one Always Cheat and one Copycat.
+
+Use the buttons on the right to START the sim,
+go through it step-by-step, or reset it. →
+
+As you already know, Copycat wins handily in the long run,
+under our current rules!
+
+But that's under our current rules, which say that
+players play against each other for 10 rounds per match.
+Does Copycat still win at 7 rounds? 5 rounds? 3? 2? 1?
+
+Change the number of rounds with the slider below,
+then START the sim, and see what happens.
+Feel free to experiment!
+
+once you're done playing around, click: +
+ +
+As you saw, if you don't play enough rounds, (here: 5 or less)
+ALWAYS CHEAT dominates.
+
+In 1985, when Americans were asked how many close friends they had,
+the most common answer was "three". In 2004, the most common answer was "zero".
+We now have fewer friends across class, racial, economic, and political lines,
+because we have fewer friends -- period.
+And as you just discovered for yourself,
+the fewer "repeat interactions" there are, the more distrust will spread.
+
+(no, mass media doesn't count:
+it must be two-way interactions between specific individuals.)
+
+and oh, it gets worse... → +
+ ++There's another way to breed distrust. +Here are the "payoffs" for the trust game: +
++With the normal payoffs, Copycat wins. +But now, change the "both cooperate" reward from +2 to +1, +then click START. +Even though +1 is still more than the punishment for both cheating (0)... +what happens? +
++feel free to play around with different payoffs! +once you're done, click: +
++(simulating: 10 rounds per match) +
+ +
+The same thing happens:
+with a lower "win-win" reward, Always Cheat takes over.
+Game theory has two powerful ideas about this:
+
+"Zero-sum game". This is the sadly common belief that a gain for "us"
+must come at a loss to "them", and vice versa.
+
+"Non-zero-sum game". This is when people make the hard effort
+to create a win-win solution! (or at least, avoid a lose-lose)
+Without the non-zero-sum game, trust cannot evolve.
+
+Speaking of which,
+let's now look at our third & final barrier to the evolution of trust...
+
+Misteaks Mistakes. →
+
+As cool as Copycat is, it has a huge, fatal weakness I haven't mentioned yet. +To understand the problem, let's say two Copycats are playing against each other: +
++Being "nice" players, both their first moves will be: +
+ ++And normally, they'd just pay back each others' kindness and sing Kumbaya until the end of time. +
++But what if, while trying to reciprocate goodness... +
+ +
+OH NO
+
+Mistakes, miscommunication, misinterpretations -- accidents happen all the time in real life.
+
+But if the other person doesn't think it was an accident... +
+ +
+OH NO TIMES TWO
+
+The other player, being a Copycat, had to retaliate...
+
+...and you, being a Copycat as well, will also have to retaliate... +
+ ++Thus, like the Hatfields and McCoys, +these two Copycats will spiral into an endless cycle of vengeance... +that started over a single mistake, long ago. +
++Tragic. But now, are there other types of players who can... +
++...deal with mistakes? → +
+ ++Let's meet some new faces! (or, new hats, anyway) +
+ +
+COPYKITTEN:
+Hello! I'm like Copycat,
+except I Cheat back only after you Cheat me twice in a row.
+After all, the first one could be a mistake! Purrrrr
+
+SIMPLETON:
+hi i try start cooperate.
+if you cooperate back, i do same thing as last move, even if it mistake.
+if you cheat back, i do opposite thing as last move, even if it mistake.
+
+RANDOM:
+Monkey robot! Ninja pizza tacos! lol i'm so random
+(Just plays Cheat or Cooperate randomly with a 50/50 chance)
+
+Alright, let's see how well these peeps do when they... +
++...play in a tournament → +
+ +
+Let's start with a dozen
+Always Cooperates,
+versus our old winner, the fair Copycat,
+and our three new characters:
+the forgiving Copykitten,
+the dull Simpleton, and
+the silly Random.
+
+In each round of a match, players have a small chance of making a mistake. (let's say, 5%)
+Who do you think will come out on top?
+Think carefully, then PLACE YOUR BETS:
+
+Alright, you bet [CHAR] wins. Let's find out! +Use the controls to your left to START the sim in quick mode, +or go through it step-by-step. +
++You were correct -- +
++Your bet was close, but no cigar -- +
++Simpleton wins! +This is because Simpleton is actually capable of +exploiting Always Cooperate. They both start cooperating, +but if Simpleton makes a mistake and cheats, +since Always Cooperate never retaliates, +it'll keep cheating them. +
++Now let's try... +
+ +
+...the same thing as before, except instead of half-Always Cooperate,
+it's half-Always Cheat. It's a much less forgiving,
+more hostile environment.
+
+Who do you think will win now? Think, then PLACE YOUR BETS:
+
+You bet on [CHAR]. Again, go through the simulation... +
++You were right on the money -- +
++Good guess, but someone else took the prize -- +
+
+Copykitten wins this time!
+That's surprising that with an even meaner starting population,
+Copykitten,
+a more forgiving version of Copycat,
+was the most successful! (note: Copykitten is so forgiving
+it doesn't even entirely wipe out Copycat. it shares room)
+
+In this case, a bit of "miscommunication" (5% chance of mistake each round) could lead
+to more forgiveness. But is this true for all levels...
+
+...of miscommunication? +
+ ++Use the slider below to change the amount of "miscommunication", then hit START. +At 5%, Copykitten wins. +What happens at 0%? Or 20%? Or 50%? (it only goes up to 50%, +because at that point, every move is a coin flip) +
++When you're done playing around, click: +
+ +
+The results turn out something like this:
+At 0%, the fair Copycat wins!
+At 1% to 9%, the forgiving Copykitten wins!
+At 10% to 49%: the unfair, unforgiving Always Cheat wins.
+At 50%, nobody wins ever.
+
+This is why "miscommunication" is such an interesting barrier to trust:
+a little bit of it leads to forgiveness,
+but too much and it leads to widespread distrust!
+I think our modern media technology,
+as much as it's helped us increase communication...
+has increased our miscommunication much more.
+
+At last, let's experiment with all the numbers, the knobs and sliders.
+Let's play...
+
+...in the Sandbox Mode! +
+ + + + + + ++Start off with this distribution of players: +
+ ++The payoffs in a one-on-one game are: +
++set default +
+ + + ++Play [N] rounds per match: +
++Play [N] round per match: +
+ ++After each tournament, eliminate the bottom [N] players & reproduce the top [N] players: +
++After each tournament, eliminate the bottom [N] player & reproduce the top [N] player: +
+ ++During each round, there's a [N]% chance a player makes a mistake: +
+ ++NOTE: Sandbox Mode is totally optional. +Feel free to skip it, or play around! Once you're done, let's recap... +
++what we learnt today! → +
+ + + + + + + ++Game theory has shown us the three things we need for the evolution of trust: +
++1. REPEAT INTERACTIONS +
++Trust keeps a relationship going, +but you need the knowledge of possible future repeat interactions before trust can evolve. +
++2. POSSIBLE WIN-WINS +
++You must be playing a non-zero-sum game, +a game where it's at least possible that both players can be better off -- a win-win. +
++3. LOW MISCOMMUNICATION +
++The level of miscommunication can't be too high. +And when there's a little bit of miscommunication, it pays to be more forgiving. +
++Of course, real-world trust is affected by much more than this. +There's reputation, shared values, contracts, cultural markers, blah blah blah. +And let's not forget... +
++...the biggest lesson. → +
+ +
+If there's one big takeaway
+from all of game theory, it's this:
+
+What the game is, defines what the players do.
+Our problem today isn't just that people are losing trust,
+it's that our environment acts against the evolution of trust.
+
+That may seem cynical or naive -- that we're "merely" products of our environment --
+but as game theory reminds us, we are each others' environment.
+In the short run, the game defines the players. But in the long run,
+it's us players who define the game.
+
+So, do what you can do, to create the conditions necessary to evolve trust.
+Build relationships. Find win-wins. Communicate clearly.
+Maybe then, we can stop firing at each other, get out of our own trenches,
+cross No Man's Land to come together...
+
+and all learn... +
+ ++...to live and let live. +
+ ++"A Christmas Truce between Opposing Trenches" +Illustrated by AC Michael. +Published in The Illustrated London News, January 9, 1915. +
+ ++<3 +
+ + + + + +
+
+
+created by:
+NICKY CASE
+play my other shtuff
+•
+follow my tweeter
+
+download the music & source code
+
+
+
+based off robert axelrod's 1984 book,
+"THE EVOLUTION OF COOPERATION"
+read my footnotes for this game
+
+
+
+lots of love and thanks to
+MY PATREON SUPPORTERS
+see my drawings of 'em
+•
+throw coins at me on patreon <3
+
+
+
+p.s: want more learning-by-playing?
+check out
+explorable explanations!
+
+
+
Copycat
++copycat +
++ + + Copycat + +
+ +Always Cheat
++cheater +
++ + + All Cheat + +
+ +Always Cooperate
++cooperator +
++ + + All Cooperate + +
+ +Grudger
++grudger +
++ + + Grudger + +
+ +Detective
++detective +
++ + + Detective + +
+ +Copykitten
++copykitten +
++ + + Copykitten + +
+ +Simpleton
++simpleton +
++ + + Simpleton + +
+ +Random
++random +
++ + + Random + +
+ + + + + + ++cooperate +
+ ++cheat +
+ ++play +
+ ++START +
+ ++STOP +
+ ++step +
+ ++reset +
+ ++population +
+ ++payoffs +
+ ++rules +
+ ++next → +
+ ++continue +
+ + + + + + ++0. Introduction +
++1. One Game +
++2. Repeated Game +
++3. One Tournament +
++4. Repeated Tournament +
++5. The Evolution of Distrust +
++6. Making Mistaeks +
++7. Sandbox Mode +
++8. Conclusion +
++9. Credits +
diff --git a/js/core/Slider.js b/js/core/Slider.js index 2817f90..0d01983 100644 --- a/js/core/Slider.js +++ b/js/core/Slider.js @@ -80,23 +80,49 @@ function Slider(config){ } }; - dom.addEventListener("mousedown",function(event){ + var _onDomMouseDown = function(event){ if(config.onselect) config.onselect(); _mouseToParam(event); _isDragging = true; _offsetX = 0; - },false); - knob.addEventListener("mousedown",function(event){ + }; + var _onKnobMouseDown = function(event){ _isDragging = true; if(config.onselect) config.onselect(); _offsetX = event.clientX - knob.getBoundingClientRect().left; - },false); - window.addEventListener("mousemove",function(event){ + }; + var _onWindowMouseMove = function(event){ if(_isDragging) _mouseToParam(event); - },false); - window.addEventListener("mouseup",function(){ + }; + var _onWindowMouseUp = function(){ _isDragging = false; + }; + dom.addEventListener("mousedown",_onDomMouseDown,false); + knob.addEventListener("mousedown",_onKnobMouseDown,false); + window.addEventListener("mousemove",_onWindowMouseMove,false); + window.addEventListener("mouseup",_onWindowMouseUp,false); + + // FOR TOUCH + var _fakeEventWrapper = function(event){ + var fake = {}; + fake.clientX = event.changedTouches[0].clientX; + fake.clientY = event.changedTouches[0].clientY; + return fake; + }; + dom.addEventListener("touchstart",function(event){ + event = _fakeEventWrapper(event); + _onDomMouseDown(event); },false); + knob.addEventListener("touchstart",function(event){ + event = _fakeEventWrapper(event); + _onKnobMouseDown(event); + },false); + window.addEventListener("touchmove",function(event){ + event = _fakeEventWrapper(event); + _onWindowMouseMove(event); + },false); + window.addEventListener("touchend",_onWindowMouseUp,false); + //////////////////////////////////////// diff --git a/js/slides/1_Slides_OneOff.js b/js/slides/1_Slides_OneOff.js index d1dd00b..65cdb6e 100644 --- a/js/slides/1_Slides_OneOff.js +++ b/js/slides/1_Slides_OneOff.js @@ -5,6 +5,8 @@ SLIDES.push({ onstart: function(self){ + Tournament.resetGlobalVariables(); + // Iterated Simulation self.add({id:"iterated", type:"Iterated", x:130, y:133}); diff --git a/js/slides/2_Slides_Iterated.js b/js/slides/2_Slides_Iterated.js index 39ff2fc..1b15f8a 100644 --- a/js/slides/2_Slides_Iterated.js +++ b/js/slides/2_Slides_Iterated.js @@ -4,6 +4,8 @@ SLIDES.push({ onjump: function(self){ + Tournament.resetGlobalVariables(); + // Iterated Simulation self.add({id:"iterated", type:"Iterated", x:130, y:133}); self.objects.iterated.dehighlightPayoff(); diff --git a/js/slides/6_Slides_Noise.js b/js/slides/6_Slides_Noise.js index 9b3799f..b9c30d7 100644 --- a/js/slides/6_Slides_Noise.js +++ b/js/slides/6_Slides_Noise.js @@ -7,6 +7,8 @@ SLIDES.push({ var o = self.objects; + Tournament.resetGlobalVariables(); + // Iterated Simulation self.add({id:"iterated", type:"Iterated", x:130, y:133}); o.iterated.dehighlightPayoff();