コード例 #1
0
ファイル: Program.cs プロジェクト: betasoftlabs/thebrain
 static void Main(string[] args)
 {
     Brain brain = new Brain();
     string diff = brain.diff("print(\"adsd 45\")", "print(\"asd 12223\")");
     Console.WriteLine(brain.GetPatterns(diff));
     Console.Read();
 }
コード例 #2
0
ファイル: TrainerCorrelation.cs プロジェクト: Bullshitzu/AHK
    public override bool Execute(Brain brain)
    {
        if (currentIteration == 0) {
            currentIteration++;
            StartIteration(currentIteration, brain);
        }

        currScore += Score(brain.Controller);

        timer += Time.deltaTime;

        if (timer >= timerMax) {

            EndIteration(currentIteration, brain);

            currentIteration++;
            if (currentIteration > iterationCount) return true;

            StartIteration(currentIteration, brain);

            currScore = 0;
            timer = 0;
        }

        return false;
    }
コード例 #3
0
ファイル: Wolf_eating.cs プロジェクト: Syclamoth/GamesAI6
    public override IEnumerator Enter(Machine owner, Brain controller)
    {
        mainMachine = owner;
        myBrain = controller;
        Legs myLeg = myBrain.legs;

        //get sheep target
        sheepTarget = myBrain.memory.GetValue<SensedObject>("hasCommand");

        sheepBrain = (Brain)sheepTarget.getObject().GetComponent("Brain");
        sheepMemory = sheepBrain.memory;
        sheepMemory.SetValue("BeingEaten", true);

        arriveBehaviour = new Arrive();

        arriveBehaviour.Init(myLeg);

        arriveBehaviour.setTarget(sheepTarget.getObject());

        //speed is zero
        myBrain.legs.maxSpeed = 0f;

        Debug.Log("I'm eating:" + sheepTarget.getObject() + " HP: " + sheepMemory.GetValue<float>("HP"));

        yield return null;
    }
コード例 #4
0
ファイル: TrainerBaseline.cs プロジェクト: Bullshitzu/AHK
    public override void Mutate(Brain brain)
    {
        foreach (Neuron currNeuron in brain.MainColumn) {
            foreach (Synapse currSynapse in currNeuron.InputSynapses) {
                currSynapse.multiplier = 0.01f;
            }
        }
        foreach (Neuron currNeuron in brain.Outputs) {
            foreach (Synapse currSynapse in currNeuron.InputSynapses) {
                currSynapse.multiplier = 0.01f;
            }
        }

        switch (currentIteration) {
            case 1:
                return;
            default:
                int synapseIndex = (currentIteration - 2) % brain.InputCount;

                brain.SimulateInput(synapseIndex);
                //SetIterationConstraints(synapseIndex, brain);

                return;
        }
    }
コード例 #5
0
ファイル: Sheep_roaming.cs プロジェクト: Syclamoth/GamesAI6
    public override IEnumerator Enter(Machine owner, Brain controller)
    {
        mainMachine = owner;
        myBrain = controller;
        Legs myLeg = myBrain.legs;

        arriveBehaviour = new PathfindToPoint();
        seekBehaviour = new Seek();

        arriveBehaviour.Init(myLeg,myBrain.levelGrid);
        seekBehaviour.Init(myLeg);

        myLeg.addSteeringBehaviour(arriveBehaviour);
        myLeg.addSteeringBehaviour(seekBehaviour);

        //set speed back to normal
        myBrain.legs.maxSpeed = 5f;

        if(firstActivation)
        {
            //set cowardLevel for sheep. Random.value returns a random number between 0.0 [inclusive] and 1.0 [inclusive].
            float coward = 0.5f;

            myBrain.memory.SetValue("cowardLevel", coward);
            myBrain.memory.SetValue("chasedBy", new List<Brain>());
            myBrain.memory.SetValue("BeingEaten", false);
            myBrain.memory.SetValue("HP", 100f);

            firstActivation = false;
        }

        time = 0f;
        seekingTime = 0f;
        yield return null;
    }
コード例 #6
0
ファイル: Solution.cs プロジェクト: JimLiaskos/TankChallenge
    public Solution()
    {
        _gameGrid = new Grid();
        _brain = new Brain(_gameGrid);

        // If you need initialization code, you can write it here!
    }
コード例 #7
0
ファイル: ANNTrainer.cs プロジェクト: Bullshitzu/AHK
    public virtual bool Execute(Brain brain)
    {
        // returns true if done
        if (currentIteration == 0) {
            currentIteration++;
            StartIteration(currentIteration, brain);
        }

        currScore += Score(brain.Controller);

        timer += Time.deltaTime;
        if (timer >= timerMax) {

            EndIteration(currentIteration, brain);

            currentIteration++;
            if (currentIteration > iterationCount) return true;

            StartIteration(currentIteration, brain);

            lastScore = currScore;
            currScore = 0;
            timer = 0;
        }

        return false;
    }
コード例 #8
0
ファイル: WolfHide.cs プロジェクト: Syclamoth/GamesAI6
    public override IEnumerator Run(Brain controller)
    {
        Vector2 playerPos = new Vector2(player.position.x, player.position.z);
        Vector2 playerFacing = new Vector2(player.forward.x, player.forward.z);
        Vector2 positionOffset = myBrain.legs.getPosition() - playerPos;

        if(Vector2.Dot(playerFacing.normalized, positionOffset.normalized) > 0.71f) {
            // Get out of the player's vision
            EscapeFromView();
        } else {
            // Stay out of the player's vision (get behind them if possible)
            StayOutOfView ();
        }

        //increase its decayHungryLevel when hunting
        if (controller.memory.GetValue<float>("hungryLevel") > 0f)
        {
            controller.memory.SetValue("hungryLevel", controller.memory.GetValue<float>("hungryLevel") - (decayHungryLevel * (myBrain.memory.GetValue<float>("ferocity") / 5)));
        }
        else
        {
            controller.memory.SetValue("hungryLevel", 0f);
            Debug.Log("I died because I used up my energy");
            myBrain.getGameObject().SetActiveRecursively(false);
        }

        if(hiddenTime > 5f * controller.memory.GetValue<Genome>("Genome").getGene("Cunning")) {
            mainMachine.RequestStateTransition(roaming.GetTarget());
        }
        yield return null;
    }
コード例 #9
0
ファイル: throwBall.cs プロジェクト: Bakiet/ProjectBruiser
 void Start()
 {
     physicsScript = gameObject.GetComponent("tsg_PropulsionPhysics")as tsg_PropulsionPhysics;
     hasBall = 1;
     theBrain = GameObject.Find("Brain") as GameObject;
     brainScript = theBrain.GetComponent("Brain") as Brain;
 }
コード例 #10
0
ファイル: WolfIdle.cs プロジェクト: Syclamoth/GamesAI6
    public override IEnumerator Enter(Machine owner, Brain controller)
    {
        mainMachine = owner;
        myBrain = controller;

        myBrain.legs.addSteeringBehaviour(wander);
        yield return null;
    }
コード例 #11
0
ファイル: WRAI.cs プロジェクト: Bakiet/ProjectBruiser
 void Start()
 {
     theBrain = GameObject.Find("Brain") as GameObject;
     brainScript = theBrain.GetComponent("Brain") as Brain;
     hasBall = 0;
     //theBrain = GameObject.Find("Brain").GetComponent("Brain") as Brain;
     routeNum = 0;
 }
コード例 #12
0
ファイル: Pursue.cs プロジェクト: JonECG/Spoopy
    public override void Act(Brain.Perception perceived, Brain.Motivation motivation)
    {
        goHere = perceived.PerceivedWorldPosition;
        goHere.y = transform.position.y;

        transform.LookAt(goHere);
        transform.Translate((transform.forward.normalized * Mathf.Min( pursueSpeed * Time.deltaTime, Mathf.Max( Vector3.Distance( goHere, transform.position ) - 0.01f, 0 ) ) ), Space.World);
    }
コード例 #13
0
ファイル: BrainJar.cs プロジェクト: hellotheredev/Brains
        void Awake()
        {
            brain = GameObject.Instantiate(brain) as Brain;
            brain.CreateRuntimeInstances();

            GetSensors();
            GetNodeBehaviours();
        }
コード例 #14
0
ファイル: LookAtPlayer.cs プロジェクト: JonECG/Spoopy
    public override void Act(Brain.Perception perceived, Brain.Motivation motivation)
    {
        Vector3 xz = perceived.PerceivedWorldPosition - transform.position;
        xz.y = 0;
        xz.Normalize();

        transform.LookAt(xz + transform.position);
    }
コード例 #15
0
ファイル: BrainWindow.cs プロジェクト: hellotheredev/Brains
        public static void ShowWindow(Brain brain)
        {
            window = EditorWindow.GetWindow(typeof(BrainWindow)) as BrainWindow;
            window.title = "Brain";
            window.scrollPosition = Vector2.zero;
            window.brain = brain;

            window.CenterOnNodes();
        }
コード例 #16
0
ファイル: Layer.cs プロジェクト: aaannndddyyy/dANN
 /// <summary>
 ///		Constructs a new layer, and sets some initial values
 /// </summary>
 /// <param name="OwnedDNAToSet">DNA that dictates the properties of the layer</param>
 /// <param name="DestinationLayerToSet">Initial Destination layer.</param>
 /// <param name="SourceLayerToSet">Initial source layer</param>
 public Layer(Brain OwnedBrainToSet, DNA OwnedDNAToSet, Layer DestinationLayerToSet, Layer SourceLayerToSet, bool UseByteResolution)
 {
     this.ByteResolution =UseByteResolution;
     this.OwnedBrain = OwnedBrainToSet;
     this.SourceLayer = SourceLayerToSet;
     this.DestinationLayer = DestinationLayerToSet;
     this.OwnedDNA = OwnedDNAToSet;
     this.Uid = this.OwnedBrain.GetNextLayerId();
 }
