Ejemplo n.º 1
0
        //Two basic functions for the Monster engine
        actionDecision think(Enemy monster)
        {
            float[] ratings = new float[(int)actionDecision.NUM_ACTIONS];
            int     dist_x  = game_state.local_player.getX() - monster.getX();
            int     dist_y  = game_state.local_player.getY() - monster.getY();

            int Dp  = GetRating(Math.Sqrt(Math.Pow(dist_x, 2) + Math.Pow(dist_y, 2)), 800.0f);
            int Db  = 0; //Bullet system not in yet
            int Alg = 0;

            if (Math.Abs(dist_x) < Math.Abs(dist_y))
            {
                Alg = GetRating(Math.Abs(dist_x), 400);
            }
            else
            {
                Alg = GetRating(Math.Abs(dist_y), 240);
            }

            int Hlt = GetRating(monster.getHealth(), monster.getMaxHealth());

            actionDecision retval    = actionDecision.FLEE;
            float          max_value = 0;

            for (int i = 0; i < (int)actionDecision.NUM_ACTIONS; ++i)
            {
                ratings[i] =
                    decision_matrix[(int)monster.getType(), i, (int)actionFactor.DP] * Dp +
                    decision_matrix[(int)monster.getType(), i, (int)actionFactor.DB] * Db +
                    decision_matrix[(int)monster.getType(), i, (int)actionFactor.AL] * Alg +
                    decision_matrix[(int)monster.getType(), i, (int)actionFactor.HL] * Hlt;

                if (ratings[i] > max_value)
                {
                    retval    = (actionDecision)i;
                    max_value = ratings[i];
                }
            }

            if (max_value < 5)
            {
                return(actionDecision.IDLE);
            }
            return(retval);
        }
Ejemplo n.º 2
0
        //Two basic functions for the Monster engine
        actionDecision think(Enemy monster)
        {
            float[] ratings = new float[(int)actionDecision.NUM_ACTIONS];
            int dist_x = game_state.local_player.getX() - monster.getX();
            int dist_y = game_state.local_player.getY() - monster.getY();

            int Dp = GetRating(Math.Sqrt(Math.Pow(dist_x, 2) + Math.Pow(dist_y, 2)), 800.0f);
            int Db = 0; //Bullet system not in yet
            int Alg = 0;
            if (Math.Abs(dist_x) < Math.Abs(dist_y))
            {
                Alg = GetRating(Math.Abs(dist_x), 400);
            }
            else
            {
                Alg = GetRating(Math.Abs(dist_y), 240);
            }

            int Hlt = GetRating(monster.getHealth(), monster.getMaxHealth());

            actionDecision retval = actionDecision.FLEE;
            float max_value = 0;

            for (int i = 0; i < (int)actionDecision.NUM_ACTIONS; ++i)
            {
                ratings[i] =
                    decision_matrix[(int)monster.getType(), i, (int)actionFactor.DP]*Dp +
                    decision_matrix[(int)monster.getType(), i, (int)actionFactor.DB]*Db +
                    decision_matrix[(int)monster.getType(), i, (int)actionFactor.AL]*Alg +
                    decision_matrix[(int)monster.getType(), i, (int)actionFactor.HL]*Hlt;

                if (ratings[i] > max_value)
                {
                    retval = (actionDecision)i;
                    max_value = ratings[i];
                }
            }

            if (max_value < 5)
            {
                return actionDecision.IDLE;
            }
            return retval;
        }