Advertisement
Guest User

Ice Block/Fireball vs. Mech Warper//Metal Tooth Leaper

a guest
May 12th, 2016
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.33 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3. #include <fstream>
  4. #include <stdlib.h>    
  5. #include <string>  
  6. #include <random>        
  7.  
  8. using namespace std;
  9.  
  10. int main (){
  11. //Declaration
  12.     int turn=0;
  13.     mt19937 rnd_gen(time(NULL));
  14.     int iceblock=0;
  15.     int fireball=0;
  16.     int roll;
  17.     int life=30;
  18.     int win=0;
  19.     int lose=0;
  20.     int times=100000000;
  21. //Output
  22.     ofstream output;
  23.     ostringstream stream;
  24.     stream << "mage.txt";
  25.     string dateiname=stream.str();
  26.     output.open(dateiname);
  27.  
  28. for (int n=0;n<times;n++){
  29.     life=30;
  30.     iceblock=0;
  31.     fireball=0;
  32.     turn=0;
  33.     for (int m=0;m<3;m++){
  34.         uniform_int_distribution<int> draw (1,2);
  35.                 roll=draw(rnd_gen);
  36.                 if(roll==1){
  37.                     iceblock++;
  38.                 //cout <<  endl   << 1;
  39.                 }
  40.                 else if(roll==2){
  41.                     fireball++;
  42.                 //cout <<  endl   << 2;
  43.                 }
  44.     }
  45.     //cout <<  endl   << "Starting hand: Fireball: " << fireball << " , Ice Block: " << iceblock;
  46.    
  47.     while (life>0){
  48.         turn++;
  49.         uniform_int_distribution<int> draw (1,2);
  50.                 roll=draw(rnd_gen);
  51.                 if(roll==1){
  52.                     iceblock++;
  53.                     //cout <<  endl   << "Draw: Ice Block";
  54.                 //cout <<  endl   << 1;
  55.                 }
  56.                 else if(roll==2){
  57.                     fireball++;
  58.                     //cout <<  endl   << "Draw: Fireball";
  59.                 //cout <<  endl   << 2;
  60.                 }
  61.         if(turn==1){
  62.         }
  63.         else if(turn==2){
  64.             life--;
  65.         }
  66.         else if(turn==3 || turn==4){
  67.             iceblock--;
  68.         }
  69.         else if(turn==5 || turn==6){
  70.             iceblock--;
  71.             life--;
  72.             }
  73.         else if(turn==7 || turn==8){
  74.             iceblock--;
  75.             if (fireball>=1){
  76.             fireball--;
  77.             life=life-6;
  78.             }
  79.         }
  80.         else if(turn==9){
  81.             iceblock--;
  82.             if (fireball>=1){
  83.             fireball--;
  84.             life=life-6;
  85.             }
  86.             life--;
  87.         }
  88.         else if(turn>=10){
  89.             if (life<=13 && fireball>=2){
  90.             fireball--;
  91.             fireball--;
  92.             life=life-13;
  93.             }
  94.             else if (fireball=1){
  95.             fireball--;
  96.             iceblock--;
  97.             life=life-7;
  98.             }
  99.             else if (fireball<=0){
  100.             iceblock--;
  101.             life=life-1;
  102.             }
  103.         }
  104.     //cout <<  endl   << "Turn: " << turn << " , Life: " << life << " , Fireball: " << fireball << " , Ice Block: " << iceblock;
  105.     if (life<1){
  106.     win++;
  107.     //cout <<  endl   << "Win, turn: " << turn << " , life: " << life;
  108.     break;
  109.     }
  110.     if (iceblock<0){
  111.     lose++;
  112.     //cout <<  endl   << "Lose, turn: " << turn << " , life: " << life;
  113.     break;
  114.     }
  115.     }
  116. }
  117. cout <<  endl   << "Lost: " << lose << " , Won: " << win;
  118. output.close();
  119. return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement