Skip to content

Instantly share code, notes, and snippets.

/omega.cpp
Created Oct 26, 2012

Embed
What would you like to do?
Simulation of Omega in Newcomb's Problem
#include <iostream>
using namespace std;
int main() {
int choice = 0;
cout << "\"Hi!" << endl
<< "Before you are two boxes, one contains $1,000 and the other contains an unspecified amount, $x:" << endl
<< "\t[$1000] [$x]" << endl
<< "You may choose to take just the one box that contains $x, or both boxes." << endl
<< "I am a keen student of human psychology and can predict which you will choose. If I have predicted that you will take only the one box that contains $x, I have placed $1,000,000 in that box. Otherwise, if I have predicted that you will take both boxes, I have placed $0 in that box." << endl
<< "Which shall you choose?\"" << endl
<< "(1) One box, containing $x, which may or may not contain $1,000,000. Or," << endl
<< "(2) Both boxes, the first containing $1,000 and the other containing $x, which may or may not contain $1,000,000." << endl;
cout << ">";
while (choice == 0) {
cin >> choice;
if (choice == 1 || choice == 2) break;
choice = 0;
cin.clear();
cin.ignore();
}
switch (choice) {
case 1:
cout << "Leaving the box containing $1,000 well alone, you open the other box and discover $1,000,000.";
break;
case 2:
cout << "You open the box containing $1,000 and take the money. After stashing this in your wallet, you open the second box. Unfortunately, it is empty.";
break;
}
cout << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.