public void getAction(GameState gs, int time_limit) {
    	//MAXSIMULATIONTIME = time_limit;
    	
    	PlayerActionGenerator pag;
		pag = new PlayerActionGenerator(gs);
		if (pag.choices.size() > 0) {
	        List<PlayerAction> l = new LinkedList<PlayerAction>();
	        {
	            PlayerAction pa = null;
	            do{
					pa = pag.getNextAction(-1);
					if (pa!=null) l.add(pa);
	            }while(pa!=null);
	            max_actions_so_far = Math.max(l.size(),max_actions_so_far);
	            //if (DEBUG>=1) System.out.println("MontCarloAI for player " + player + " chooses between " + l.size() + " actions [maximum so far " + max_actions_so_far + "] (cycle " + gs.getTime() + ")");
	        }
	                
	        PlayerAction best = null;
	        float best_score = 0;
	        int SYMS_PER_ACTION = NSIMULATIONS/l.size();
	        for(PlayerAction pa:l) {
	            float score = 0;
	            for(int i = 0;i<SYMS_PER_ACTION;i++) {
	            	Game g2 = new Game(gs, gs.getPlayerID(), time_limit, MAXSIMULATIONTIME);
	            	g2.addAgent(randomAI);
	            	g2.addAgent(randomAI);
	            	g2.play(gs.isFog());
	            	g2.pgs.current_player = gs.getPlayerID();
	            	g2.gs.update();
	                // Discount factor:
	                score += SimpleEvaluationFunction.evaluate(g2.gs)*Math.pow(0.99,g2.cycle/10.0);
	            }
	            if (best==null || score>best_score) {
	                best = pa;
	                best_score = score;
	            }
	            //if (DEBUG>=2) System.out.println("child " + pa + " explored " + SYMS_PER_ACTION + " Avg evaluation: " + (score/((double)NSIMULATIONS)));
	        }
		}
    }