コード例 #17
0
    void OnGUI()
    {
        if (editorWindow)
            editorWindow.minSize = new Vector2(512, 512);
        else
            ShowEditor();

        if (brain == null)
            StatusMsg = "nothing loaded!";
        else
            StatusMsg = "loaded " + brain.name;

        GUILayout.Label("Status: " + StatusMsg);

        assetName = GUILayout.TextField(assetName, 32, GUILayout.ExpandWidth(true));

        if (GUILayout.Button("Create"))
        {
            var asset = CreateInstance<Brain>();
            DataAssetCreator.CreateDataAsset(assetName, asset);

            if (asset != null)
            {
                //asset.Name = assetName;
                brain = asset;
                //StatusMsg = "created " + Graph.Name;
            }
        }

        GUI.enabled = assetName != "";
        if (GUILayout.Button("Load"))
        {
            Brain tmp = Resources.Load<Brain>(assetName);

            if (tmp != null)
            {
                //StatusMsg = "loaded " + tmp.Name;
                //Graph = tmp;
                brain = tmp;
            }
        }

        GUI.enabled = brain != null;
        if (GUILayout.Button("add neuron"))
        {
            var neuron = new Neuron();
            neuron.count = 1;

            brain.network.Add(neuron);
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(brain);
        }
    }
コード例 #18
0
    public override IEnumerator Enter(Machine owner, Brain controller)
    {
        mainMachine = owner;
        myBrain = controller;

        //speed is zero
        myBrain.legs.maxSpeed = 0f;
        Debug.Log("I'm being eaten! Oh no!");
        yield return null;
    }
コード例 #19
0
ファイル: WolfIdle.cs プロジェクト: Syclamoth/GamesAI6
    public override IEnumerator Run(Brain controller)
    {
        foreach(SensedObject obj in controller.senses.GetSensedObjects()) {
            if(obj.getAgentType() == AgentClassification.Sheep) {
                controller.memory.SetValue("SeenTarget", obj.getObject());

            }
        }
        yield return null;
    }
コード例 #20
0
ファイル: Sheep_gonenut.cs プロジェクト: Syclamoth/GamesAI6
    public override IEnumerator Enter(Machine owner, Brain controller)
    {
        mainMachine = owner;
        myBrain = controller;

        //set speed to minimum
        myBrain.legs.maxSpeed = 1f;
        time = 0f;
        yield return null;
    }
コード例 #21
0
ファイル: DEAI.cs プロジェクト: Bakiet/ProjectBruiser
    // Use this for initialization
    void Start()
    {
        theBrain = GameObject.Find("Brain") as GameObject;
        brainScript = theBrain.GetComponent("Brain") as Brain;

        QB = GameObject.Find("QB") as GameObject;
        persuitSack = QB.GetComponent("Throw Ball") as throwBall;

        hasBall = 0;
        persuitHasBallInt = 0;
    }
コード例 #22
0
    public override IEnumerator Run(Brain controller)
    {
        //back to gonenut state
        if (controller.memory.GetValue<bool>("BeingEaten") == false)
        {
            controller.memory.SetValue("HP", 100f);
            mainMachine.RequestStateTransition(nuts.GetTarget());
        }

        yield return null;
    }
コード例 #23
0
ファイル: MainGUI.cs プロジェクト: Bakiet/ProjectBruiser
 //int timer = 210;
 void Start()
 {
     score0 = 0;
     score1 = 0;
     isEscape = 0;
     theScoreObject = GameObject.Find("Brain") as GameObject;
     brainScript = theScoreObject.GetComponent("Brain") as Brain;
     Screen.lockCursor = true;
     Screen.showCursor = false;
     //GUI.skin = thisMetalGUISkin;
 }
コード例 #24
0
ファイル: Brain.cs プロジェクト: bosaku/darkness
 void Awake()
 {
     //Debug.Log("Awake");
     if (!Brain.Instance) {
         Instance = this;
     } else {
         DestroyImmediate(gameObject);
         return;
     }
     DontDestroyOnLoad(gameObject);
 }
コード例 #25
0
ファイル: Brain.cs プロジェクト: MedStarSiTEL/UnityTrauma
	virtual public void Awake() // this virtual definition differs from Unity's Awake Signature, so it isnt called.
	{
		if (instance == null)
			instance = this;
		// get audio source
		audioSource = Camera.mainCamera.audio;		
		characterAudioSources = new Dictionary<string,AudioSource>();
		foreach (UnityEngine.Object tc in FindObjectsOfType(typeof (TaskCharacter))){
			if (((TaskCharacter)tc).gameObject.audio != null)
				characterAudioSources[tc.name]=((TaskCharacter)tc).gameObject.audio;
		}
	}
コード例 #26
0
ファイル: SheepIdle.cs プロジェクト: Syclamoth/GamesAI6
    public override IEnumerator Run(Brain controller)
    {
        foreach(SensedObject obj in controller.senses.GetSensedObjects()) {
            if(obj.getAgentType() == AgentClassification.Wolf) {
                controller.memory.SetValue<float>("Panic", controller.memory.GetValue<float>("Panic") + 10);
            }
        }

        if((float)controller.memory.GetValue("Panic") >= 85) {
            mainMachine.RequestStateTransition(alarm.GetTarget());
        }
        yield return null;
    }
コード例 #27
0
ファイル: TriggerManager.cs プロジェクト: Syclamoth/GamesAI6
 public void BuildTrigger(Brain cortex)
 {
     if(owner != null)
     {
         owner.AddTrigger(this);
     }
     if(watched != null)
     {
         observed = watched.GetExposedVariables()[observedIndex];
     } else {
         watchedBrain = cortex;
         observed = GetMemoryData;
     }
 }
コード例 #28
0
ファイル: Player.cs プロジェクト: tedavtar/LTAI
	// changed from start to awake since want to have this done very first
	void Awake () {

		selectedPause = actualSelectedPause;

		initStanding ();
		loadID ();

		initDeck ();
		
		initHand ();

		myBrain = gameObject.GetComponents (typeof(Brain))[0] as Brain;
		//print (myBrain);
	}
コード例 #29
0
ファイル: TrainerCorrelation.cs プロジェクト: Bullshitzu/AHK
    public override void EndIteration(int num, Brain brain)
    {
        float[] results;

        switch (num) {
            case 1:
                results = new float[brain.Inputs.Count];
                for (int i = 0; i < brain.Inputs.Count; i++) {
                    results[i] = brain.Inputs[i].currentValue;
                }
                scoreSets.Add(results);
                return;
            default:
                int outputIndex = (num - 2) / brain.InputCount;
                int inputIndex = (num - 2) % brain.InputCount;

                if (inputIndex == 0) {
                    results = new float[brain.Inputs.Count];
                    scoreSets.Add(results);
                }
                else results = scoreSets[outputIndex];

                float currResult = (TrainerBaseline.baseList[inputIndex] - brain.Inputs[inputIndex].currentValue) * 2.5f; // cca 2.5, perfect with an additional genetic pass
                results[inputIndex] = currResult;

                Debug.Log(outputIndex + 1 + "   -   " + inputIndex + "   -   " + brain.MainColumn[inputIndex].currentValue + "  -   " + TrainerBaseline.baseList[inputIndex] + "  -   " + currResult);

                if (num == iterationCount) {
                    Debug.Log("Done! Applying..");

                    Reset(brain.Controller);

                    for (int i = 0; i < brain.OutputCount; i++) {
                        for (int j = 0; j < brain.Inputs.Count; j++) {
                            brain.Outputs[i].InputSynapses[j].multiplier = Mathf.Clamp01(scoreSets[i][j]);
                        }
                    }
                    for (int i = 0; i < brain.MainColumn.Count; i++) {
                        for (int j = 0; j < brain.InputCount; j++) {
                            brain.MainColumn[i].InputSynapses[j].multiplier = 0.1f;
                        }
                    }
                    for (int i = 0; i < brain.Inputs.Count; i++) {
                        brain.MainColumn[i].InputSynapses[i].multiplier = 1;
                    }
                }

                return;
        }
    }
コード例 #30
0
 public override IEnumerator Enter(Machine owner, Brain controller)
 {
     mainMachine = owner;
     myBrain = controller;
     Legs myLegs = myBrain.legs;
     cohesion = new Cohesion(controller.allObjects);
     cohesion.setWeight (0.3f);
     cohesion.Init (myLegs);
     alignment = new Alignment(controller.allObjects);
     alignment.Init (myLegs);
     alignment.setWeight(0.2f);
     myLegs.addSteeringBehaviour(cohesion);
     myLegs.addSteeringBehaviour(alignment);
     yield return null;
 }
コード例 #31
0
 public TargetController(Brain brain)
 {
     this.brain = brain;
 }
コード例 #32
0
 void Start()
 {
     cBrain = gameObject.GetComponent <Brain> ();
 }
コード例 #33
0
 public AiPlayed(Brain brain, int gamesPlayed)
 {
     Brain       = brain;
     GamesPlayed = new bool[gamesPlayed];
 }
コード例 #34
0
ファイル: Agent.cs プロジェクト: jo3w4rd/ml-agents
 /// <summary>
 /// Updates the Brain for the agent. Any brain currently assigned to the
 /// agent will be replaced with the provided one.
 /// </summary>
 /// <remarks>
 /// The agent unsubscribes from its current brain (if it has one) and
 /// subscribes to the provided brain. This enables contextual brains, that
 /// is, updating the behaviour (hence brain) of the agent depending on
 /// the context of the game. For example, we may utilize one (wandering)
 /// brain when an agent is randomly exploring an open world, but switch
 /// to another (fighting) brain when it comes into contact with an enemy.
 /// </remarks>
 /// <param name="brain">New brain to subscribe this agent to</param>
 public void GiveBrain(Brain brain)
 {
     this.brain = brain;
     ResetData();
 }
