Ejemplo n.º 1
0
    private void Awake()
    {
        resetButton.onClick.AddListener(() => onResetClicked());

        sensorsCountController.Setup(20, 2, 1);
        sensorsCountController.SetValue(1);
        sensorsCountController.OnValueChanged += onSensorsCountValueChanged;

        hiddenLayerNeuronsCountController.Setup(20, 1, 1);
        hiddenLayerNeuronsCountController.SetValue(1);
        hiddenLayerNeuronsCountController.OnValueChanged += hiddenLayerNeuronsCountValueChanged;

        angleBetweenForwardVectorAndMovementDirectionInputToggle.OnValueChanged += onToggleValueChanged;
        velocityInputToggle.OnValueChanged   += onToggleValueChanged;
        torqueInputToggle.OnValueChanged     += onToggleValueChanged;
        steerAngleInputToggle.OnValueChanged += onToggleValueChanged;

        torqueOutputToggle.OnValueChanged     += onToggleValueChanged;
        steerAngleOutputToggle.OnValueChanged += onToggleValueChanged;
        handbrakeOutputToggle.OnValueChanged  += onToggleValueChanged;
    }
Ejemplo n.º 2
0
    private void Awake()
    {
        resetCarsPositions.onClick.AddListener(() => onResetCarsPositionsButtonClicked());
        resetAllCars.onClick.AddListener(() => onResetAllCarsClicked());

        showSensorsToggle.onValueChanged.AddListener((value) => onShowSensorValueChanged(value));
        crossbreedSensorsToggle.onValueChanged.AddListener((value) => onCrossbreedSensorsToggleValueChanged(value));
        disableCarsOnWallHit.onValueChanged.AddListener((value) => onDisableCarsOnWallHitValueChanged(value));
        adaptiveMutationProbabilityToggle.onValueChanged.AddListener((value) => onAdaptiveMutationProbabilityToggleValueChanged(value));
        multiplyDistanceByVelocity.onValueChanged.AddListener((value) => onMultiplyDistanceByVelocityValueChanged(value));
        explosionsToggle.onValueChanged.AddListener((value) => onExpolosionsToggleValueChanged(value));

        sensorsLengthController.OnValueChanged         += onSensorLengthValueChanged;
        angleBetweenSensorsController.OnValueChanged   += onAngleBetweenSensorsValueChanged;
        mutationProbabilityController.OnValueChanged   += onMutationProbabilityValueChanged;
        totalCarsCountController.OnValueChanged        += totalCarsCountValueChanged;
        newRandomCarsEveryGenController.OnValueChanged += newRandomCarsValueChanged;

        sensorsLengthController.Setup(MAX_SENSOR_LENGTH, MIN_SENSORS_LENGTH, SENSOR_LENGTH_D);
        angleBetweenSensorsController.Setup(MAX_ANGLE_BETWEEN_SENSORS, MIN_ANGLE_BEETWEEN_SENSORS, ANGLE_D);
        mutationProbabilityController.Setup(MAX_MUTATION_PROBABILITY, MIN_MUTATION_PROBABILITY, MUTATION_PROBABILITY_D);
        totalCarsCountController.Setup(100, 10, 1);
        newRandomCarsEveryGenController.Setup(10, 0, 1);

        multiplyDistanceByVelocity.isOn = geneticsManager.FitnessType == FitnessType.DIST_MUL_SPEED;
        crossbreedSensorsToggle.isOn    = geneticsManager.CrossbreedSensors;
        sensorsLengthController.SetValue(geneticsManager.SensorsLength);
        angleBetweenSensorsController.SetValue(geneticsManager.AngleBetweenSensors);
        onCrossbreedSensorsToggleValueChanged(geneticsManager.CrossbreedSensors);
        disableCarsOnWallHit.isOn = geneticsManager.DisableOnWallHit;
        adaptiveMutationProbabilityToggle.isOn = geneticsManager.AdaptiveMutationProbability;
        onAdaptiveMutationProbabilityToggleValueChanged(geneticsManager.AdaptiveMutationProbability);
        newRandomCarsEveryGenController.SetValue(geneticsManager.NewRandomCarsCount);
        totalCarsCountController.SetValue(geneticsManager.CarsCount);
        explosionsToggle.isOn = geneticsManager.Explosions;

        mutationProbabilityController.Format = "0.00";

        timeScaleController.OnValueChanged += onTimeScaleValueChanged;
        timeScaleController.SetValue(TimeScaleController.TargetTimeScale);

        RefreshViews();
    }
Ejemplo n.º 3
0
 public void RefreshViews()
 {
     generationText.text = "GENERATION " + geneticsManager.Generation.ToString("D3");
     mutationProbabilityController.SetValue(geneticsManager.MutationProbability);
 }