/**
     * Picks an action. This function is called every game step to request an
     * action from the player. The action returned must be contained in the
     * actions accessible from stateObs.getAvailableActions(), or no action
     * will be applied.
     * Multi player method.
     * @param stateObs Observation of the current state.
     * @param elapsedTimer Timer when the action returned is due.
     * @return An action for the current state
     */
    public VGDLAvatarActions act(StateObservationMulti stateObs, ElapsedCpuTimer elapsedTimer)
    {
        lastGameObservation = stateObs;

        if (lastVectorAction == null || lastVectorAction.Length < 1)
        {
            return(VGDLAvatarActions.ACTION_NIL);
        }

        return((VGDLAvatarActions)Mathf.RoundToInt(lastVectorAction[0]));
    }
    /**
     * Function called when the game is over. This method must finish before CompetitionParameters.TEAR_DOWN_TIME,
     *  or the agent will be DISQUALIFIED
     * @param stateObs the game state at the end of the game
     * @param elapsedCpuTimer timer when this method is meant to finish.
     */
    public void result(StateObservationMulti stateObs, ElapsedCpuTimer elapsedCpuTimer)
    {
        Done();

        var diff = stateObs.getGameScore(PlayerID) - lastScore;

        AddReward(diff);
        lastScore           = stateObs.getGameScore(PlayerID);
        lastGameObservation = stateObs;

        //SetReward(stateObs.getGameScore(PlayerID));
    }
Exemple #3
0
    /**
     * Picks an action. This function is called every game step to request an
     * action from the player.
     * @param stateObs Observation of the current state.
     * @param elapsedTimer Timer when the action returned is due.
     * @return An action for the current state
     */
    public override VGDLAvatarActions act(StateObservationMulti stateObs, ElapsedCpuTimer elapsedTimer)
    {
        var action = actions[actionIdx];

        actionIdx++;

        var remaining = elapsedTimer.remainingTimeMilliseconds();

        while (remaining > 1)
        {
            //This allows visualization of the replay.
            remaining = elapsedTimer.remainingTimeMilliseconds();
        }

        return(action);
    }
    public override VGDLAvatarActions act(StateObservationMulti stateObs, ElapsedCpuTimer elapsedTimer)
    {
        //int id = (getPlayerID() + 1) % stateObs.getNoPlayers();
        var keyhandler = stateObs.getKeyHandler(PlayerID);

        var move  = keyhandler.ProcessPlayerMovement(PlayerID);
        var useOn = keyhandler.ProcessUseInput(PlayerID);


        //In the keycontroller, move has preference.
        VGDLAvatarActions action = AvatarAction.fromVector(move);

        if (action == VGDLAvatarActions.ACTION_NIL && useOn)
        {
            action = VGDLAvatarActions.ACTION_USE;
        }

        return(action);
    }
Exemple #5
0
 public override VGDLAvatarActions act(StateObservationMulti stateObs, ElapsedCpuTimer elapsedTimer)
 {
     return(stateObs.getAvailableActions().RandomElement());
 }
Exemple #6
0
    public StateObservationMulti copy()
    {
        StateObservationMulti copyObs = new StateObservationMulti(model.copy(), this.playerID);

        return(copyObs);
    }
Exemple #7
0
 public void result(StateObservationMulti stateObs, ElapsedCpuTimer elapsedCpuTimer)
 {
 }
Exemple #8
0
 /**
  * Picks an action. This function is called every game step to request an
  * action from the player. The action returned must be contained in the
  * actions accessible from stateObs.getAvailableActions(), or no action
  * will be applied.
  * Multi player method.
  * @param stateObs Observation of the current state.
  * @param elapsedTimer Timer when the action returned is due.
  * @return An action for the current state
  */
 public abstract VGDLAvatarActions act(StateObservationMulti stateObs, ElapsedCpuTimer elapsedTimer);