Skip to content

Commit

Permalink
fixed small bug on updating open book for each new move
Browse files Browse the repository at this point in the history
  • Loading branch information
spchuang committed Jul 6, 2013
1 parent eef498c commit 461cc9a
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 5 deletions.
19 changes: 19 additions & 0 deletions AugmentedRealityGo/ARGraphicController.cpp
Expand Up @@ -353,6 +353,25 @@ void ARGraphicController::gl_idle_func()

//release frame data
frameImg = cv::Mat();


if(board->newMoveIsMade)
{
switch(assistant_mode){
case A_MODE_NONE:
break;
case A_MODE_FUEGO_BOOK:

fuego->getBookPositions();
break;
case A_MODE_TERRITORY:
fuego->estimateTerritory(board->getMoveTurnColor());
break;
}
board->newMoveIsMade = false;
}


glutPostRedisplay();
}else
Sleep(1); // don't be a CPU hog
Expand Down
10 changes: 7 additions & 3 deletions AugmentedRealityGo/GamePlayUtils/FuegoAssistant.cpp
Expand Up @@ -36,6 +36,7 @@ FuegoAssistant::FuegoAssistant()

setTerritoryParam = false;
prevMove = "none";

for(int i=0; i<19*19; i++)
{
estimateScore.push_back(0);
Expand Down Expand Up @@ -124,11 +125,13 @@ bool FuegoAssistant::estimateTerritory(int color)
getline(readFromFuego, readLine);

cout<<"return: "<<endl<<readLine<<endl<<"END"<<endl;
cout <<"is this okay?"<<endl;
split(readLine, l, ' ');

cout <<"size: "<< l.size()<<endl;
for(int j=0; j<l.size(); j++)
for(int z=0; z<l.size(); z++)
{
cout <<j << " : " << l[j] <<endl;
cout <<z << " : " << l[z] <<endl;

}

Expand Down Expand Up @@ -163,7 +166,8 @@ void FuegoAssistant::addMove(std::string move, int color){
getline(readFromFuego, readLine);
}while(readLine[0]!='=');

getBookPositions();

//getBookPositions();
}

bool FuegoAssistant::getBookPositions()
Expand Down
1 change: 1 addition & 0 deletions AugmentedRealityGo/GamePlayUtils/FuegoAssistant.h
Expand Up @@ -33,6 +33,7 @@ class FuegoAssistant
//public variables
static std::vector<int> bookMoves;
static std::vector<float> estimateScore;

private:

static boost::process::child c;
Expand Down
4 changes: 3 additions & 1 deletion AugmentedRealityGo/GamePlayUtils/GoBoard.cpp
@@ -1,6 +1,7 @@
#include "GoBoard.h"

FuegoAssistant* GoBoard::fuego;
bool GoBoard::newMoveIsMade;
GoBoard::GoBoard(FuegoAssistant* f)
{
fuego = f;
Expand All @@ -10,6 +11,7 @@ GoBoard::GoBoard(FuegoAssistant* f)
wrongRealStones[i] = 2;
}
currentMoveColor = COLOR_WHITE;
newMoveIsMade = false;
}

void GoBoard::clear_board()
Expand All @@ -35,7 +37,7 @@ void GoBoard::changeTurn()
currentMoveColor = COLOR_BLACK;
else if(currentMoveColor == COLOR_BLACK)
currentMoveColor = COLOR_WHITE;

newMoveIsMade = true;
}

void GoBoard::addVirtualStone(std::string move, std::string color)
Expand Down
2 changes: 1 addition & 1 deletion AugmentedRealityGo/GamePlayUtils/GoBoard.h
Expand Up @@ -28,7 +28,7 @@ class GoBoard
volatile char virtualStones[361];
volatile char wrongRealStones[361];
volatile int newMoveIndex;

static bool newMoveIsMade;
static FuegoAssistant* fuego;
private:
int currentMoveColor;
Expand Down
1 change: 1 addition & 0 deletions AugmentedRealityGo/GamePlayUtils/Helper.h
Expand Up @@ -57,6 +57,7 @@ static unsigned int split(const std::string &txt, std::vector<std::string> &strs

// Decompose statement
while( pos != std::string::npos ) {
std::cout<<"substr: "<< txt.substr( initialPos, pos - initialPos + 1 ) <<std::endl;
strs.push_back( txt.substr( initialPos, pos - initialPos + 1 ) );
initialPos = pos + 1;

Expand Down

0 comments on commit 461cc9a

Please sign in to comment.