void Start()
    {
        _robot_controller                    = GetComponent <RobotCarController>();
        _robot_controller.Driver             = new GoalieDriver(_robot_controller);
        _robot_controller.transform.rotation = Quaternion.Euler(0f, 90f, 0f);
        _robot_controller.IsGoalie           = true;
        Ball   = GameObject.Find("Soccer Ball");
        Goal   = (_robot_controller.Team.Team == TeamController.TEAM.RED) ? GameObject.Find("LeftRing") : GameObject.Find("RightRing");
        Config = GameObject.Find("ConfigurationHolder").GetComponent <ConfigurationHolder>();
        GoalieOutputYDistance yOutput = null;
        var category = new GoalieCategory(6);

        float goalOffset;

        switch (Config.c.NumberOfRobots)
        {
        case 3:
            _goalie_x_distance = new SmallGoalieXDistance(1);
            _goalie_y_distance = new SmallGoalieInputYDistance(2);
            _ball_x_distance   = new SmallGoalieXDistance(3);
            _ball_y_distance   = new SmallGoalieInputYDistance(4);
            yOutput            = new SmallGoalieOutputYDistance(5);
            goalOffset         = 15f;
            break;

        case 5:
            _goalie_x_distance = new MiddleGoalieXDistance(1);
            _goalie_y_distance = new MiddleGoalieInputYDistance(2);
            _ball_x_distance   = new MiddleGoalieXDistance(3);
            _ball_y_distance   = new MiddleGoalieInputYDistance(4);
            yOutput            = new MiddleGoalieOutputYDistance(5);
            goalOffset         = 20f;
            break;

        case 11:
            _goalie_x_distance = new LargeGoalieXDistance(1);
            _goalie_y_distance = new LargeGoalieInputYDistance(2);
            _ball_x_distance   = new LargeGoalieXDistance(3);
            _ball_y_distance   = new LargeGoalieInputYDistance(4);
            yOutput            = new LargeGoalieOutputYDistance(5);
            goalOffset         = 25f;
            break;

        default:
            goalOffset = 15f;
            break;
        }

        _strategizer = new GoalieStrategizer(_ball_x_distance, _goalie_x_distance, category);

        _strategy_1 = new GoalieStrategy(1, _ball_y_distance, _goalie_y_distance, yOutput);
        _strategy_2 = new GoalieStrategy(2, _ball_y_distance, _goalie_y_distance, yOutput);
        _strategy_3 = new GoalieStrategy(3, _ball_y_distance, _goalie_y_distance, yOutput);
        _strategy_4 = new GoalieStrategy(4, _ball_y_distance, _goalie_y_distance, yOutput);

        float goalX = Goal.transform.position.z;

        FixedX = goalX < 0 ? goalX + goalOffset : goalX - goalOffset;
    }
Exemplo n.º 2
0
        public GoalieStrategizer(GoalieXDistance ballDistance, GoalieXDistance goalieDistance, GoalieCategory category)
        {
            _ball_distance   = ballDistance;
            _goalie_distance = goalieDistance;
            _category        = category;

            _rule_base = new EvaluationTreeRuleBase(
                new List <FuzzySet <IInputFuzzyMember> >()
            {
                _ball_distance, _goalie_distance
            },
                category, CreateRules());

            _fls = new FuzzyLogicSystem(new Fuzzifier(), new CenterOfSumsDefuzzifier(), _rule_base);
        }