Source

python-ai / src / othello / Player.cpp

#include "Player.hpp"
#include <iostream>
#include <cstdlib>
#include <iterator>

using std::cout;
using std::cin;
using std::endl;
using std::advance;

Player::~Player() {}

const BoardLoc HumanPlayer::chooseMove(const Board board, const BoardLocs locs) {
    string rowStr, colStr;
    int row, col;
    cout << "Pick a row (0-7): " << endl;
    cin >> row;
    cout << "Pick a col (0-7): " << endl;
    cin >> col;
    return BoardLoc((int8_t)row, (int8_t)col);
}

const BoardLoc NaivePlayer::chooseMove(const Board board, const BoardLocs locs) {
    int num = rand() % locs.size();
    BoardLocs::const_iterator it = locs.begin();
    advance(it, num);
    return *it;
}