예제 #1
0
        private Moves HoldGround()
        {
            Moves move = Moves.NO_ACTION;

            // bananas
            if (this.agentStatus.MOVING_LEFT > Utils.Quantifier.NONE)
            {
                move = Moves.ROLL_RIGHT;
            }
            else if (this.agentStatus.MOVING_RIGHT > Utils.Quantifier.NONE)
            {
                move = Moves.ROLL_LEFT;
            }

            Log.LogInformation("HOLD_GROUND");
            Log.LogInformation(this.agentStatus.ToString());
            Log.LogInformation(move.ToString());
            return(move);
        }
예제 #2
0
        //TODO If near Obstacle, but still below, doesnt jump
        private Moves JumpOnto(ObstacleRepresentation obstacle)
        {
            Moves move = Moves.NO_ACTION;

            Status statusCircle = new Status();

            statusCircle.Update(this.circleInfo, this.rectangleInfo, obstacle, AgentType.Circle);

            Utils.Quantifier Distance_From_Obstacle;
            Moves            Roll_To_Obstacle;
            Moves            Roll_Away_From_Obstacle;

            Utils.Direction Direction_To_Get_To_Obstacle;

            if (statusCircle.LEFT_FROM_TARGET == Utils.Quantifier.NONE) //Circle is on the obstacle's right side
            {
                Distance_From_Obstacle       = statusCircle.RIGHT_FROM_TARGET;
                Roll_To_Obstacle             = Moves.ROLL_LEFT;
                Roll_Away_From_Obstacle      = Moves.ROLL_RIGHT;
                Direction_To_Get_To_Obstacle = Utils.Direction.LEFT;
            }
            else if (statusCircle.RIGHT_FROM_TARGET == Utils.Quantifier.NONE)//Circle is on the obstacle's left side
            {
                Distance_From_Obstacle       = statusCircle.LEFT_FROM_TARGET;
                Roll_To_Obstacle             = Moves.ROLL_RIGHT;
                Roll_Away_From_Obstacle      = Moves.ROLL_LEFT;
                Direction_To_Get_To_Obstacle = Utils.Direction.RIGHT;
            }
            else //Circle is vertically aligned with obstacle
            {
                Distance_From_Obstacle       = Utils.Quantifier.NONE;
                Roll_To_Obstacle             = Moves.NO_ACTION;
                Roll_Away_From_Obstacle      = Moves.NO_ACTION;
                Direction_To_Get_To_Obstacle = Utils.Direction.RIGHT; //Default, not gonna be used
            }

            if (statusCircle.MOVING_TOWARDS_TARGET == Utils.Quantifier.NONE) //When circle is not moving towards the target
            {
                if (statusCircle.NEAR_TARGET)
                {
                    if (statusCircle.ABOVE_TARGET == Utils.Quantifier.SLIGHTLY) //Already Above target
                    {
                        move = Moves.NO_ACTION;
                    }
                    else //Has to roll away from target to gain speed to jump
                    {
                        if (Distance_From_Obstacle == Utils.Quantifier.NONE) //Is directly below target
                        {
                            //TODO CIRCLE MUST FIND A WAY TO TRY TO POSITION HIMSELF TO JUMP
                            move = Moves.NO_ACTION; //TODO PROVISIONAL
                        }
                        else
                        {
                            move = Roll_Away_From_Obstacle;
                        }
                    }
                }
                else //Circle has to start moving in the obstacle's direction, because is far away
                {
                    move = Roll_To_Obstacle;
                }
            }
            else //When the circle is moving towards the target
            {
                if (Distance_From_Obstacle == Utils.Quantifier.SLIGHTLY) //when the circle has to jump now
                {
                    move = Moves.JUMP;
                }
                else if (Distance_From_Obstacle > Utils.Quantifier.A_BIT) //When the circle is very far away, and has to go fast
                {
                    move = Roll(Direction_To_Get_To_Obstacle, Utils.Quantifier.A_BIT);
                }
                else if (Distance_From_Obstacle > Utils.Quantifier.SLIGHTLY) //When the circle is almost in the jumping spot
                {
                    move = Roll(Direction_To_Get_To_Obstacle, Utils.Quantifier.SLIGHTLY);
                }
                else //When an error occurs
                {
                    move = Moves.NO_ACTION;
                }
            }

            Log.LogInformation("JUMP_ONTO");
            Log.LogInformation(statusCircle.ToString());
            Log.LogInformation(move.ToString());
            return(move);
        }