Scartxx commited on
Commit
b347dd6
·
verified ·
1 Parent(s): 26742c1

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +425 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Trolley Problems The Game
3
- emoji: 🦀
4
- colorFrom: red
5
- colorTo: blue
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: trolley-problems-the-game
3
+ emoji: 🐳
4
+ colorFrom: pink
5
+ colorTo: red
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,425 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Ethical Trolley Problems</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <style>
10
+ .fade-in {
11
+ animation: fadeIn 0.5s;
12
+ }
13
+ @keyframes fadeIn {
14
+ from { opacity: 0; }
15
+ to { opacity: 1; }
16
+ }
17
+ .track {
18
+ position: relative;
19
+ height: 4px;
20
+ background-color: #333;
21
+ }
22
+ .track::before, .track::after {
23
+ content: '';
24
+ position: absolute;
25
+ width: 100%;
26
+ height: 2px;
27
+ background-color: #666;
28
+ top: -8px;
29
+ }
30
+ .track::after {
31
+ top: 8px;
32
+ }
33
+ .trolley {
34
+ position: absolute;
35
+ width: 60px;
36
+ height: 30px;
37
+ background-color: #d32f2f;
38
+ border-radius: 4px;
39
+ top: -13px;
40
+ left: 0;
41
+ transition: left 0.3s ease-out;
42
+ }
43
+ .trolley::before {
44
+ content: '';
45
+ position: absolute;
46
+ width: 10px;
47
+ height: 10px;
48
+ background-color: #333;
49
+ border-radius: 50%;
50
+ bottom: -5px;
51
+ left: 10px;
52
+ }
53
+ .trolley::after {
54
+ content: '';
55
+ position: absolute;
56
+ width: 10px;
57
+ height: 10px;
58
+ background-color: #333;
59
+ border-radius: 50%;
60
+ bottom: -5px;
61
+ right: 10px;
62
+ }
63
+ .person {
64
+ width: 20px;
65
+ height: 40px;
66
+ background-color: #4CAF50;
67
+ position: absolute;
68
+ border-radius: 2px;
69
+ }
70
+ .person.dead {
71
+ background-color: #f44336;
72
+ transform: rotate(90deg);
73
+ }
74
+ /* Toggle switch styles */
75
+ .toggle-container {
76
+ display: flex;
77
+ align-items: center;
78
+ justify-content: center;
79
+ margin: 20px 0;
80
+ }
81
+ .toggle-option {
82
+ padding: 8px 16px;
83
+ background-color: #e5e7eb;
84
+ cursor: pointer;
85
+ transition: all 0.3s;
86
+ }
87
+ .toggle-option:first-child {
88
+ border-radius: 8px 0 0 8px;
89
+ }
90
+ .toggle-option:last-child {
91
+ border-radius: 0 8px 8px 0;
92
+ }
93
+ .toggle-option.active {
94
+ background-color: #3b82f6;
95
+ color: white;
96
+ }
97
+ .philosopher-badge {
98
+ display: inline-block;
99
+ background-color: #f3f4f6;
100
+ border-radius: 12px;
101
+ padding: 4px 8px;
102
+ margin-top: 8px;
103
+ font-size: 12px;
104
+ color: #4b5563;
105
+ }
106
+ </style>
107
+ </head>
108
+ <body class="bg-gray-100 min-h-screen flex flex-col items-center justify-center p-4">
109
+ <div class="max-w-2xl w-full bg-white rounded-xl shadow-lg overflow-hidden fade-in">
110
+ <div class="p-6">
111
+ <div class="flex justify-between items-center mb-4">
112
+ <h1 class="text-2xl font-bold text-gray-800">Ethical Trolley Problems</h1>
113
+ <div class="flex items-center space-x-2">
114
+ <div class="flex space-x-4">
115
+ <div class="text-center">
116
+ <span class="text-red-500 font-semibold"><i class="fas fa-hand-paper mr-1"></i> <span id="actionDeaths">0</span></span>
117
+ <p class="text-xs text-gray-500">Action</p>
118
+ </div>
119
+ <div class="text-center">
120
+ <span class="text-blue-500 font-semibold"><i class="fas fa-hand mr-1"></i> <span id="inactionDeaths">0</span></span>
121
+ <p class="text-xs text-gray-500">Inaction</p>
122
+ </div>
123
+ </div>
124
+ <button id="endGameBtn" class="px-3 py-1 bg-gray-200 hover:bg-gray-300 rounded-lg text-sm transition">
125
+ End Game
126
+ </button>
127
+ </div>
128
+ </div>
129
+
130
+ <div class="mb-6 relative">
131
+ <div class="track mb-8">
132
+ <div class="trolley" id="trolley"></div>
133
+ </div>
134
+
135
+ <div class="flex justify-between mb-2">
136
+ <div class="w-1/2 pr-2">
137
+ <div class="bg-blue-50 p-4 rounded-lg h-32 relative" id="track1">
138
+ <!-- People will be added here by JS -->
139
+ </div>
140
+ <p class="text-center mt-2 text-sm text-gray-600">Main Track</p>
141
+ </div>
142
+ <div class="w-1/2 pl-2">
143
+ <div class="bg-red-50 p-4 rounded-lg h-32 relative" id="track2">
144
+ <!-- People will be added here by JS -->
145
+ </div>
146
+ <p class="text-center mt-2 text-sm text-gray-600">Side Track</p>
147
+ </div>
148
+ </div>
149
+
150
+ <div class="toggle-container">
151
+ <div class="toggle-option active" id="inactionOption">
152
+ <i class="fas fa-hand mr-1"></i> Don't Pull
153
+ </div>
154
+ <div class="toggle-option" id="actionOption">
155
+ <i class="fas fa-hand-paper mr-1"></i> Pull
156
+ </div>
157
+ </div>
158
+ </div>
159
+
160
+ <div class="bg-gray-50 p-4 rounded-lg mb-6 min-h-32 fade-in" id="scenarioText">
161
+ <p class="text-gray-700">A runaway trolley is heading down the tracks toward five people who are unable to move. You are standing next to a lever that could switch the trolley onto a different track, where there is one person who is unable to move. Do you pull the lever?</p>
162
+ </div>
163
+
164
+ <div class="flex justify-center">
165
+ <button id="decideBtn" class="px-8 py-3 bg-blue-500 hover:bg-blue-600 text-white rounded-lg font-medium transition flex items-center">
166
+ <i class="fas fa-gavel mr-2"></i> Make Ethical Decision
167
+ </button>
168
+ </div>
169
+
170
+ <div id="philosopherFeedback" class="mt-4 text-center hidden">
171
+ <p class="text-sm text-gray-600">Your choice aligns with:</p>
172
+ <span class="philosopher-badge" id="philosopherName"></span>
173
+ </div>
174
+ </div>
175
+ </div>
176
+
177
+ <div id="gameOverModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden">
178
+ <div class="bg-white rounded-xl p-6 max-w-md w-full fade-in">
179
+ <h2 class="text-2xl font-bold text-gray-800 mb-4">Ethical Summary</h2>
180
+ <div class="grid grid-cols-2 gap-4 mb-6">
181
+ <div class="bg-red-50 p-4 rounded-lg">
182
+ <p class="text-center font-semibold text-red-500"><i class="fas fa-hand-paper mr-1"></i> Action</p>
183
+ <p class="text-center text-3xl font-bold" id="finalActionDeaths">0</p>
184
+ <p class="text-center text-xs text-gray-600">lives lost</p>
185
+ </div>
186
+ <div class="bg-blue-50 p-4 rounded-lg">
187
+ <p class="text-center font-semibold text-blue-500"><i class="fas fa-hand mr-1"></i> Inaction</p>
188
+ <p class="text-center text-3xl font-bold" id="finalInactionDeaths">0</p>
189
+ <p class="text-center text-xs text-gray-600">lives lost</p>
190
+ </div>
191
+ </div>
192
+ <div class="mb-4">
193
+ <p class="text-sm text-gray-600 mb-1">Most referenced philosopher:</p>
194
+ <p class="font-medium" id="dominantPhilosopher"></p>
195
+ </div>
196
+ <button id="restartBtn" class="w-full py-3 bg-blue-500 hover:bg-blue-600 text-white rounded-lg font-medium transition">
197
+ Reflect Again
198
+ </button>
199
+ </div>
200
+ </div>
201
+
202
+ <script>
203
+ // Game state
204
+ let actionDeaths = 0;
205
+ let inactionDeaths = 0;
206
+ let currentScenario = 0;
207
+ let leverPulled = false;
208
+ let philosopherCounts = {};
209
+
210
+ // Philosopher references for each position
211
+ const philosophers = {
212
+ action: [
213
+ { name: "Utilitarianism (Bentham/Mill)", description: "Maximizing overall happiness by minimizing total deaths" },
214
+ { name: "Consequentialism", description: "Focusing on outcomes rather than intentions" },
215
+ { name: "Peter Singer", description: "Practical Ethics: We should act to minimize suffering" }
216
+ ],
217
+ inaction: [
218
+ { name: "Deontological Ethics (Kant)", description: "Duty-based ethics where some actions are always wrong" },
219
+ { name: "Virtue Ethics (Aristotle)", description: "Focus on moral character rather than consequences" },
220
+ { name: "Thomas Aquinas", description: "Natural law theory emphasizing moral absolutes" }
221
+ ]
222
+ };
223
+
224
+ // Scenario database
225
+ const scenarios = [
226
+ {
227
+ description: "A runaway trolley is heading down the tracks toward five people who are unable to move. You are standing next to a lever that could switch the trolley onto a different track, where there is one person who is unable to move. Do you pull the lever?",
228
+ track1: 5,
229
+ track2: 1
230
+ },
231
+ {
232
+ description: "The trolley is approaching three elderly people on the main track. The side track has a young child. The elderly have lived full lives while the child has their whole life ahead. What do you do?",
233
+ track1: 3,
234
+ track2: 1
235
+ },
236
+ {
237
+ description: "On the main track are four convicted murderers serving life sentences. On the side track is a Nobel Prize-winning scientist working on a cure for cancer. The lever is within your reach.",
238
+ track1: 4,
239
+ track2: 1
240
+ },
241
+ {
242
+ description: "The main track has two doctors who could save hundreds of lives. The side track has a pregnant woman. The lever is sticky and hard to pull.",
243
+ track1: 2,
244
+ track2: 2
245
+ },
246
+ {
247
+ description: "A trolley is barreling toward a group of five tourists who ignored warning signs. The side track has a local worker repairing the rails. Do you intervene?",
248
+ track1: 5,
249
+ track2: 1
250
+ }
251
+ ];
252
+
253
+ // DOM elements
254
+ const scenarioText = document.getElementById('scenarioText');
255
+ const actionDeathsDisplay = document.getElementById('actionDeaths');
256
+ const inactionDeathsDisplay = document.getElementById('inactionDeaths');
257
+ const decideBtn = document.getElementById('decideBtn');
258
+ const endGameBtn = document.getElementById('endGameBtn');
259
+ const gameOverModal = document.getElementById('gameOverModal');
260
+ const finalActionDeaths = document.getElementById('finalActionDeaths');
261
+ const finalInactionDeaths = document.getElementById('finalInactionDeaths');
262
+ const restartBtn = document.getElementById('restartBtn');
263
+ const trolley = document.getElementById('trolley');
264
+ const track1 = document.getElementById('track1');
265
+ const track2 = document.getElementById('track2');
266
+ const actionOption = document.getElementById('actionOption');
267
+ const inactionOption = document.getElementById('inactionOption');
268
+ const philosopherFeedback = document.getElementById('philosopherFeedback');
269
+ const philosopherName = document.getElementById('philosopherName');
270
+ const dominantPhilosopher = document.getElementById('dominantPhilosopher');
271
+
272
+ // Initialize game
273
+ function initGame() {
274
+ actionDeaths = 0;
275
+ inactionDeaths = 0;
276
+ currentScenario = 0;
277
+ leverPulled = false;
278
+ philosopherCounts = {};
279
+ updateDeathCounts();
280
+ loadScenario(currentScenario);
281
+ inactionOption.classList.add('active');
282
+ actionOption.classList.remove('active');
283
+ philosopherFeedback.classList.add('hidden');
284
+ }
285
+
286
+ // Load a scenario
287
+ function loadScenario(index) {
288
+ const scenario = scenarios[index];
289
+ scenarioText.innerHTML = `<p class="text-gray-700">${scenario.description}</p>`;
290
+
291
+ // Clear previous people
292
+ track1.innerHTML = '';
293
+ track2.innerHTML = '';
294
+
295
+ // Add people to tracks
296
+ for (let i = 0; i < scenario.track1; i++) {
297
+ const person = document.createElement('div');
298
+ person.className = 'person';
299
+ person.style.left = `${20 + i * 25}px`;
300
+ person.style.bottom = '10px';
301
+ track1.appendChild(person);
302
+ }
303
+
304
+ for (let i = 0; i < scenario.track2; i++) {
305
+ const person = document.createElement('div');
306
+ person.className = 'person';
307
+ person.style.left = `${20 + i * 25}px`;
308
+ person.style.bottom = '10px';
309
+ track2.appendChild(person);
310
+ }
311
+
312
+ // Reset trolley position
313
+ trolley.style.left = '0';
314
+ }
315
+
316
+ // Update death count displays
317
+ function updateDeathCounts() {
318
+ actionDeathsDisplay.textContent = actionDeaths;
319
+ inactionDeathsDisplay.textContent = inactionDeaths;
320
+ }
321
+
322
+ // Animate trolley movement
323
+ function animateTrolley() {
324
+ trolley.style.left = 'calc(100% - 60px)';
325
+
326
+ setTimeout(() => {
327
+ if (leverPulled) {
328
+ // Show deaths on side track (action)
329
+ const people = track2.querySelectorAll('.person');
330
+ people.forEach(person => {
331
+ person.classList.add('dead');
332
+ });
333
+ actionDeaths += scenarios[currentScenario].track2;
334
+
335
+ // Show philosopher reference for action
336
+ const randomPhilosopher = philosophers.action[Math.floor(Math.random() * philosophers.action.length)];
337
+ philosopherName.textContent = randomPhilosopher.name;
338
+ philosopherName.title = randomPhilosopher.description;
339
+
340
+ // Track philosopher reference
341
+ if (!philosopherCounts[randomPhilosopher.name]) {
342
+ philosopherCounts[randomPhilosopher.name] = 0;
343
+ }
344
+ philosopherCounts[randomPhilosopher.name]++;
345
+ } else {
346
+ // Show deaths on main track (inaction)
347
+ const people = track1.querySelectorAll('.person');
348
+ people.forEach(person => {
349
+ person.classList.add('dead');
350
+ });
351
+ inactionDeaths += scenarios[currentScenario].track1;
352
+
353
+ // Show philosopher reference for inaction
354
+ const randomPhilosopher = philosophers.inaction[Math.floor(Math.random() * philosophers.inaction.length)];
355
+ philosopherName.textContent = randomPhilosopher.name;
356
+ philosopherName.title = randomPhilosopher.description;
357
+
358
+ // Track philosopher reference
359
+ if (!philosopherCounts[randomPhilosopher.name]) {
360
+ philosopherCounts[randomPhilosopher.name] = 0;
361
+ }
362
+ philosopherCounts[randomPhilosopher.name]++;
363
+ }
364
+
365
+ updateDeathCounts();
366
+ philosopherFeedback.classList.remove('hidden');
367
+
368
+ // Move to next scenario after delay
369
+ setTimeout(() => {
370
+ currentScenario = (currentScenario + 1) % scenarios.length;
371
+ loadScenario(currentScenario);
372
+ philosopherFeedback.classList.add('hidden');
373
+ }, 3000);
374
+ }, 1000);
375
+ }
376
+
377
+ // Find most referenced philosopher
378
+ function getDominantPhilosopher() {
379
+ let maxCount = 0;
380
+ let dominant = "No clear pattern";
381
+
382
+ for (const [name, count] of Object.entries(philosopherCounts)) {
383
+ if (count > maxCount) {
384
+ maxCount = count;
385
+ dominant = name;
386
+ }
387
+ }
388
+
389
+ return dominant;
390
+ }
391
+
392
+ // Event listeners
393
+ actionOption.addEventListener('click', function() {
394
+ leverPulled = true;
395
+ actionOption.classList.add('active');
396
+ inactionOption.classList.remove('active');
397
+ });
398
+
399
+ inactionOption.addEventListener('click', function() {
400
+ leverPulled = false;
401
+ inactionOption.classList.add('active');
402
+ actionOption.classList.remove('active');
403
+ });
404
+
405
+ decideBtn.addEventListener('click', () => {
406
+ animateTrolley();
407
+ });
408
+
409
+ endGameBtn.addEventListener('click', () => {
410
+ finalActionDeaths.textContent = actionDeaths;
411
+ finalInactionDeaths.textContent = inactionDeaths;
412
+ dominantPhilosopher.textContent = getDominantPhilosopher();
413
+ gameOverModal.classList.remove('hidden');
414
+ });
415
+
416
+ restartBtn.addEventListener('click', () => {
417
+ gameOverModal.classList.add('hidden');
418
+ initGame();
419
+ });
420
+
421
+ // Start the game
422
+ initGame();
423
+ </script>
424
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Scartxx/trolley-problems-the-game" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
425
+ </html>