Advertisement
Guest User

Untitled

a guest
Dec 16th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.97 KB | None | 0 0
  1. //#include "stdafx.h"
  2.  
  3. #include <iostream>
  4. #include <time.h>
  5. #include <math.h>
  6. #include <stdlib.h>
  7. #include <stdio.h>
  8.  
  9.  
  10. using namespace std;
  11.  
  12. void game(int choice_bot1, int choice_bot2, int *w);
  13. int bot_do_boju(int points_bot1, int points_bot2, int round, int wybory1[], int wybory2[]);
  14. int bot_high(int points_bot1, int points_bot2, int round, int wybory1[], int wybory2[]);
  15. int calculate_last_n_diff(int n, int round, int wybory1[], int wybory2[]);
  16.  
  17. const int R = 25;
  18. const int ilosc_gier = 1000;
  19. int wybory1 [ilosc_gier];
  20. int wybory2 [ilosc_gier];
  21.  
  22. int main() {
  23.     int j = 0;
  24.     int choice1 = 0, choice2 = 0;
  25.     int SCORE[2] = {0, 0};
  26.     int *s;
  27.     s = SCORE;
  28.  
  29.     srand(time(NULL));
  30.     do {
  31.         cout << "Runda " << j + 1 << endl;
  32.         choice1 = bot_do_boju(SCORE[0], SCORE[1], j, wybory1, wybory2);
  33.         choice2 = bot_high(SCORE[1], SCORE[0], j, wybory2, wybory1);
  34.         cout << "Gracz  wybral: " << choice1 << "\t";
  35.         cout << "Gracz  wybral: " << choice2 << "\t" << endl;
  36.         wybory1[j] = choice1;
  37.         wybory2[j] = choice2;
  38.         game(choice1, choice2, s);
  39.         cout << endl << "Punktacja: \n\t" << SCORE[0] << "\n\t" << SCORE[1] << endl << endl << endl;
  40.         j++;
  41.     } while (j < ilosc_gier);
  42.     cout << "Ncisnij ENTER aby kontynuowac...";
  43.     getchar();
  44.     system("CLS");
  45.     cout << "Koniec gry!\n\t Gracz  uzyskal: " << SCORE[0] << "\n\t Gracz  uzyskal: "
  46.             << SCORE[1] << endl;
  47.     getchar();
  48.     return 0;
  49. }
  50.  
  51. void game(int choice_bot1, int choice_bot2, int *w) {
  52.     bool flag = 0;
  53.     if ((choice_bot1 < 180) || (choice_bot1 > 300)) {
  54.         if ((choice_bot2 >= 180) && (choice_bot2 <= 300))
  55.             w[1] += choice_bot2 + R;
  56.         flag = 1;
  57.     }
  58.     if (!flag && ((choice_bot2 < 180) || (choice_bot2 > 300))) {
  59.         if ((choice_bot1 >= 180) && (choice_bot1 <= 300))
  60.             w[0] += choice_bot1 + R;
  61.         flag = 1;
  62.     }
  63.  
  64.     if (!flag) {
  65.         if (choice_bot1 == choice_bot2) {
  66.             w[0] += choice_bot1;
  67.             w[1] += choice_bot1;
  68.         } else {
  69.             if (choice_bot1 > choice_bot2) {
  70.                 w[0] += choice_bot2 - R;
  71.                 w[1] += choice_bot2 + R;
  72.             } else {
  73.                 w[0] += choice_bot1 + R;
  74.                 w[1] += choice_bot1 - R;
  75.             }
  76.         }
  77.     }
  78. }
  79.  
  80. int bot_do_boju(int points_bot1, int points_bot2, int round, int wybory1[], int wybory2[]) {
  81.  
  82.     if (round == 0) return 250;
  83.     int new_value = 1;
  84.     int rounds_between_change = 3;
  85.     if (round > rounds_between_change && round % rounds_between_change == 0) {
  86.  
  87.         if (points_bot2 > points_bot1) {
  88.             new_value = wybory1[round - 1] + calculate_last_n_diff(rounds_between_change, round, wybory1, wybory2) / 10;
  89.         }
  90.  
  91.     } else {
  92.         new_value = wybory1[round - 1];
  93.     }
  94.     if (new_value > 300) return 299;
  95.     if (new_value < 180) return 200;
  96.     return new_value;
  97. }
  98.  
  99. int calculate_last_n_diff(int n, int round, int wybory1[], int wybory2[]) {
  100.     int my_points = 0;
  101.     int oponent_points = 0;
  102.     for (int i = round - n; i < round - 1; i++) {
  103.         my_points += wybory1[i];
  104.         oponent_points += wybory2[i];
  105.     }
  106.     return my_points - oponent_points;
  107. }
  108.  
  109. int bot_high(int points_bot1, int points_bot2, int round, int wybory1[], int wybory2[]) {
  110.  
  111.     int difference_tour = 0;
  112.     if (round <= 1) {
  113.         return 280;
  114.     }
  115.     if (((double) round / 33) == 1) {
  116.         return 250;
  117.     } else {
  118.         int difference_tour = (wybory2[round - 2] - wybory2[round - 1]);
  119.         if (wybory2[round - 1] > 2) {
  120.             if (wybory2[round - 1] - (2 * difference_tour - 1) > 300) {
  121.                 return 299;
  122.             }
  123.             if ((wybory2[round - 1] - (2 * difference_tour - 1)) < 180)
  124.                 return 180;
  125.  
  126.             else {
  127.                 return wybory2[round - 1] - (2 * difference_tour - 1);
  128.             }
  129.  
  130.         } else {
  131.             return 280;
  132.  
  133.         }
  134.     }
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement