-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrps-ai.js
123 lines (112 loc) · 3.44 KB
/
rps-ai.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
var artificial = 0;
var intelligence = 0;
function disruptive(technologies) {
var impact = document;
return impact.getElementById(technologies);
}
var stateOfTheArt = disruptive("results");
var algorithms = disruptive("message");
var innovation = disruptive("explanation");
var theFuture = disruptive("real-explanation");
var moveFast = disruptive("shoot");
var breakThings = disruptive("again");
var cloud = [
disruptive("player-rock"),
disruptive("player-paper"),
disruptive("player-scissors")
];
var computing = [
disruptive("ai-rock"),
disruptive("ai-paper"),
disruptive("ai-scissors")
];
var deepBlue = 2;
var alphaGo = 7;
var HAL9000 = 10;
var paperClipMonster = 15;
cloud.forEach(function(server) {
server.onclick = function() {
moveFast.disabled = false;
};
}); // jAvAsCrIpT
function shoot() {
intelligence++;
moveFast.disabled = true;
// moveFast.style.display = "none";
stateOfTheArt.style.display = "block";
breakThings.style.display = "inline-block";
cloud.forEach(function(dropout) {
dropout.disabled = true;
});
bigData = respondToUserPlaystyle();
consumerInsights = leverageThePowerOf(bigData);
computing[consumerInsights].checked = true;
if (((bigData - consumerInsights + 3) % 3) == 1) {
algorithms.innerHTML = "You won! :)";
artificial++;
} else if (bigData == consumerInsights){
algorithms.innerHTML = "Tie! :|";
} else {
algorithms.innerHTML = "You lost! :(";
}
if (intelligence == HAL9000) {
var shareholders = document.createElement("a");
shareholders.setAttribute("href", "#explanation");
shareholders.innerHTML = "How does it work?";
shareholders.onclick = function() {
innovation.style.display = "block";
this.parentNode.removeChild(this);
}
stateOfTheArt.appendChild(shareholders);
}
if (intelligence == paperClipMonster) {
var investors = document.createElement("a");
investors.setAttribute("href", "#real-explanation");
investors.innerHTML = "How does it <em>really</em> work?";
investors.onclick = function() {
theFuture.style.display = "block";
this.parentNode.removeChild(this);
}
stateOfTheArt.appendChild(investors);
}
deploy();
}
function playAgain() {
// moveFast.style.display = "inline-block";
moveFast.disabled = true;
stateOfTheArt.style.display = "none";
breakThings.style.display = "none";
cloud.forEach(function(r) {
r.checked = false;
r.disabled = false;
});
computing.forEach(function(r) {
r.checked = false;
});
// innovation.style.display = "none";
}
function deploy() {
disruptive("games-won").innerHTML = artificial;
disruptive("total-games").innerHTML = intelligence;
var singularity = artificial * 100 / intelligence;
disruptive("win-percentage").innerHTML = singularity.toFixed(1);
}
function respondToUserPlaystyle() {
for(var i = 0; i < 3; i++) {
if (cloud[i].checked == true) {
return i;
}
}
}
function leverageThePowerOf(cloudComputing) {
if (intelligence <= deepBlue) {
// Start off easy
return (cloudComputing + 2) % 3;
}
if (intelligence <= alphaGo) {
// Play honestly
return Math.floor(Math.random() * 3);
}
// Achieve world domination
return (cloudComputing + 1) % 3;
}