コード例 #35
0
 private void Awake()
 {
     brain = GetComponent <Brain>();
 }
コード例 #36
0
 public HammerOfWrath(Brain brain, int priority)
     : base(brain, priority, "Hammer of Wrath")
 {
 }
コード例 #37
0
 public Rebuke(Brain brain, int priority)
     : base(brain, priority, "Rebuke")
 {
 }
コード例 #38
0
        public static Perso Read(EndianBinaryReader reader, Pointer offset, SuperObject so)
        {
            MapLoader l = MapLoader.Loader;
            //l.print("Offset: " + offset);
            Perso p = new Perso(offset, so);

            l.persos.Add(p);
            Pointer off_perso       = Pointer.Read(reader); // 0x0
            Pointer off_nameIndices = Pointer.Read(reader); // 4 Standard Game info
            Pointer off_unknown     = Pointer.Read(reader); // 0x8
            Pointer off_brain       = Pointer.Read(reader); // 0xC

            reader.ReadUInt32();                            // 0x10 is Camera in Rayman 2
            reader.ReadUInt32();                            // 0x14 platform info
            Pointer off_msWay = Pointer.Read(reader);       // 0x18

            reader.ReadUInt32();                            // 0x1C
            reader.ReadUInt32();                            // 0x20
            reader.ReadUInt32();                            // 0x24
            reader.ReadUInt32();
            if (l.mode == MapLoader.Mode.RaymanArenaPC || l.mode == MapLoader.Mode.RaymanArenaGC)
            {
                reader.ReadUInt32();
            }
            if (l.mode == MapLoader.Mode.Rayman2PC)
            {
                reader.ReadUInt32();
                reader.ReadUInt32();
                reader.ReadUInt32();
                reader.ReadUInt32();
            }
            //R3Pointer.Goto(ref reader, off_perso);
            Pointer.Read(reader); // same as next
            Pointer off_currentState = Pointer.Read(reader);

            Pointer.Read(reader); // same as previous
            Pointer off_physicalObjects = Pointer.Read(reader);

            reader.ReadUInt32(); // same address?
            Pointer off_family = Pointer.Read(reader);

            p.family       = Family.FromOffset(off_family);
            p.initialState = State.FromOffset(p.family, off_currentState);

            if (off_nameIndices != null)
            {
                Pointer off_current = Pointer.Goto(ref reader, off_nameIndices);
                uint    index0      = reader.ReadUInt32();
                uint    index1      = reader.ReadUInt32();
                uint    index2      = reader.ReadUInt32();
                p.name0 = l.objectTypes[0][index0].name;
                p.name1 = l.objectTypes[1][index1].name;
                p.name2 = l.objectTypes[2][index2].name;
                Pointer.Goto(ref reader, off_current);
            }
            l.print("[" + p.name0 + "] " + p.name1 + " | " + p.name2 + " - offset: " + offset);

            if (off_brain != null)
            {
                Pointer off_current = Pointer.Goto(ref reader, off_brain);
                p.brain = Brain.Read(reader, off_brain);
                Pointer.Goto(ref reader, off_current);
            }

            if (l.mode == MapLoader.Mode.Rayman2PC && off_msWay != null)
            {
                Pointer off_current = Pointer.Goto(ref reader, off_msWay);
                p.msWay = MSWay.Read(reader, off_msWay);
                Pointer.Goto(ref reader, off_current);

                // Graph read?
                if (p.msWay.graph != null)
                {
                    GameObject go_msWay = new GameObject("MSWay");
                    go_msWay.transform.SetParent(p.Gao.transform);

                    GameObject go_graph = new GameObject("Graph");
                    go_graph.transform.SetParent(go_msWay.transform);

                    int nodeNum = 0;
                    foreach (GraphNode node in p.msWay.graph.nodeList)
                    {
                        GameObject go_graphNode = new GameObject("GraphNode[" + nodeNum + "].WayPoint");
                        go_graphNode.transform.position.Set(node.wayPoint.position.x, node.wayPoint.position.y, node.wayPoint.position.z);
                        go_graphNode.transform.SetParent(go_graph.transform);
                        nodeNum++;
                    }
                }
            }

            if (p.family != null && p.family.GetIndexOfPhysicalList(off_physicalObjects) != -1)
            {
                p.physical_objects = p.family.physical_objects[p.family.GetIndexOfPhysicalList(off_physicalObjects)];
            }
            //if (off_intelligence != null) l.print("Intelligence for " + p.name2 + ": " + off_intelligence);

            /*if (off_intelligence != null) {
             *  R3Pointer.Goto(ref reader, off_intelligence);
             *  reader.ReadUInt32();
             *  reader.ReadUInt32();
             *  reader.ReadUInt32();
             *  reader.ReadUInt32();
             *  reader.ReadUInt32();
             *  reader.ReadUInt32();
             *  reader.ReadUInt32();
             *  R3Pointer off_name = R3Pointer.Read(reader);
             *  if (off_name != null) {
             *      R3Pointer.Goto(ref reader, off_name);
             *      name = reader.ReadNullDelimitedString();
             *  }
             * }*/
            /*if (off_subblocklist != null && p.family != null && off_subblocklist == p.family.off_physical_list && p.family.physical_objects != null) {
             *  // Clone family's physical objects into this perso
             *  p.physical_objects = new PhysicalObject[p.family.physical_objects.Length];
             *  for (int i = 0; i < p.family.physical_objects.Length; i++) {
             *      PhysicalObject o = p.family.physical_objects[i];
             *      if (o != null) {
             *          p.physical_objects[i] = o.Clone();
             *          p.physical_objects[i].Gao.transform.parent = p.Gao.transform;
             *          p.physical_objects[i].Gao.name = "" + i + " - " + p.physical_objects[i].Gao.name;
             *      }
             *  }
             * } else if (off_subblocklist != null) {
             *  l.print("Perso's physical list does not match family list at position " + offset);
             * }*/
            return(p);
        }
コード例 #39
0
        public void Run()
        {
            var mockOut      = new Mock <TextWriter>();
            var mockGraphics = new Mock <IGraphics>();
            var myBot        = new Mock <IBaseAdvancedRobot>(MockBehavior.Strict);

            IContext context = new Context(myBot.Object);

            BaseBehavior.Context = context;
            BaseStrategy.Context = context;

            var behaviours = new BaseBehavior[]
            {
                // new RunAwayAndHideBehaviour(),
                new SearchBehavior(),
                new MeleeBehavior(),
                new OneVsOneBehavior(),
                new VictoryBehavior()
            };

            IBrain brain = new Brain(
                myBot.Object,
                behaviours,
                context);

            myBot.Setup(bot => bot.Out).Returns(mockOut.Object);
            myBot.Setup(bot => bot.SetColors(It.IsAny <Color>(), It.IsAny <Color>(), It.IsAny <Color>()));
            myBot.SetupProperty(bot => bot.IsAdjustGunForRobotTurn);
            myBot.SetupProperty(bot => bot.IsAdjustRadarForGunTurn);
            myBot.SetupProperty(bot => bot.IsAdjustRadarForRobotTurn);
            myBot.Setup(bot => bot.BattleFieldWidth).Returns(800d);
            myBot.Setup(bot => bot.BattleFieldHeight).Returns(600d);
            var startAt = RandomHelper.RandomLocation();

            myBot.Setup(bot => bot.X).Returns(startAt.X);
            myBot.Setup(bot => bot.Y).Returns(startAt.Y);

            brain.RunInit();

            myBot.Setup(bot => bot.GunHeading).Returns(0d);
            myBot.Setup(bot => bot.GunTurnRemaining).Returns(0d);
            myBot.Setup(bot => bot.GunHeat).Returns(0d);
            myBot.Setup(bot => bot.Others).Returns(10);

            myBot.Setup(bot => bot.SetTurnRadarRight(It.IsAny <double>()));
            myBot.Setup(bot => bot.SetTurnGunRight(It.IsAny <double>()));
            myBot.Setup(bot => bot.SetTurnRight(It.IsAny <double>()));
            myBot.Setup(bot => bot.SetAhead(It.IsAny <double>()));
            myBot.Setup(bot => bot.SetFireBullet(It.IsAny <double>()))
            .Returns(RandomHelper.RandomBullet());

            myBot.Setup(bot => bot.Heading).Returns(RandomHelper.RandomHeading());

            myBot.Setup(bot => bot.Execute());

            myBot.Setup(bot => bot.GunCoolingRate).Returns(5);
            myBot.Setup(bot => bot.Energy).Returns(RandomHelper.RandomEnergy());

            for (int turn = 0; turn < 200; turn++)
            {
                brain.Render(mockGraphics.Object);

                myBot.Setup(bot => bot.Time).Returns(turn);

                if (turn % 7 == 0)
                {
                    for (int i = 0; i < 2; i++)
                    {
                        brain.OnScannedRobot(new ScannedRobotEvent(
                                                 RandomHelper.RandomRobotName(),
                                                 RandomHelper.RandomEnergy(),
                                                 RandomHelper.RandomBearing(),
                                                 RandomHelper.RandomDistance(),
                                                 RandomHelper.RandomHeading(),
                                                 RandomHelper.RandomVelocity()
                                                 ));
                    }
                }

                brain.Run();
            }
        }
コード例 #40
0
ファイル: Labourer.cs プロジェクト: zzq889527/goap
 public virtual void Release()
 {
     Brain.Release();
 }
コード例 #41
0
ファイル: Labourer.cs プロジェクト: zzq889527/goap
 public virtual void Tick()
 {
     Brain.Tick(this);
 }
コード例 #42
0
ファイル: Snake.cs プロジェクト: Taybenberg/EvoSnake
 public void mutate()
 {
     Brain.mutate();
 }
コード例 #43
0
 //public AudioClip onHoverGuiSound;
 void Start()
 {
     brain       = GameObject.Find("Brain") as GameObject;
     brainScript = brain.GetComponent("Brain") as Brain;
     arrayPos    = 0;
 }
コード例 #44
0
 public TemplarsVerdict(Brain brain, int priority)
     : base(brain, priority, "Templar's Verdict")
 {
 }
コード例 #45
0
 public Exorcism(Brain brain, int priority)
     : base(brain, priority, "Exorcism")
 {
 }
コード例 #46
0
 public State onTrigger(FeatureVector vector, Brain brain)
 {
     return(new ShootAndResumeState(brain.getCurrentState()));
 }
コード例 #47
0
 public DivineShield(Brain brain, int priority)
     : base(brain, priority, "Divine Shield")
 {
 }
コード例 #48
0
        public override void Execute()
        {
            NWCreature self       = (NWCreature)Self;
            BeastBrain beastBrain = (BeastBrain)Brain;

            int            min          = beastBrain.fNearKinsfolkDist;
            CreatureEntity nearKinsfolk = beastBrain.fNearKinsfolk;
            int            cohX         = 0;
            int            cohY         = 0;
            int            algX         = 0;
            int            algY         = 0;

            int cnt = beastBrain.Kinsfolks.Count;

            for (int i = 0; i < cnt; i++)
            {
                NWCreature cr  = beastBrain.Kinsfolks[i];
                int        dir = cr.LastDir;
                cohX += cr.PosX;
                cohY += cr.PosY;
                algX += Directions.Data[dir].DX;
                algY += Directions.Data[dir].DY;
            }

            int dX = 0;
            int dY = 0;

            if (cnt > 0)
            {
                dX = (dX + (int)Math.Round(algX / (float)cnt));
                dY = (dY + (int)Math.Round(algY / (float)cnt));
            }
            if (cnt > 0)
            {
                cohX = (int)Math.Round(cohX / (float)cnt);
                cohY = (int)Math.Round(cohY / (float)cnt);
                int dir = Directions.GetDirByCoords(self.PosX, self.PosY, cohX, cohY);
                dX += Directions.Data[dir].DX;
                dY += Directions.Data[dir].DY;
            }
            if (min <= 3 && nearKinsfolk != null)
            {
                if (nearKinsfolk.PosX > self.PosX)
                {
                    dX--;
                }
                if (nearKinsfolk.PosX < self.PosX)
                {
                    dX++;
                }
                if (nearKinsfolk.PosY > self.PosY)
                {
                    dY--;
                }
                if (nearKinsfolk.PosY < self.PosY)
                {
                    dY++;
                }
            }

            ExtPoint newPos = new ExtPoint();

            newPos.X = self.PosX + dX;
            newPos.Y = self.PosY + dY;
            ExtPoint next = self.GetStep(newPos);

            if (!next.IsEmpty)
            {
                Brain.StepTo(next.X, next.Y);
            }
        }
コード例 #49
0
 public Consecration(Brain brain, int priority)
     : base(brain, priority, "Consecration")
 {
 }
コード例 #50
0
ファイル: State_Attack.cs プロジェクト: paco141/Chronopulse
 public virtual void OnTriggerEnter(Brain _brain)
 {
 }
コード例 #51
0
    /***
     * Fetch a pack
     * Remove old shapes
     * Get the new shapes
     */
    public override void AgentReset()
    {
        step    = 0;
        stepNum = 0;
        pack    = packEvol.ReadPack(packFileName, packID);
        GameObject _brain = GameObject.Find("Academy/Brain");
        Brain      brain  = _brain.transform.GetComponent <Brain>();

        // Destroying the already present shapes
        if (shapes != null)
        {
            for (int i = 0; i < shapes.Length; i++)
            {
                UnityEngine.Object.DestroyImmediate(shapes[i]);
            }
            shapes = null;
        }

        if (rotBeforeMov)
        {
            validPos = new int[1, 1, MOV_RES, MOV_RES, MOV_RES];
        }
        else
        {
            validPos = new int[packEvol.r1Value.Count, packEvol.r2Value.Count, MOV_RES, MOV_RES, MOV_RES];
        }

        if (!loadPrecompute)
        {
            if (getGT)
            {
                gtStepAction = gtPack.GetGtStepAction(ref pack, rotBeforeMov: rotBeforeMov);
            }

            if (getSavedAct)
            {
                gtStepAction = GetStepAction();
            }

            // Loading the new shapes
            string[] _null = null;
            packEvol.GetShapes(ref _null, ref pack.sources, ref shapes, loadFromResources: false, keepRenderer: editorMode);
            for (int i = 0; i < shapes.Length; i++)
            {
                shapes[i].transform.localScale = pack.scales[i];
            }

            // Move shapes in visible pisitions in demoMode
            // Also removing box colliders for faster processing
            if (demoMode)
            {
                float theta = (2.0f * Mathf.PI) / shapes.Length;
                for (int i = 0; i < shapes.Length; i++)
                {
                    BoxCollider[] boxes = shapes[i].GetComponents <BoxCollider>();
                    foreach (BoxCollider box in boxes)
                    {
                        Destroy(box);
                    }

                    shapes[i].transform.position = new Vector3(2.0f * Mathf.Sin(i * theta),
                                                               0f,
                                                               2.0f * Mathf.Cos(i * theta));
                }
            }
            else
            {
                // intial estimate added so as to ensure faster computation
                vox = new List <float> (Mathf.CeilToInt(pack.efficiency * VOX_RES * VOX_RES * VOX_RES));
                for (int i = 0; i < shapes.Length; i++)
                {
                    shapes[i].transform.position = Vector3.zero;
                    boxVoxel(ref vox, i);
                    shapes[i].transform.position = 100 * Vector3.one;
                }
                vox.TrimExcess();

                // setting up the number of observarions
                brain.brainParameters.vectorObservationSize =
                    ((VOX_RES * VOX_RES * VOX_RES) > (vox.Count + 1)) ? (VOX_RES * VOX_RES * VOX_RES) + 2 : vox.Count + 3;
            }
        }
        else
        {
            shapes = new GameObject[pack.sources.Length];
            precompute.loadPrecompute(packFileName, packID, ref gtStepAction, rotBeforeMov);
            brain.brainParameters.vectorObservationSize = (VOX_RES * VOX_RES * VOX_RES) + 2;
            if (getSavedAct)
            {
                gtStepAction = GetStepAction();
            }
        }
    }
