Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 19 additions & 21 deletions mcts/include/state.h
Original file line number Diff line number Diff line change
@@ -1,38 +1,36 @@
#ifndef MCTS_STATE_H
#define MCTS_STATE_H

#include <stdexcept>
#include <iostream>
#include <queue>

#include <stdexcept>

using namespace std;


struct MCTS_move {
virtual ~MCTS_move() = default;
virtual bool operator==(const MCTS_move& other) const = 0; // implement this!
virtual string sprint() const { return "Not implemented"; } // and optionally this
virtual ~MCTS_move() = default;
virtual bool operator==(const MCTS_move &other) const = 0; // implement this!
virtual string sprint() const {
return "Not implemented";
} // and optionally this
};


/** Implement all pure virtual methods. Notes:
* - rollout() must return something in [0, 1] for UCT to work as intended and specifically
* the winning chance of player1.
* - rollout() must return something in [0, 1] for UCT to work as intended and
* specifically the winning chance of player1.
* - player1 is determined by player1_turn()
*/
class MCTS_state {
public:
// Implement these:
virtual ~MCTS_state() = default;
virtual queue<MCTS_move *> *actions_to_try() const = 0;
virtual MCTS_state *next_state(const MCTS_move *move) const = 0;
virtual double rollout() const = 0;
virtual bool is_terminal() const = 0;
virtual void print() const {
cout << "Printing not implemented" << endl;
}
virtual bool player1_turn() const = 0; // MCTS is for two-player games mostly -> (keeps win rate)
public:
// Implement these:
virtual ~MCTS_state() = default;
virtual queue<MCTS_move *> *actions_to_try() const = 0;
virtual MCTS_state *next_state(const MCTS_move *move) const = 0;
virtual double rollout() const = 0;
virtual bool is_terminal() const = 0;
virtual void print() const { cout << "Printing not implemented" << endl; }
virtual bool player1_turn()
const = 0; // MCTS is for two-player games mostly -> (keeps win rate)
};


#endif