Example #1
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                Unit target = trigger.Args.Target;

                if (target == trigger.Args.Character)
                {
                    target = trigger.Args.Character.Target;
                }
                if (!(target is NPC))
                {
                    trigger.Reply("Must target NPC.");
                }
                else
                {
                    IBrain brain = target.Brain;
                    if (brain == null)
                    {
                        trigger.Reply(target.Name + " doesn't have a brain.");
                    }
                    else
                    {
                        bool flag = !trigger.Text.HasNext ? !brain.IsRunning : trigger.Text.NextBool();
                        brain.IsRunning = flag;
                        trigger.Reply(target.Name + "'s Brain is now: " + (flag ? "Activated" : "Deactivated"));
                    }
                }
            }
Example #2
0
 private void _fileName_TextChanged(object sender, TextChangedEventArgs e)
 {
     _brain = null;
     _grid.Children.Clear();
     _grid.ColumnDefinitions.Clear();
     _grid.RowDefinitions.Clear();
 }
Example #3
0
        public bool LoadBrain(string path)
        {
            var    dataBase = XDocument.Load(path);
            var    Xbrain   = dataBase.Root;
            IBrain brain    = new Network();
            var    first    = true;

            foreach (var Xlayer in Xbrain.Elements())
            {
                ILayer layer;
                layer = first ? methodForFirstLayer(Xlayer) : methodForNextLayer(Xlayer, brain.Layers[0]);
                first = false;
                brain.Layers.Add(layer);
            }

            if (brain.Layers.Count < 2)
            {
                MessageBox.Show(
                    "Неподдерживаемый файл, обновите файл и повторите попытку. Или просто натренируйте сеть заново.");
                return(false);
            }

            Brain = brain;
            return(true);
        }
Example #4
0
 public Basics()
 {
     env   = new DefaultEnvironment(null);
     robot = new RobotBase(env);
     brain = new BrainBase(robot);
     brain.OnLoggedEvent += (ILogEntry entry) => lastLogEntry = entry;
 }
Example #5
0
        public void Init(
            IBrain brain,
            IVideoProvider videoProvider,
            IVideoRecorder videoRecorder,
            IAudioRecorder audioRecorder,
            IAudioPlayer audioPlayer,
            IAudioRepository audioRepository)
        {
            this.brain         = brain;
            this.videoProvider = videoProvider;
            this.videoRecorder = videoRecorder;
            this.audioRecorder = audioRecorder;

            var frameObserver           = new FrameObserver(brain);
            var frameRecognizedObserver = new FrameRecognizedObserver(audioPlayer, audioRepository);

            recognizeAvailableFrameSubscription = videoProvider.FrameAvailable.Subscribe(frameObserver);

            this.lifetimeStreams = new CompositeDisposable
            {
                brain.FrameRecognized.Subscribe(frameRecognizedObserver),
                videoRecorder.RecordingAvailable.Subscribe(new VideoPublisher(brain)),
                audioRecorder.RecordingAvailable.Subscribe(new AudioPublisher(audioRepository))
            };
        }
        public void Teach(IBrain brain, int iterations)
        {
            var analyser = new Analyser(brain);

            var depth = 4;

            for (var i = 0; i < iterations; i++)
            {
                var stones   = _randomizer.Next(1, 48);
                var position = GetAwariPosition(stones);
                var p        = position.GetPits();

                if (p[0] > 0 || p[1] > 0 || p[2] > 0 || p[3] > 0 || p[4] > 0 || p[5] > 0)
                {
                    analyser.Start(i, p, 48 - stones);

                    var score = _evaluator.Evaluate(position, 5) + 48 - stones;
                    brain.Learn(p, 48 - stones, score);

                    analyser.Stop(score);
                }
            }

            analyser.Dispose();
        }
Example #7
0
        private Agent _CreateComponent(IBrain brain, Body body, List <IAction> actions, List <ISoul> souls = null)
        {
            List <IManipulatable> manipulatables = GetChildrenManipulatables();

            for (int i = 0; i < manipulatables.Count; i++)
            {
                manipulatables[i].SetManipulatableId(i); // just an ID
            }

            if (souls == null)
            {
                souls = new List <ISoul>()
                {
                    new GluttonySoul()
                };
            }

            body.Init(manipulatables, actions);
            brain.Init(
                manipulatables
                .Where(m => m.GetManipulatableDimention() > 0)
                .Select(m => m.GetManipulatableDimention()).ToList(),
                actions,
                souls);
            this.brain = brain;
            this.body  = body;
            return(this);
        }
