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 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
/*
Zombie sim 0.1
An attempt to simulate the daily life of a human (broken down 24 hours in 24 minutes) to see the
odds of surviving on a per day basis and the expansion of the zombie populous vs the human populous
:D
*/
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <time.h>
using namespace std;
int main(){
//declare our variables
int awake, eat, safe, mate, survive, attempts, slept, ate, mated, survived, zombie, zombiefied, stupid, runs, eaten, starved;
string didsleep, dideat, aresafe, didmate, didsurvive, arezombie, starve;
//thrown here to work out how to do longest consecutive time spent alive
int chain, longest;
//zeroing out variables cause I know no better way
slept = 0;
ate = 0;
mated = 0;
survived = 0;
zombiefied = 0;
stupid = 0;
eaten = 0;
starved = 0;
chain = 0;
longest = 0;
//be polite, ask how long they want it to run first
cout << "How many attempts would you like to simulate? :>";
cin >> runs;
//loop with odds of one thing or the other happening
while( attempts < runs ){
awake = rand() % 3;
eat = rand() % 3;
safe = rand() % 3;
mate = rand() % 3;
survive = rand() % 3;
zombie = rand() % 5;
//+++++++++++++++++++++++++++++++++++++++++++
//are you awake? (will later determine if you more vulnerable to zombification
// due to being unconscious as well as whether or not you are forcefully
//put to sleep from exhaustion (how many days without sleep)
if( awake == 1 ){
didsleep = "you did";
slept++;}
else
{didsleep = "you did not";
};
//+++++++++++++++++++++++++++++++++++++++++++
//Have you eaten today? Will move into how strong/weak you are from lack
//of nutrition (and overall food supply for when we start including
//larger numbers of people, also helps determine if you have starved to death
if( eat == 1 ){
dideat = "you did";
ate++;
eaten = 0;
}
else
{dideat = "you did not";
eaten++;
};
//++++++++++++++++++++++++++++++++++++++++++++
//dunno why this is here yet, it seemed like an idea to have it but it might later
//determine your odds of encountering a zombie (and then determine your odds of surviving
//that encounter (i.e. 1 zombie = good odds, unsafe = 100's of zombies = death T_T
if(safe == 1){
aresafe = "you are";}
else
{aresafe = "you are not";
};
//+++++++++++++++++++++++++++++++++++++++++++++
//er... im assuming the human race is going try to keep going, which means the population
//will fluctuate....
if(mate == 1){
didmate = "you did";
mated++;}
else
{didmate = "you did not";
};
//+++++++++++++++++++++++++++++++++++++++++++++
//well? did you?!? also helps determine how long you stayed alive
if (( survive == 1 ) && ( eaten < 14 )){
didsurvive = "you did";
survived++;
chain++;}
else
{didsurvive = "you did not";
chain = 0;
};
if(chain > longest)
longest++;
//++++++++++++++++++++++++++++++++++++++++++++++
//Have you joined the undead horde?
if( zombie == 1){
arezombie = "you are";
zombiefied++;}
else
{arezombie = "you are not";
};
//+++++++++++++++++++++++++++++++++++++++++++++++
//its here that we determined how many attempts you have failed at eating,
//assuming overall attempts were 3 times daily and 14 days till starvation... or
//was that dehydration o_O
if( eaten > (13 * 3) ){
starve = "starved";
starved++;}
else
{starve = "did not starve";};
//daily statistics
cout << "Welcome to your day!" << endl;
cout << "Today: " <<endl;
cout << didsleep << " sleep..." << endl;
cout << dideat << " eat..." << endl;
cout << aresafe << " safe..." << endl;
cout << didmate << " mate..." << endl;
cout << didsurvive << " survive..." << endl;
cout << "And " << arezombie << " a zombie!" << endl;
cout << endl;
attempts++;
};
//global statistics after it has finished the overall loop
cout << "In total you:" << endl;
cout << "Slept " << slept << " times" << endl;
cout << "Ate " << ate << " times" << endl;
cout << "Mated " << mated << " times" << endl;
cout << "And survived " << survived << " times!" << endl;
cout << "You starved " << starved << " times!" << endl;
//if you didnt die from old age or natural death, and if you werent zombified
//or starved to death, you obviously did something you are less then comfortable
//admitting and died cause of it =D
stupid = runs - survived - zombiefied - starved;
cout << "You died " << stupid << " times from idiocy" << endl;
cout << "Sadly, you became a zombie " << zombiefied << " times T_T" << endl;
cout << "Your longest run was " << longest << " days alive!" << endl;
return 0;
}
|