   sendMsg(MSG_REGISTER + player_id + END_CHAR);
 }
 
-String findPlayer(){
-  //TODO
-  // rival_id = send ("REGISTER " + player_id)
-  // returns the rival_id and who starts playing
-  // REGISTER ####
-  // ##### -> first 4 numbers is the rival id and the 5th is who plays first. 0 the player and 1 the rival
-  return "10020";
-
+void findPlayer(){
+  boolean notFound = true;
+  while(notFound){
+    String res = sendAndWait(MSG_FIND_GAME + player_id + END_CHAR);
+    String command = getCommand(res);
+    
+    // if waiting_for_player -> delay 100
+    // if not_registered -> register
+    // if rival -> set start_turn, set rival_id, notFound = false
+    if (command == CMD_WAIT_FOR_RIVAL){
+      delay(1000);
+    } else if (command == CMD_NOT_REGISTERED){ // This shouldn't happen
+      registerPlayer();
+    } else if (command == CMD_RIVAL){
+      String parameters = getParameters(res);
+      rival_id = getParameter(parameters, 1);
+      start_turn = getParameter(parameters, 2);
+      notFound = false;
+    }
+  }
 }
 
 int getMove(){

#define VICTORY_LOOP 0x3 //Victory loop!!!
#define NO_NO 0x4 //Illegal move

//Communication msgs
String MSG_REGISTER = "REGISTER"; // id
String MSG_FIND_GAME = "FIND_GAME"; // id
String MSG_DO_MOVE =  "DO_MOVE"; // id movement(0..8)
String MSG_GET_MOVE = "GET_MOVE"; // id
String END_CHAR = "\0d"; // id


// Baseboard screen

    }
  }
  
  if ((turn > 0) || (turn == 0 && start_turn=="1")){
    // ************************************************************************
    // ******* Rival turn *****************************************************
    // ************************************************************************
