Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include "stdafx.h"
- #include <iostream>
- #include <time.h>
- #include <math.h>
- #include <stdlib.h>
- #include <stdio.h>
- using namespace std;
- void game(int choice_bot1, int choice_bot2, int *w);
- int bot_do_boju(int points_bot1, int points_bot2, int round, int wybory1[], int wybory2[]);
- int bot_high(int points_bot1, int points_bot2, int round, int wybory1[], int wybory2[]);
- int calculate_last_n_diff(int n, int round, int wybory1[], int wybory2[]);
- const int R = 25;
- const int ilosc_gier = 1000;
- int wybory1 [ilosc_gier];
- int wybory2 [ilosc_gier];
- int main() {
- int j = 0;
- int choice1 = 0, choice2 = 0;
- int SCORE[2] = {0, 0};
- int *s;
- s = SCORE;
- srand(time(NULL));
- do {
- cout << "Runda " << j + 1 << endl;
- choice1 = bot_do_boju(SCORE[0], SCORE[1], j, wybory1, wybory2);
- choice2 = bot_high(SCORE[1], SCORE[0], j, wybory2, wybory1);
- cout << "Gracz wybral: " << choice1 << "\t";
- cout << "Gracz wybral: " << choice2 << "\t" << endl;
- wybory1[j] = choice1;
- wybory2[j] = choice2;
- game(choice1, choice2, s);
- cout << endl << "Punktacja: \n\t" << SCORE[0] << "\n\t" << SCORE[1] << endl << endl << endl;
- j++;
- } while (j < ilosc_gier);
- cout << "Ncisnij ENTER aby kontynuowac...";
- getchar();
- system("CLS");
- cout << "Koniec gry!\n\t Gracz uzyskal: " << SCORE[0] << "\n\t Gracz uzyskal: "
- << SCORE[1] << endl;
- getchar();
- return 0;
- }
- void game(int choice_bot1, int choice_bot2, int *w) {
- bool flag = 0;
- if ((choice_bot1 < 180) || (choice_bot1 > 300)) {
- if ((choice_bot2 >= 180) && (choice_bot2 <= 300))
- w[1] += choice_bot2 + R;
- flag = 1;
- }
- if (!flag && ((choice_bot2 < 180) || (choice_bot2 > 300))) {
- if ((choice_bot1 >= 180) && (choice_bot1 <= 300))
- w[0] += choice_bot1 + R;
- flag = 1;
- }
- if (!flag) {
- if (choice_bot1 == choice_bot2) {
- w[0] += choice_bot1;
- w[1] += choice_bot1;
- } else {
- if (choice_bot1 > choice_bot2) {
- w[0] += choice_bot2 - R;
- w[1] += choice_bot2 + R;
- } else {
- w[0] += choice_bot1 + R;
- w[1] += choice_bot1 - R;
- }
- }
- }
- }
- int bot_do_boju(int points_bot1, int points_bot2, int round, int wybory1[], int wybory2[]) {
- if (round == 0) return 250;
- int new_value = 1;
- int rounds_between_change = 3;
- if (round > rounds_between_change && round % rounds_between_change == 0) {
- if (points_bot2 > points_bot1) {
- new_value = wybory1[round - 1] + calculate_last_n_diff(rounds_between_change, round, wybory1, wybory2) / 10;
- }
- } else {
- new_value = wybory1[round - 1];
- }
- if (new_value > 300) return 299;
- if (new_value < 180) return 200;
- return new_value;
- }
- int calculate_last_n_diff(int n, int round, int wybory1[], int wybory2[]) {
- int my_points = 0;
- int oponent_points = 0;
- for (int i = round - n; i < round - 1; i++) {
- my_points += wybory1[i];
- oponent_points += wybory2[i];
- }
- return my_points - oponent_points;
- }
- int bot_high(int points_bot1, int points_bot2, int round, int wybory1[], int wybory2[]) {
- int difference_tour = 0;
- if (round <= 1) {
- return 280;
- }
- if (((double) round / 33) == 1) {
- return 250;
- } else {
- int difference_tour = (wybory2[round - 2] - wybory2[round - 1]);
- if (wybory2[round - 1] > 2) {
- if (wybory2[round - 1] - (2 * difference_tour - 1) > 300) {
- return 299;
- }
- if ((wybory2[round - 1] - (2 * difference_tour - 1)) < 180)
- return 180;
- else {
- return wybory2[round - 1] - (2 * difference_tour - 1);
- }
- } else {
- return 280;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement