Skip to content

Commit

Permalink
Disable swap for the solvers
Browse files Browse the repository at this point in the history
  • Loading branch information
Timo Ewalds committed May 10, 2010
1 parent 4aecc8b commit 1af5df8
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 14 deletions.
10 changes: 6 additions & 4 deletions board.h
Expand Up @@ -84,12 +84,13 @@ class Board{
};

private:
short size; //the length of one side of the hexagon
short size_d; //diameter of the board = size*2-1
char size; //the length of one side of the hexagon
char size_d; //diameter of the board = size*2-1

short nummoves;
char toPlay;
char outcome; //-1 = unknown, 0 = tie, 1,2 = player win
bool allowswap;

vector<Cell> cells;

Expand All @@ -104,6 +105,7 @@ class Board{
nummoves = 0;
toPlay = 1;
outcome = -1;
allowswap = true;

cells.resize(vecsize());

Expand Down Expand Up @@ -143,8 +145,8 @@ class Board{
bool onboard(int x, int y) const { return ( x >= 0 && y >= 0 && x < size_d && y < size_d && onboard_fast(x, y) ); }
bool onboard(const Move & m)const { return (m.x >= 0 && m.y >= 0 && m.x < size_d && m.y < size_d && onboard_fast(m) ); }

bool canswap() const { return (nummoves == 1 && toPlay == 2); }
// bool canswap() const { return false; }
void setswap(bool s) { allowswap = s; }
bool canswap() const { return (nummoves == 1 && toPlay == 2 && allowswap); }

//assumes x, y are in bounds (meaning no swap) and the game isn't already finished
bool valid_move_fast(int x, int y) const { return !get(x,y); }
Expand Down
10 changes: 5 additions & 5 deletions solver.h
Expand Up @@ -99,11 +99,11 @@ class Solver {
}
void timedout(){ timeout = true; }

void solve_ab (const Board & board, double time, int mdepth = 1000);
void solve_scout (const Board & board, double time, int mdepth = 1000);
void solve_pns (const Board & board, double time, uint64_t memlimit);
void solve_pnsab (const Board & board, double time, uint64_t memlimit);
void solve_dfpnsab(const Board & board, double time, uint64_t memlimit);
void solve_ab (Board board, double time, int mdepth = 1000);
void solve_scout (Board board, double time, int mdepth = 1000);
void solve_pns (Board board, double time, uint64_t memlimit);
void solve_pnsab (Board board, double time, uint64_t memlimit);
void solve_dfpnsab(Board board, double time, uint64_t memlimit);

//protected:

Expand Down
3 changes: 2 additions & 1 deletion solverab.cpp
@@ -1,12 +1,13 @@

#include "solver.h"

void Solver::solve_ab(const Board & board, double time, int mdepth){
void Solver::solve_ab(Board board, double time, int mdepth){
reset();
if(board.won() >= 0){
outcome = board.won();
return;
}
board.setswap(false);

Timer timer = Timer(time, bind(&Solver::timedout, this));
int starttime = time_msec();
Expand Down
3 changes: 2 additions & 1 deletion solverdfpnsab.cpp
@@ -1,13 +1,14 @@

#include "solver.h"

void Solver::solve_dfpnsab(const Board & board, double time, uint64_t memlimit){
void Solver::solve_dfpnsab(Board board, double time, uint64_t memlimit){
reset();

if(board.won() >= 0){
outcome = board.won();
return;
}
board.setswap(false);

Timer timer = Timer(time, bind(&Solver::timedout, this));
int starttime = time_msec();
Expand Down
3 changes: 2 additions & 1 deletion solverpns.cpp
Expand Up @@ -8,13 +8,14 @@
* L W L L from the perspective of toplay
* U W LT U
*/
void Solver::solve_pns(const Board & board, double time, uint64_t memlimit){
void Solver::solve_pns(Board board, double time, uint64_t memlimit){
reset();

if(board.won() >= 0){
outcome = board.won();
return;
}
board.setswap(false);

Timer timer = Timer(time, bind(&Solver::timedout, this));
int starttime = time_msec();
Expand Down
3 changes: 2 additions & 1 deletion solverpnsab.cpp
@@ -1,13 +1,14 @@

#include "solver.h"

void Solver::solve_pnsab(const Board & board, double time, uint64_t memlimit){
void Solver::solve_pnsab(Board board, double time, uint64_t memlimit){
reset();

if(board.won() >= 0){
outcome = board.won();
return;
}
board.setswap(false);

Timer timer = Timer(time, bind(&Solver::timedout, this));
int starttime = time_msec();
Expand Down
3 changes: 2 additions & 1 deletion solverscout.cpp
@@ -1,12 +1,13 @@

#include "solver.h"

void Solver::solve_scout(const Board & board, double time, int mdepth){
void Solver::solve_scout(Board board, double time, int mdepth){
reset();
if(board.won() >= 0){
outcome = board.won();
return;
}
board.setswap(false);

Timer timer = Timer(time, bind(&Solver::timedout, this));
int starttime = time_msec();
Expand Down

0 comments on commit 1af5df8

Please sign in to comment.