public void run() {	
		ar.configure(ClientActionRobot.intToByteArray(id));
		//load the initial level (default 1)
		ar.loadLevel();
		GameState state;
		while (true) {
			
			state = solve();
			
			//If the level is solved , go to the next level
			if (state == GameState.WON) {
							
				System.out.println(" loading the level " + (currentLevel + 1) );
				ar.loadLevel(++currentLevel);

				//display the global best scores
				int[] scores = ar.checkScore();
				System.out.println("The global best score: ");
				for (int i = 0; i < scores.length ; i ++)
				{
			
				    	  System.out.print( " level " + (i+1) + ": " + scores[i]);
				}
				System.out.println();
				System.out.println(" My score: ");
				scores = ar.checkMyScore();
				for (int i = 0; i < scores.length ; i ++)
				{
				   
				    	  System.out.print( " level " + (i+1) + ": " + scores[i]);
				}
				System.out.println();
				// make a new trajectory planner whenever a new level is entered
				tp = new TrajectoryPlanner();

				// first shot on this level, try high shot first
				firstShot = true;
				
			} else 
				//If lost, then restart the level
				if (state == GameState.LOST) {
				System.out.println("restart");
				ar.restartLevel();
			} else 
				if (state == GameState.LEVEL_SELECTION) {
				System.out.println("unexpected level selection page, go to the last current level : "
								+ currentLevel);
				ar.loadLevel(currentLevel);
			} else if (state == GameState.MAIN_MENU) {
				System.out
						.println("unexpected main menu page, reload the level : "
								+ currentLevel);
				ar.loadLevel(currentLevel);
			} else if (state == GameState.EPISODE_MENU) {
				System.out.println("unexpected episode menu page, reload the level: "
								+ currentLevel);
				ar.loadLevel(currentLevel);
			}

		}

	}