 // square status
 int redStatus [] = {0,0,0,0,0,0,0,0,0};
 int greenStatus [] = {0,0,0,0,0,0,0,0,0};
+int previousGreenStatus [] = {0,0,0,0,0,0,0,0,0};
 
 // conditions for victory
 int winConditions [][9] = {{1,1,1,0,0,0,0,0,0},

  while(doLoop){
    if (display.buttonsChanged()) {
      byte reply = display.getButtons();
      if ((reply & 0x04) == 0x00){
          doLoop = false;
      }
    }  
  }
  display.clear();
  display.printText("Starting new game!", 6, 1, GREEN);
  
  
}

/**********************************************
 *   GAME INITIALIZATION WITH THE SERVER
 **********************************************/

int findPlayer(int player_id){
  //TODO
  Serial.println("finding player");
  return 113;

}



/**********************************************
 *   GAME LOGIC
 **********************************************/
 
int checkPlayerMove(){
  int totalMoves = 0;
  int player_move = 0;
  char color;
  for(int i = 0; i < 9; i++){
    color = squares[i]->checkColor();
    if (previousGreenStatus[i] != greenStatus[i]){
      totalMoves++;
      player_move = i+1;
    }
  }
  
  if (totalMoves == 0) {
    // The player has not done any move
    player_move = 0;
  } else if (totalMoves > 1) {
    // The player has moved 2 pieces, which is an illegal move
    player_move = -1;
  }
  else if (color == 'r'){
    // The player has moved his piece into an square already used by the rival
    player_move = -2;
  }
  
  return player_move;
  
}


void updateBoardStatus(){
  for (int i=0; i < 9; i++){
    char color = squares[i]->checkColor();
    if (color == 'g'){
      squares[i]->setGreen();
      greenStatus[i] = 1;
    }
  }
}

void updateColorStatus(){
  for (int i=0; i < 9; i++){
