-
Notifications
You must be signed in to change notification settings - Fork 0
/
RandomAgent.cpp
29 lines (27 loc) · 955 Bytes
/
RandomAgent.cpp
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
28
29
/* =============================================================================
# FileName: RandomAgent.cpp
# Desc: Random Agent
# Author: YanlongLi
# Email: [email protected]
# HomePage: http://www.yanlongli.me
# Created: 2017-10-14 03:58:52
# Version: 0.0.1
# LastChange: 2017-10-14 03:58:52
# History:
# 0.0.1 | YanlongLi | init
============================================================================= */
#include "RandomAgent.h"
#include <vector>
#include <ctime>
#include <cstdlib>
using namespace std;
Board RandomAgent::nextByMaxer(const Board& board) {
vector<Action> actions = validActionByMaxer(board);
int index = rand() % actions.size();
return actions[index].result();
}
Board RandomAgent::nextByMiner(const Board& board) {
vector<Action> actions = validActionByMiner(board);
int index = rand() % actions.size();
return actions[index].result();
}