Example #8
0
        public void Hear(Message message, IMessageClient client, IBrain brain)
        {
            string time = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
            string result = time + " in the room " + message.RoomId;
            var userName = client.GetUser(message.UserId).Name;

            brain.SetValue(LastSpokeKey(userName), result);
        }
Example #9
0
File: Status.cs Project: NBot/NBot
        public void Hear(Message message, IMessageClient client, IBrain brain)
        {
            string time     = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
            string result   = time + " in the room " + message.RoomId;
            var    userName = client.GetUser(message.UserId).Name;

            brain.SetValue(LastSpokeKey(userName), result);
        }
Example #10
0
 /// <summary>
 /// Cell constructor
 /// </summary>
 /// <param name="x">The x position where the cell is spawned</param>
 /// <param name="y">The y position where the cell is spawned</param>
 /// <param name="initialLife">life the cell is going to spawn with</param>
 /// <param name="thisWorld">A reference to the world the cell lives in</param>
 /// <param name="teamColor">The color of the team this cell belongs to</param>
 public Cell(Int16 x, Int16 y, Int16 initialLife, World thisWorld, Color teamColor)
 {
     Position = new Coordinates(x, y);
     _brain = new SwarmBrain();
     _life = initialLife;
     _world = thisWorld;
     _team = teamColor;
 }
 public void Initialize()
 {
     _randomizer = Substitute.For <IRandomizer>();
     _repository = new WeightingFactorsRepository(_randomizer);
     _repository.DeleteAll();
     _testPosition = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 3, 3, 3, 3 };
     _brain        = new Brain(_repository);
 }
Example #12
0
        public static IBrain Create(Gene gene, GameObject prefab, Vector3 position, Quaternion rotation)
        {
            GameObject org   = Instantiate(prefab, position, rotation);
            IBrain     brain = org.GetComponent <IBrain>();

            brain.SetupGenes(gene);
            return(brain);
        }
Example #13
0
 public HelpMeSkill(IBrain brain)
 {
     _brain  = brain;
     _skills = new Dictionary <string, IBrainSkill>();
     _orders = new OrdersCollection();
     _orders.Add("helpme", "prints this info!");
     _orders.Add("helpme allskills", "prints help for all known skills.");
     _orders.Add("helpme <skill>", "prints help for a specific skill.");
 }
Example #14
0
 void Awake()
 {
     brain    = GetComponent <IBrain>();
     animator = GetComponentInChildren <Animator>();
     foreach (FighterState state in info.states)
     {
         states[state.name] = state;
     }
 }
Example #15
0
 private void Start()
 {
     brain = GetComponent <IBrain>();
     if (PickRandomName)
     {
         _myName = AdjectiveHolder.GetRandomName();
     }
     GameObject.FindObjectOfType <MoveManager>().RegisterPlayer(this);
 }
Example #16
0
 public Robot(string name, string alias, string environment, Dictionary <string, object> settings, IBrain brain,
              INBotLog log)
 {
     Name        = name;
     Alias       = alias;
     Environment = environment;
     _settings   = settings;
     Brain       = brain;
     Log         = log;
 }
 public void SetClass(IClass clas, IBrain brain)
 {
     _class     = clas;
     _brain     = brain;
     Health     = _class.Health;
     Attack     = _class.Attack;
     Defense    = _class.Defense;
     Movement   = _class.Movement;
     Initiative = Random.Range(0, 20);
 }
Example #18
0
		public SpellCastAction(IBrain owner, Unit target, Spell spell) : base(owner)
		{
			m_ownerBrain = owner;
			m_target = target;
			m_spell = spell;

			if (m_target != null)
				m_range = new AIRange(m_spell.Range.Min, m_spell.Range.Max);

			IsPrimary = true;
		}
Example #19
0
        public Plan(IGoal goal, 
            IBrain brain)
        {
            this.Goal = goal;
            this.brain = brain;

            CurrentTask = new BaseTask();
            TaskQueue = new Queue<ITask>();

            IsActive = false;
        }
Example #20
0
        public MeleeAttackAction(IBrain owner)
            : base(owner)
        {
            var ownerUnit = owner.Owner;
            var mainWep   = ownerUnit.MainWeapon;

            m_range = new AIRange(mainWep.MinRange, mainWep.MaxRange);

            m_target = ownerUnit.Target;

            IsPrimary = false;
        }
Example #21
0
        public void Setup()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddLogging(x => x.AddConsole().SetMinimumLevel(LogLevel.Debug))
                                  .BuildServiceProvider();

            var factory = serviceProvider.GetService <ILoggerFactory>();

            var logger = factory.CreateLogger <Brainiac>();

            this.brain = new Brainiac(logger);
        }
Example #22
0
        private async Task <Board> ParseBoard()
        {
            if (_brain == null)
            {
                _brain = new CompositeBrain(_input);
            }

            _brain.Parse();
            var board = _brain.Board;

            return(board);
        }
Example #23
0
		public MeleeAttackAction(IBrain owner)
			: base(owner)
		{
			var ownerUnit = owner.Owner;
			var mainWep = ownerUnit.MainWeapon;

			m_range = new AIRange(mainWep.MinRange, mainWep.MaxRange);

			m_target = ownerUnit.Target;

			IsPrimary = false;
		}
Example #24
0
        public SpellCastAction(IBrain owner, Unit target, Spell spell) : base(owner)
        {
            m_ownerBrain = owner;
            m_target     = target;
            m_spell      = spell;

            if (m_target != null)
            {
                m_range = new AIRange(m_spell.Range.Min, m_spell.Range.Max);
            }

            IsPrimary = true;
        }
        protected BaseAdvancedRobot(IEnumerable <BaseBehavior> behaviours)
        {
            IContext context = new Context(this);

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

            _brain = new Brain(
                this,
                behaviours,
                context);
        }
Example #26
0
 public Robot(string name, IDictionary <string, string> config, LoggerConfigurator logConfig, IDictionary <string, IAdapter> adapters, IRouter router, IBrain brain, IScriptStore scriptStore, IScriptRunner scriptRunner)
     : this(logConfig)
 {
     _name         = name;
     _config       = config;
     _scriptStore  = scriptStore;
     _adapters     = adapters;
     _brain        = brain;
     _router       = router;
     _scriptRunner = scriptRunner;
     _isConfigured = true;
     Initialize(adapters.Values.ToArray().Concat(new object[] { router, brain, scriptRunner }).ToArray());
 }
Example #27
0
 public void SetClass(IClass clas, IBrain brain, God god)
 {
     _class     = clas;
     _brain     = brain;
     Health     = _class.Health;
     _maxHealth = _class.Health;
     Attack     = _class.Attack;
     Defense    = _class.Defense;
     Movement   = _class.Movement;
     //Initiative = _class.Initiative;
     Initiative      = Random.Range(0, 20) + _class.Initiative;
     InitiativeBonus = _class.Initiative;
     _god            = god;
 }
Example #28
0
        public void Init(Dictionary <Guid, int> manipulatableDimensions, List <IAction> actions, List <ISoul> soul,
                         IBrain iParentBrain)
        {
            var parentBrain = (Brain)iParentBrain;

            if (actions.Count == 0)
            {
                throw new ArgumentException("need at least one action");
            }
            _decisionMaker.Init(parentBrain._decisionMaker);
            _sequenceMaker.Init(parentBrain._sequenceMaker, manipulatableDimensions);
            _souls         = soul;
            _currentAction = actions[0];
        }
Example #29
0
        public Robot(string name, ILogger logger, IMessenger messenger, IBrain brain)
        {
            Name      = name;
            Logger    = logger;
            Messenger = messenger;
            Brain     = brain;

            Version = "1.0"; //todo replace harcoding of the version number

            _listeners = new List <Listener>();

            Settings = new AppSettings();

            _compositionManager = new CompositionManager(this);
        }
Example #30
0
        public void CreateNewBrain(int inputSignalCount)
        {
            IBrain brain = new Network(); //создаем мозг

            brain.Layers = new List <ILayer> {
                new Layer()
            };                                              //создаем список слоев //создаем входной слой
            brain.Layers[0].Neurons = new List <INeuron>(); //создаем список нейронов
            for (var i = 0; i < inputSignalCount; i++)
            {
                brain.Layers[0].Neurons.Add(new Neuron());  //добавляем новый нейрон в слой
            }
            brain.Layers.Add(new Layer());                  //создаем выходной слой
            brain.Layers[1].Neurons = new List <INeuron>(); //создаем список нейронов
            Brain = brain;
        }
