-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomPlayer.cpp
More file actions
27 lines (24 loc) · 768 Bytes
/
Copy pathRandomPlayer.cpp
File metadata and controls
27 lines (24 loc) · 768 Bytes
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
// Class definition for XO_RandomPlayer class
// Which is a computer player playing randomly
// Author: Mohammad El-Ramly
// Date: 10/10/2022
// Version: 1
#include<iostream>
#include<random>
#include<iomanip>
#include<algorithm>
#include "BoardGame_Classes.hpp"
//#include"../include/BoardGame_Classes.hpp"
using namespace std;
// Set player symbol and name as Random Computer Player
RandomPlayer::RandomPlayer (char symbol, int dimension):Player(symbol)
{
this->dimension = dimension;
this->name = "Random Computer Player";
cout << "My names is " << name << endl;
}
// Generate a random move
void RandomPlayer::get_move (int& x, int& y) {
x = (int) (rand()/(RAND_MAX + 1.0) * dimension);
y = (int) (rand()/(RAND_MAX + 1.0) * dimension);
}