public void JustSampleUsage() { var actions = LocomotionAction.EightDirections(); var sequenceMaker = new EvolutionarySequenceMaker(epsilon: 0.3f, minimumCandidates: 30); var decisionMaker = new ReinforcementDecisionMaker(); var brain = new MotionGenerator.Brain( decisionMaker, sequenceMaker ); brain.Init( new Dictionary <Guid, int> { { Guid.NewGuid(), (new ManipulatableMock()).GetManipulatableDimention() } }, actions, new List <ISoul>() { new GluttonySoul() } ); // Position, Rotation is required to update LocomotionAction // GluttonySoul.Key is required to update GluttonySoul // others are used to decide action brain.GenerateMotionSequence(new State(new Dictionary <string, Vector>() { { State.BasicKeys.RelativeFoodPosition, DenseVector.OfArray(new double[] { 0.5f, 0.5f, 0.5f }) }, { State.BasicKeys.BirthPosition, DenseVector.OfArray(new double[] { 0f, 0f, 0f }) }, { State.BasicKeys.Position, DenseVector.OfArray(new double[] { 0f, 0f, 0f }) }, { State.BasicKeys.Rotation, DenseVector.OfArray(new double[] { 0f, 0f, 0f, 0f }) }, { GluttonySoul.Key, DenseVector.OfArray(new double[] { 0f }) } })); brain.GenerateMotionSequence(new State(new Dictionary <string, Vector>() { { State.BasicKeys.RelativeFoodPosition, DenseVector.OfArray(new double[] { 0.5f, 0.5f, 0.5f }) }, { State.BasicKeys.BirthPosition, DenseVector.OfArray(new double[] { 0f, 0f, 0f }) }, { State.BasicKeys.Position, DenseVector.OfArray(new double[] { 0.1f, 0f, 0f }) }, { State.BasicKeys.Rotation, DenseVector.OfArray(new double[] { 0f, 0f, 0f, 0f }) }, { GluttonySoul.Key, DenseVector.OfArray(new double[] { 1f }) } })); }
public static Car CreateComponent(Vector3 vector3, Camera main) { var prefab = (GameObject)Resources.Load("Prefabs/Car"); var car = Instantiate(prefab, vector3, Quaternion.identity); CarControlManipulatable.CreateComponent(car); SurroundSensor.CreateComponent(car); Sensor.CreateComponent(car, typeof(Food), State.BasicKeys.RelativeFoodPosition, range: 300f); Mouth.CreateComponent(car, typeof(Food)); CrashSensor.CreateComponent(car); var actions = LocomotionAction.EightDirections(); var sequenceMaker = new EvolutionarySequenceMaker(epsilon: 0.3f, minimumCandidates: 30); IDecisionMaker decisionMaker = new ReinforcementDecisionMaker( keyOrder: new[] { State.BasicKeys.Forward, State.BasicKeys.RelativeFoodPosition, SurroundSensor.Key }, soulWeights: new[] { 1f, 1f }); decisionMaker = new LoggingDecisionMaker(decisionMaker); var brain = new Brain( decisionMaker, sequenceMaker ); Agent.CreateComponent(car, brain, new Body(car), actions, souls: new List <ISoul>() { new SnufflingDifferencialSoul(), new AvoidCrashSoul() }); return(car.AddComponent <Car>()._CreateComponent(main, vector3)); }