Example #31
0
        public Being(string name, IBrain brain, IStomach stomach)
        {
            _stomach = stomach;
            _brain   = brain;
            _name    = name;

            _stomach.NeedsFoodEvent += (s, e) =>
            {
                Console.WriteLine($"{_name}: {e.Message}");
                _brain.OnRaiseIsHungryEvent();
            };

            _brain.IsHungryEvent += (s, e) =>
            {
                Console.WriteLine($"{_name}: {e.Message}");
            };
        }
Example #32
0
 public Player(IBrain brain, Players players)
 {
     m_Lock = new object();
     Brain  = brain;
     brain.EvolutionRequest += () =>
     {
         lock (m_Lock)
         {
             players.m_EvolutionRequests[brain] = true;
             if (players.m_EvolutionRequests.Values.All(v => v))
             {
                 players.EvolutionRequest?.Invoke();
             }
         }
     };
     brain.ShotDataReady += (data) => players.ShotDataReady?.Invoke(data);
 }
Example #33
0
 public AIAction this[BrainState state]
 {
     get { return(this.Actions[(int)state]); }
     set
     {
         AIAction action = this.Actions[(int)state];
         if (action == value)
         {
             return;
         }
         this.Actions[(int)state] = value;
         IBrain brain = this.m_owner.Brain;
         if (brain == null || brain.State != state || brain.CurrentAction != action)
         {
             return;
         }
         brain.CurrentAction = (IAIAction)value;
     }
 }
Example #34
0
 public void HandleStatusChange(Message message, IMessageClient client, IBrain brain, string query)
 {
     string time = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
     //string result = "wut";
     var userName = client.GetUser(message.UserId).Name;
     if (query.ToLower().StartsWith("in"))
     {
         //result = "i recognize " + message.UserId + " checked in at " + time;
         brain.SetValue(LastCheckinKey(userName), time);
         brain.RemoveKey(LastCheckoutKey(userName));
     }
     else if (query.ToLower().StartsWith("out"))
     {
         //result = "i recognize " + message.UserId + " checked out at " + time;
         brain.SetValue(LastCheckoutKey(userName), time);
         brain.RemoveKey(LastCheckinKey(userName));
     }
     //client.ReplyTo(message, result);
 }
Example #35
0
File: Status.cs Project: NBot/NBot
        public void HandleStatusChange(Message message, IMessageClient client, IBrain brain, string query)
        {
            string time = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
            //string result = "wut";
            var userName = client.GetUser(message.UserId).Name;

            if (query.ToLower().StartsWith("in"))
            {
                //result = "i recognize " + message.UserId + " checked in at " + time;
                brain.SetValue(LastCheckinKey(userName), time);
                brain.RemoveKey(LastCheckoutKey(userName));
            }
            else if (query.ToLower().StartsWith("out"))
            {
                //result = "i recognize " + message.UserId + " checked out at " + time;
                brain.SetValue(LastCheckoutKey(userName), time);
                brain.RemoveKey(LastCheckinKey(userName));
            }
            //client.ReplyTo(message, result);
        }
Example #36
0
        public void Register(Robot robot)
        {
            Brain = robot.Brain;

            robot.Respond(command, msg =>
            {
                var adapter = new MmbotResponseAdapter(msg);
                try
                {
                    CurrentUser = msg.Message.User;
                    Execute(msg.Match.Select(CleanupLinkFormattedMatches).ToArray(), adapter)
                         .Wait();
                }
                catch (Exception ex)
                {
                    adapter.Send(ex.ToString());
                    throw;
                }
            });
        }
Example #37
0
        public Analyser(IBrain brain)
        {
            _brain     = brain;
            _stopwatch = new Stopwatch();

            var directory = $"{Environment.CurrentDirectory}\\analyses";

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }
            var file = $"{directory}\\analyses{DateTime.Now.ToString("yyyyMMddHHmmss")}";

            if (File.Exists(file))
            {
                File.Delete(file);
            }
            _writer = new StreamWriter(file);
            _writer.WriteLine($"index;captured;milliseconds;score;value;place;top5-1;top5-2;top5-3;top5-4;top5-5;A;B;C;D;E;F;a;b;c;d;e;f");
        }
