public Pair execute(State state)
        {
            //Debug.Log("REST");


            //MUDAR HP, ENERGY
            //ja sabemos q podemos fazer
            int key = LearningCharacter.toKeyState(
                Math.Max(state.getHp() - 1, 0),
                Math.Min(LearningCharacter.max_energy, state.getEnergy() + 2),
                state.getCharacterPosition().z_index,
                state.getCharacterPosition().x_index);

            if (!LearningCharacter.all_states.ContainsKey(key))
            {
                Debug.Log("error key not found: hp: " + Math.Max(state.getHp() - 1, 0) + "\n" +
                          "mp: " + (Math.Min(LearningCharacter.max_energy, state.getEnergy() + 2)) + "\n" +
                          "z: " + (state.getCharacterPosition().z_index) + "\n" +
                          "x: " + state.getCharacterPosition().x_index);
            }

            //new state
            State new_state = LearningCharacter.all_states[key];

            Pair pair = new Pair();

            pair.setNewState(new_state);
            pair.setReward(calculateReward(state));

            return(pair);
        }
Beispiel #2
0
        public Pair execute(State state)
        {
            //Debug.Log("RIGHT");


            //ja sabemos q podemos fazer
            int key = LearningCharacter.toKeyState(
                state.getHp() - 1,
                state.getEnergy() - 1,
                state.getCharacterPosition().z_index,
                state.getCharacterPosition().x_index + 1);

            if (!LearningCharacter.all_states.ContainsKey(key))
            {
                Debug.Log("error key not found: hp: " + (state.getHp() - 1) + "\n" +
                          "mp: " + (state.getEnergy() - 1) + "\n" +
                          "z: " + (state.getCharacterPosition().z_index) + "\n" +
                          "x: " + (state.getCharacterPosition().x_index + 1));
            }

            //new state
            State new_state = LearningCharacter.all_states[key];

            Pair pair = new Pair();

            pair.setNewState(new_state);
            pair.setReward(calculateReward(state));

            return(pair);
        }