@Override
	/**
	 * Issues actions to units
	 *@param gs the game state
	 *@param time_limit how much time is given for this turn (msec)
	 */
	public void getAction(GameState gs, int time_limit) {
		turn_start = System.currentTimeMillis();
		turn_limit = time_limit;
		state = gs;
		
		current_turn++;
		
		if (!init) {
			initialize();
		}
		
		update_unit_list();
		
		traffic_map.update(current_turn);
		
		production_manager.update(this);
		farm_manager.update(this);
		attack_manager.update(this);
		exploration_manager.update(this);
		town_manager.update(this);
		
		production_manager.manage_units(this);
		farm_manager.manage_units(this);
		town_manager.manage_units(this);
		attack_manager.manage_units(this);
		exploration_manager.manage_units(this);
		
		// execute unit orders
		boolean finished = true;
		boolean builders = false;
		for (int i = last_unit; i < units.size(); i++) {
			if (System.currentTimeMillis()-turn_start > turn_limit) {
//				System.out.println(player_id+" out of time on turn "+current_turn);
				last_unit = i;
				builders = false;
				finished = false;
				break; // out of time
			}
			units.get(i).act(this);
			if (units.get(i).stats.hasAction() && units.get(i).stats.getAction().getType() == UnitAction.BUILD) {
				builders = true;
			}
		}
		if (finished) {
			last_unit = 0;
		}
		if (!builders) {
			for (int i = 0; i < money.size(); i++) {
				money.set(i, state.getResources(i));
			}
		}
	}