Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <fstream>
- #include <stdlib.h>
- #include <string>
- #include <random>
- using namespace std;
- int main (){
- //Declaration
- int turn=0;
- mt19937 rnd_gen(time(NULL));
- int iceblock=0;
- int fireball=0;
- int roll;
- int life=30;
- int win=0;
- int lose=0;
- int times=100000000;
- //Output
- ofstream output;
- ostringstream stream;
- stream << "mage.txt";
- string dateiname=stream.str();
- output.open(dateiname);
- for (int n=0;n<times;n++){
- life=30;
- iceblock=0;
- fireball=0;
- turn=0;
- for (int m=0;m<3;m++){
- uniform_int_distribution<int> draw (1,2);
- roll=draw(rnd_gen);
- if(roll==1){
- iceblock++;
- //cout << endl << 1;
- }
- else if(roll==2){
- fireball++;
- //cout << endl << 2;
- }
- }
- //cout << endl << "Starting hand: Fireball: " << fireball << " , Ice Block: " << iceblock;
- while (life>0){
- turn++;
- uniform_int_distribution<int> draw (1,2);
- roll=draw(rnd_gen);
- if(roll==1){
- iceblock++;
- //cout << endl << "Draw: Ice Block";
- //cout << endl << 1;
- }
- else if(roll==2){
- fireball++;
- //cout << endl << "Draw: Fireball";
- //cout << endl << 2;
- }
- if(turn==1){
- }
- else if(turn==2){
- life--;
- }
- else if(turn==3 || turn==4){
- iceblock--;
- }
- else if(turn==5 || turn==6){
- iceblock--;
- life--;
- }
- else if(turn==7 || turn==8){
- iceblock--;
- if (fireball>=1){
- fireball--;
- life=life-6;
- }
- }
- else if(turn==9){
- iceblock--;
- if (fireball>=1){
- fireball--;
- life=life-6;
- }
- life--;
- }
- else if(turn>=10){
- if (life<=13 && fireball>=2){
- fireball--;
- fireball--;
- life=life-13;
- }
- else if (fireball=1){
- fireball--;
- iceblock--;
- life=life-7;
- }
- else if (fireball<=0){
- iceblock--;
- life=life-1;
- }
- }
- //cout << endl << "Turn: " << turn << " , Life: " << life << " , Fireball: " << fireball << " , Ice Block: " << iceblock;
- if (life<1){
- win++;
- //cout << endl << "Win, turn: " << turn << " , life: " << life;
- break;
- }
- if (iceblock<0){
- lose++;
- //cout << endl << "Lose, turn: " << turn << " , life: " << life;
- break;
- }
- }
- }
- cout << endl << "Lost: " << lose << " , Won: " << win;
- output.close();
- return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement