//get the next action according to the plan and the agent state
        private void getAction()
        {
            currentAction = controller.computeAction(pathPlan.getPathPoints()[0], circleInfo.VelocityX, circleInfo.X, circleInfo.Y, timestep.ElapsedMilliseconds * 0.001f, acceleration);
            timestep.Restart();
            if (currentAction == Moves.JUMP)
            {
                jumpPerformed = true;
            }

            //change to next point when a point is reached or when a jump was performed
            if (!correctRRT && controller.rollReached)
            {
                lastMove = pathPlan.getPathPoints()[0].getAction();

                if (firstAction3)
                {
                    firstAction3 = false;
                }
                else
                {
                    pathPlan.nextPoint();
                }

                if (pathPlan.getPathPoints().Count == 0)
                {
                    lastAction = true;
                }

                if (controller.jumpReached)
                {
                    justJumped = true;
                }
                else if (justJumped)
                {
                    justJumped = false;
                }
                controller.jumpReached = false;
                controller.rollReached = false;
                remainingActions--;
                gameTime.Restart();
                timestep.Restart();
            }
            else if (firstAction2)
            {
                firstAction2 = false;
                firstAction3 = true;
                pathPlan.getOriginalPoints()[pathPlan.getCurrentPoint()].passedThrough();
            }
        }
Esempio n. 2
0
        //get the next action according to the plan and the agent state
        private void getAction()
        {
            acceleration = getAcceleration();
            var timeStep = timestep.ElapsedMilliseconds * 0.001f;

            if (timeStep < 0.001f)
            {
                timeStep = 0.001f;
            }
            currentAction = controller.computeAction(pathPlan.getPathPoints()[0], rectangleInfo.VelocityX, rectangleInfo.VelocityY, rectangleInfo.X, rectangleInfo.Y, timeStep, acceleration);

            timestep.Restart();

            //change to next point when a point is reached or when a jump was performed
            if (!correctRRT && (controller.slideReached || controller.morphReached))
            {
                lastMove = pathPlan.getPathPoints()[0].getAction();

                if (firstAction3)
                {
                    firstAction3 = false;
                }
                else
                {
                    pathPlan.nextPoint();
                }

                if (pathPlan.getPathPoints().Count == 0)
                {
                    lastAction = true;
                }

                controller.slideReached = false;
                controller.morphReached = false;
                remainingActions--;
                gameTime.Restart();
                timestep.Restart();
            }
            else if (firstAction2)
            {
                firstAction2 = false;
                firstAction3 = true;
                pathPlan.getOriginalPoints()[pathPlan.getCurrentPoint()].passedThrough();
            }
        }