Example #38
0
        public void HandleGetStatus(Message message, IMessageClient client, IBrain brain, string userName)
        {
            string result = userName;
            bool needsAnd = false;
            bool neverSeenThem = true;

            if (brain.ContainsKey(LastCheckinKey(userName)))
            {
                result += " last checked in at " + brain.GetValue(LastCheckinKey(userName));
                neverSeenThem = false;
                needsAnd = true;
            }

            if (brain.ContainsKey(LastCheckoutKey(userName)))
            {
                if (needsAnd)
                {
                    result += ",";
                }
                result += " last checked out at " + brain.GetValue(LastCheckoutKey(userName));
                neverSeenThem = false;
                needsAnd = true;
            }

            if (brain.ContainsKey(LastSpokeKey(userName)))
            {
                if (needsAnd)
                {
                    result += " and";
                }
                result += " last spoke at " + brain.GetValue(LastSpokeKey(userName));
                neverSeenThem = false;
            }

            if (neverSeenThem)
            {
                result = "I ain't never seen " + userName + " come round these parts";
            }

            client.ReplyTo(message, result);
        }
Example #39
0
		public override void Dispose(bool disposing)
		{
			if (m_auras == null)
			{
				// already disposed
				return;
			}

			if (m_Movement != null)
			{
				m_Movement.m_owner = null;
				m_Movement = null;
			}

			base.Dispose(disposing);

			m_attackTimer = null;
			m_target = null;

			if (m_brain != null)
			{
				m_brain.Dispose();
				m_brain = null;
			}
			
			m_spells.Recycle();
			m_spells = null;

			m_auras.Owner = null;
			m_auras = null;

			m_charm = null;
			m_channeled = null;
		}
Example #40
0
        public void RememberMeSomeStuff(Message message, IMessageClient client, IBrain brain, string value, string key)
        {
            brain.SetValue(key, value);

            client.ReplyTo(message, string.Format("{0} stored as {1}", value, key));
        }
Example #41
0
 public Eyes(IScreenCapturer screenCapturer, IBrain brain, IBoardLogger boardLogger)
 {
     this.screenCapturer = screenCapturer;
     this.brain = brain;
     this.boardLogger = boardLogger;
 }
Example #42
0
 public void Register(IBrain brain)
 {
     Brain = brain;
 }
Example #43
0
 public void Think(IBrain brain)
 {
     throw new NotImplementedException();
 }
Example #44
0
 public void RegisterBrain(IBrain brain)
 {
     _brain = brain;
 }
Example #45
0
 public MessageRouter(IBrain brain)
 {
     _brain = brain;
 }
Example #46
0
 public void RecallMeSomeStuff(Message message, IMessageClient client, IBrain brain, string key)
 {
     object value = brain.GetValue(key);
     client.ReplyTo(message, value == null ? string.Format("The key {0} is not in the brain.", key) : string.Format("The value of {0} is {1}", key, value));
 }
Example #47
0
 /// <summary>
 /// Builds up the relation between the brain and the cell
 /// </summary>
 /// <param name="newBrain">The IBrain to use</param>
 public void SetBrain(IBrain newBrain)
 {
     this.Brain = newBrain;
     (this.Brain as BaseBrain).SetCell(this);
 }
Example #48
0
 public HandleBarsMessageFilter(IBrain brain)
 {
     _brain = brain;
 }
Example #49
0
		public override void Dispose(bool disposing)
		{
			if (m_auras == null)
			{
				// already disposed
				return;
			}

			if (m_Movement != null)
			{
				m_Movement.m_owner = null;
				m_Movement = null;
			}

			base.Dispose(disposing);

			m_attackTimer = null;

			if (m_target != null)
			{
				OnTargetNull();
				m_target = null;
			}

			if (m_regenTimer != null)
			{
				m_regenTimer.Dispose();
			}

			if (m_brain != null)
			{
				m_brain.Dispose();
				m_brain = null;
			}

			if (m_spells != null)
			{
				m_spells.Owner = null;
				m_spells = null;
			}

			m_auras.Owner = null;
			m_auras = null;

			if (m_areaAura != null)
			{
				m_areaAura.Holder = null;
				m_areaAura = null;
			}

			m_charm = null;
			m_channeled = null;
		}
Example #50
0
		public BossPhase(IBrain owner)
		{
			m_owner = owner;
		}