Exemplo n.º 1
0
    void LookForPreys()
    {
        var preyList = new List <GameObject>();

        foreach (var pathfinder in All)
        {
            if (pathfinder != null && pathfinder is Prey)
            {
                preyList.Add(pathfinder.gameObject);
                var prey = (Prey)pathfinder;
                if (prey2MemoryDuration.ContainsKey(prey))
                {
                    prey2MemoryDuration[prey] -= Time.deltaTime;
                }
            }
        }

        foreach (var preyObj in seenPreyList)
        {
            if (preyObj != null)
            {
                Utils.ModifyAlpha(preyObj.GetComponent <Renderer>(), 1f);
            }
        }
        seenPreyList = SensorySystem.Sight2(float.MaxValue, transform.position, transform.forward, 90f, preyList);
        foreach (var preyObj in seenPreyList)
        {
            Utils.ModifyAlpha(preyObj.GetComponent <Renderer>(), 0.2f);
            var prey = preyObj.GetComponent <Prey>();
            if (prey2MemoryDuration.ContainsKey(prey))
            {
                prey2MemoryDuration[prey] = memoryTime;
            }
        }
    }
Exemplo n.º 2
0
        private void InitializeSenses(SequentialMessageQueue <GameManager> queue)
        {
            Add <SensorComponent>(EntityComponent.Sensor, poolSize: 32);

            SensorySystem = new SensorySystem();
            queue.Add <TraveledMessage>(SensorySystem, TravelSystem.TraveledMessageName, 3);
            queue.Add <EntityAddedMessage <GameEntity> >(SensorySystem, Beings.GetEntityAddedMessageName(), 1);
        }
    public Animal(string objectType, string index, Genome motherGenome, Genome fatherGenome, Vector3 spawn)
        : base(objectType, index, motherGenome, fatherGenome, spawn, true)
    {
        InitBodyControl(spawn);

        driveSystem   = new DriveSystem(this);
        sensorySystem = new SensorySystem(this);
        InitBrain();
    }
Exemplo n.º 4
0
 void Awake()
 {
     _sensorySystem = GetComponentInParent <SensorySystem>();
     if (_sensorySystem == null)
     {
         throw new Exception("SensorySystem required to be a parent of VisionComponent");
     }
     _sensorySystem.RegisterEvent(new SensorySystem.ObserveEnterEvent());
     _sensorySystem.RegisterEvent(new SensorySystem.ObserveExitEvent());
 }
 public NeuralAI(Animal animal, Body body, DriveSystem drives, MotorSystem motor, SensorySystem senses, Phenotype phenotype) :
     base(body, drives, motor, senses, phenotype)
 {
     InitNetworkLayerInfoDict();
     InitLayers();
     InitConnections();
     GetOutputConnectionDict();
     InitInputs();
     InitOutputs();
     Feedforward();
 }
Exemplo n.º 6
0
    private void Awake()
    {
        if (_domainDefinition == null)
        {
            Debug.LogError($"Missing domain definition in {name}!");
            gameObject.SetActive(false);
            return;
        }

        _planner = new Planner <AIContext>();
        _context = new AIContext(this, _senses, _head, GetComponent <Animator>(), GetComponent <NavMeshAgent>());
        _sensory = new SensorySystem(this);

        _domain = _domainDefinition.Create();
    }
Exemplo n.º 7
0
    protected override void SetUp( )
    {
        sensorySystem = this.GetComponent <SensorySystem>();
        blackBoard    = this.GetComponent <BlackBoard>();
        blackBoard.variables.Add("enemiesInSight", new List <Agent>());
        blackBoard.variables.Add("alliesInSight", new List <Agent>());
        blackBoard.variables.Add("Target", new GameObject());

        if (defaultRuta != null)
        {
            blackBoard.variables.Add("Ruta", defaultRuta.path);
        }
        else
        {
            blackBoard.variables.Add("Ruta", new List <Transform>());
        }
    }
Exemplo n.º 8
0
    public AI(Body body, DriveSystem drives, MotorSystem motor, SensorySystem senses, Phenotype phenotype)
    {
        bodyStates         = body.GetStates();
        bodyStateLabelList = body.GetStateLabels();
        bodyStateIndexDict = body.GetStateIndices();
        gameobject         = body.GetGameObject();

        driveStates         = drives.GetStates();
        driveStateLabelList = drives.GetStateLabels();
        driveStateIndexDict = drives.GetStateIndices();

        actionStates         = motor.GetStates();
        actionStateLabelList = motor.GetStateLabels();
        actionStateIndexDict = motor.GetStateIndices();

        traits         = phenotype.GetTraits();
        traitLabelList = phenotype.GetTraitLabels();
        traitIndexDict = phenotype.GetTraitIndices();

        visualInput = senses.GetVisualInput();
    }
Exemplo n.º 9
0
 public SimpleAI(Animal animal, Body body, DriveSystem drives, MotorSystem motor, SensorySystem senses, Phenotype traits) :
     base(body, drives, motor, senses, traits)
 {
     thisAnimal = animal;
     //InitGoalDict();
 }