コード例 #52
0
ファイル: State_Attack.cs プロジェクト: paco141/Chronopulse
 public virtual void OnTriggerExit(Brain _brain)
 {
 }
コード例 #53
0
ファイル: Controller.cs プロジェクト: maksa988/Warehouse
 public Controller(Brain brain, MyDatabase db)
 {
     this._brain = brain;
     this._db    = db;
 }
コード例 #54
0
 public void Mutate()
 {
     Brain.Mutate();
 }
コード例 #55
0
        public void TestFuctionNotReturnsZero()
        {
            Brain b = new Brain();

            Assert.NotEqual(0, b.TestFunction());
        }
コード例 #56
0
 public HolyWrath(Brain brain, int priority)
     : base(brain, priority, "Holy Wrath")
 {
 }
コード例 #57
0
ファイル: BoardBrain.cs プロジェクト: d3x0r/xperdex
 BoardBrain()
 {
     brain = new xperdex.brain.core.Brain();
 }
コード例 #58
0
        public void TestFunctionReturnsFive()
        {
            Brain b = new Brain();

            Assert.Equal(5, b.TestFunction());
        }
コード例 #59
0
    // Update is called once per frame
    void Update()
    {
        List <Brain> newBrains    = new List <Brain>();
        List <Brain> removeBrains = new List <Brain>();

        // run each brain
        foreach (Brain brain in brains)
        {
            if (brain.getCurrentSize() >= brain.getMaxSize())
            {
                Brain newBrain = new Brain();
                newBrain.setMaxSize(brain.getMaxSize());
                newBrain.setCyclesMax(brain.cyclesPerUpdateMax);
                newBrain.setCyclesMin(brain.cyclesPerUpdateMin);
                newBrain.setCyclesPer(brain.cyclesPerUpdateMin);
                newBrain.setEntities(brain.Split());
                newBrains.Add(newBrain);
                continue;
            }

            if (brain.getCurrentSize() >= 1)
            {
                brain.Update();
            }
            else
            {
                removeBrains.Add(brain);
            }
        }

        foreach (Brain newBrain in newBrains)
        {
            brains.Add(newBrain);
        }
        foreach (Brain removeBrain in removeBrains)
        {
            brains.Remove(removeBrain);
        }

        totalCycles++;

        List <string> entityNames  = new List <string>();
        List <int>    entityCounts = new List <int>();

        if (cycleCount++ > debugRefresh)
        {
            cycleCount = 0;

            GameObject[] entities = GameObject.FindGameObjectsWithTag("Entity");
            foreach (GameObject entity in entities)
            {
                if (!entityNames.Contains(entity.name))
                {
                    entityNames.Add(entity.name);
                }
                int nameIndex = entityNames.IndexOf(entity.name);

                if (entityCounts.Count <= nameIndex)
                {
                    entityCounts.Add(1);
                }
                else
                {
                    entityCounts[nameIndex]++;
                }
            }

            debugText.text = "Game Cycles: " + totalCycles;

            for (int key = 0; key < entityNames.Count; ++key)
            {
                debugText.text += "\n" + entityNames[key] + ": " + entityCounts[key];
            }

            debugText.text += "\nBrains: " + brains.Count;
        }
    }
コード例 #60
0
 public void Init(Brain net, Transform hex)
 {
     this.hex   = hex;
     this.net   = net;
     initilized = true;
 }