Example #1
0
        public void StartGame(GameStartupParameters parameters, Agents.BaseAgent[] agents)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }
            else if (agents == null)
            {
                throw new ArgumentNullException("agents");
            }
            else if (parameters.PlayerDecks.Count != agents.Length)
            {
                throw new InvalidOperationException("PlayerDecks and agents shall have the same length.");
            }

            Agents = agents.ToIndexable();

            m_game = new Game(parameters.PlayerIds, new XnaUIController(agents, parameters.Seed));
            m_game.Initialize(parameters.PlayerDecks);

            GameApp.Service<GameUI>().GameCreated(m_game);
            GameApp.Service<Graphics.Scene>().GameCreated();

            m_game.StartGameFlowThread();
            GameApp.Service<Sound>().PlayMusic(Sound.MusicEnum.kagamiM);
        }
Example #2
0
    protected void ResultsObjectDataSource_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
    {
        Agents agents;

        agents = Session["AgentsViewState"] as Agents;

        if (agents == null)
        {
            agents = new Agents();
        }
        e.ObjectInstance = agents;
    }
Example #3
0
        public void RegisterClientAsAgent(ulong clientId, string message)
        {
            var client = JoiningAgents.Where(q => q.ID == clientId).FirstOrDefault();

            JoiningAgents.Remove(client);

            client.MessageInterpreter = new AgentInterpreter(this);
            var agent = new AGENT(client);

            Agents.Add(agent);
            client.BeginSend(message);
        }
        public async Task <IActionResult> Create([Bind("AgentId,AgtFirstName,AgtMiddleInitial,AgtLastName,AgtBusPhone,AgtEmail,AgtPosition,AgencyId")] Agents agents)
        {
            if (ModelState.IsValid)
            {
                _context.Add(agents);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AgencyId"] = new SelectList(_context.Agencies, "AgencyId", "AgencyId", agents.AgencyId);
            return(View(agents));
        }
        private void SupprimerAgent(object sender, RoutedEventArgs e)
        {
            Agents selection = (Agents)lvAgents.SelectedItem;

            if (selection != null)
            {
                if (MessageBox.Show($"Etes-vous sur de vouloir supprimer l'agent {selection.NomComplet} de la liste ?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    Statics.TryCatch(() => { BDD.SupprimerAgent(selection); }, nameof(SupprimerAgent));
                }
            }
        }
 /// <summary>
 /// Hide Agent Creation Menu
 /// </summary>
 public void SpawnAgent(string agentType)
 {
     // Debug.Log("Spawning Agent");
     foreach (Agents agent in units)
     {
         if (agent.unitType == Agents.GetAgentFromString(agentType))
         {
             Instantiate(agent.gameObject, newAgentPosition, newAgentRotation);
         }
     }
     creationMenu.SetActive(false);
 }
Example #7
0
        private void PopulateAgents()
        {
            foreach (agentType agent in Model.Agents)
            {
                SupervisedAgentViewModel avm = CreateAgentViewModel(agent);

                avm.PropertyChanged += AvmPropertyChanged;
                avm.Monitored       += AvmMonitored;

                Agents.Add(avm);
            }
        }
 /// <summary>
 /// Stops the execution of the agent and removes it from the environment. Use the Remove method instead of Agent.Stop
 /// when the decision to stop an agent does not belong to the agent itself, but to some other agent or to an external factor.
 /// </summary>
 /// <param name="agent">The agent to be removed</param>
 public void Remove(TurnBasedAgent agent)
 {
     if (Agents.Contains(agent))
     {
         Agents.Remove(agent);
         AgentsDict.Remove(agent.Name);
     }
     else
     {
         throw new Exception("Agent " + agent.Name + " does not exist (TurnBasedAgent.Remove)");
     }
 }
Example #9
0
 public bool Remove(Agents.Agent agent)
 {
     foreach (GraphNode gn in nodes)
       {
     if (gn.Value.Equals(agent))
     {
       nodes.Remove(gn);
       return true;
     }
       }
       return false;
 }
 public async Task <int> AgentRegistration([FromBody] Agents obj)
 {
     try
     {
         return(await this._Agent.AgentRegistration(obj));
     }
     catch (Exception ex)
     {
         Logger.LogError($"Something went wrong inside AgentController AgentRegistration action: {ex.Message}");
         return(-1);
     }
 }
Example #11
0
        internal void HealMe(Block block)
        {
            if (Doctors.TryGetValue(block, out Doctor doctor))
            {
                doctor.Heal(block);
            }

            if (Agents.TryGetValue(block, out Agent agent))
            {
                agent.Safe(block);
            }
        }
Example #12
0
        public async Task <IActionResult> PostAgents([FromBody] Agents agents)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Agents.Add(agents);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAgents", new { id = agents.AgentId }, agents));
        }
Example #13
0
        internal void HandleMoveTaskInventory(Message m)
        {
            var req = (MoveTaskInventory)m;

            if (req.CircuitAgentID != req.AgentID ||
                req.CircuitSessionID != req.SessionID)
            {
                return;
            }

            IAgent agent;

            if (!Agents.TryGetValue(req.AgentID, out agent))
            {
                return;
            }

            ObjectPart part;

            if (!Primitives.TryGetValue(req.LocalID, out part))
            {
                return;
            }

            ObjectPartInventoryItem item;

            if (!part.Inventory.TryGetValue(req.ItemID, out item))
            {
                return;
            }

            var newItem = new InventoryItem(item);

            if (item.CheckPermissions(agent.Owner, agent.Group, InventoryPermissionsMask.Copy))
            {
                /* permissions okay */
            }
            else if (CanEdit(agent, part.ObjectGroup, part.ObjectGroup.GlobalPosition))
            {
                part.Inventory.Remove(item.ID);
            }
            else
            {
                /* we cannot edit */
                return;
            }
            new ObjectTransferItem(agent,
                                   this,
                                   newItem.AssetID,
                                   new List <InventoryItem>(new InventoryItem[] { newItem }),
                                   req.FolderID, newItem.AssetType).QueueWorkItem();
        }
        public void AddAgent(AgentConnection agent)
        {
            agent.Session            = this;
            agent.OnOpen            += () => ConnectionOpen(agent);
            agent.OnClose           += () => ConnectionClose(agent);
            agent.OnConnectionError += (message) => ConnectionError(agent, message);
            agent.OnMessage         += (payload) => MessageReceived(agent, payload);

            if (!Agents.ContainsKey(agent.Address))
            {
                Agents.Add(agent.Address, agent);
            }
        }
Example #15
0
        public void AddClient(AgentConnection client)
        {
            client.Session            = this;
            client.OnOpen            += () => ConnectionOpen(client);
            client.OnClose           += () => ConnectionClose(client);
            client.OnConnectionError += (message) => ConnectionError(client, message);
            client.OnMessage         += (payload) => MessageReceived(client, payload);

            if (!Agents.ContainsKey(client.Address))
            {
                Agents.Add(client.Address, client);
            }
        }
Example #16
0
 /// <summary>
 /// Stops the execution of the agent identified by name and removes it from the environment. Use the Remove method instead of Agent.Stop
 /// when the decision to stop an agent does not belong to the agent itself, but to some other agent or to an external factor.
 /// </summary>
 /// <param name="agentName">The name of the agent to be removed</param>
 override public void Remove(string agentName)
 {
     if (AgentsDict.ContainsKey(agentName))
     {
         TurnBasedAgent ag = AgentsDict[agentName];
         Agents.Remove(ag);
         AgentsDict.Remove(agentName);
     }
     else
     {
         throw new Exception("Agent " + agentName + " does not exist (TurnBasedAgent.Remove)");
     }
 }
Example #17
0
        public Tuple <Agent, bool> GetAgent(List <Guid> contactResponsibles)
        {
            var result = Agents.FirstOrDefault(r => r.Status == AgentStatus.Online && contactResponsibles.Contains(r.Id)) ??
                         Agents.FirstOrDefault(r => r.Status == AgentStatus.Online);
            var isAnyNotOffline = Agents.Any();

            if (result != null)
            {
                result.Status = AgentStatus.Paused;
            }

            return(new Tuple <Agent, bool>(result, isAnyNotOffline));
        }
 public void DecideRoles()
 {
     // Manager Role
     Manager      = Agents.First(a => a.CleanedCells.Count == Agents.Max(p => p.CleanedCells.Count));
     Manager.Role = ContractRole.Manager;
     // Contract Roles
     Contractors = new List <MasCleaningAgent>(Agents.Where(a => a.Id != Manager.Id));
     foreach (var cleaningAgent in Contractors)
     {
         cleaningAgent.Role = ContractRole.Contractor;
     }
     (Contractors as List <MasCleaningAgent>).Add(Manager);
 }
Example #19
0
        public void AddOrUpdateAgent(Agent agent)
        {
            var existingAgent = Agents.FirstOrDefault(r => r.Id == agent.Id);

            if (existingAgent != null)
            {
                existingAgent.Status = agent.Status;
            }
            else
            {
                Agents.Add(agent);
            }
        }
        private void CommitAgents()
        {
            if (HasErrors)
            {
                return;
            }

            var agents = Agents.Select(x => x.CreateEntity()).ToList();

            _agentRepo.Store(agents);

            IsDirty = false;
        }
Example #21
0
        public bool CheckDuplicateAgentname(string AgentName)
        {
            Agents agent = db.Agents.Where(ii => ii.AgentName == AgentName).FirstOrDefault();

            if (agent != null)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Example #22
0
        public void HandleParcelSelectObjects(Message m)
        {
            var req = (ParcelSelectObjects)m;

            if (req.AgentID != req.CircuitAgentID ||
                req.SessionID != req.CircuitSessionID)
            {
                return;
            }

            ParcelInfo pinfo;
            IAgent     agent;
            var        reply = new ForceObjectSelect
            {
                ResetList = true
            };

            if (Agents.TryGetValue(req.AgentID, out agent) && Parcels.TryGetValue(req.LocalID, out pinfo))
            {
                foreach (Object.ObjectGroup grp in ObjectGroups)
                {
                    if (grp.IsAttached)
                    {
                        continue;
                    }

                    if (!pinfo.LandBitmap.ContainsLocation(grp.GlobalPosition))
                    {
                        continue;
                    }

                    bool isOwner = grp.Owner.EqualsGrid(pinfo.Owner);

                    if (((req.ReturnType & ObjectReturnType.Owner) != 0 && isOwner) ||
                        ((req.ReturnType & ObjectReturnType.Other) != 0 && !isOwner) ||
                        ((req.ReturnType & ObjectReturnType.Group) != 0 && grp.Group == pinfo.Group) ||
                        ((req.ReturnType & ObjectReturnType.Sell) != 0 && grp.SaleType != InventoryItem.SaleInfoData.SaleType.NoSale) ||
                        ((req.ReturnType & ObjectReturnType.List) != 0 && req.ReturnIDs.Contains(grp.ID)))
                    {
                        if (reply.LocalIDs.Count >= 251)
                        {
                            agent.SendMessageAlways(reply, ID);
                            reply = new ForceObjectSelect();
                        }
                        reply.LocalIDs.Add(grp.LocalID[ID]);
                    }
                }

                agent.SendMessageAlways(reply, ID);
            }
        }
Example #23
0
        // ***********************************************************************************
        ////// Setting of session For Specific user login
        // ***********************************************************************************
        public void SetSessionsObject(Guid userId)
        {
            Agents        ainfo = null;
            TravelSession obj   = new TravelSession();
            aspnet_Users  tu    = GetUserInfo(userId);

            try
            {
                ainfo = GetAgentInfo(tu.UserId);
            }
            catch (Exception)
            {
            }

            UsersDetails udinfo = GetUserDetailsInfo(userId);

            if (udinfo.UserTypeId == 5)
            {
                BranchOfficeManagementProvider branchOfficeManagementProvider = new BranchOfficeManagementProvider();
                View_BranchDetails             branchOffices = branchOfficeManagementProvider.GetBranchOfficeByUserId(userId);

                obj.LoginTypeName = branchOffices.BranchOfficeName;
                obj.AgentCode     = branchOffices.BranchOfficeName;
                obj.LoginTypeId   = branchOffices.BranchOfficeId;
            }
            else if (udinfo.UserTypeId == 6)
            {
                DistributorManagementProvider distributorManagementProvider = new DistributorManagementProvider();
                View_DistributorDetails       distributors = distributorManagementProvider.GetDistributorByUserId(userId);

                obj.LoginTypeName = distributors.DistributorName;
                obj.AgentCode     = distributors.DistributorName;
                obj.LoginTypeId   = distributors.DistributorId;
            }
            else if (udinfo.UserTypeId == 7)
            {
                obj.Id         = userId;
                obj.LoginName  = tu.UserName;
                obj.AppUserId  = udinfo.AppUserId;
                obj.UserTypeId = udinfo.UserTypeId;
                obj.ProductId  = GetUserProductId(obj.AppUserId);
            }

            obj.Id         = userId;
            obj.LoginName  = tu.UserName;
            obj.AppUserId  = udinfo.AppUserId;
            obj.UserTypeId = udinfo.UserTypeId;
            obj.ProductId  = GetUserProductId(obj.AppUserId);

            HttpContext.Current.Session["TravelPortalSessionInfo"] = obj;
        }
    protected void AgentCountries_SelectedIndexChanged(object sender, EventArgs e)
    {
        AgentsAdapter.SelectCommand.Parameters["@Country"].Value = AgentCountries.SelectedValue;
        AgentsAdapter.SelectCommand.Parameters["@UserID"].Value  = userid;

        //lock (CommonFunctions.Connection)
        AgentsAdapter.Fill(MainDataSet, "Agents");
        Agents.DataSource     = MainDataSet;
        Agents.DataMember     = "Agents";
        Agents.DataValueField = "ID";
        Agents.DataTextField  = "FullName";

        Agents.DataBind();
    }
        protected override void Reconfigure()
        {
            var isReconfPossible = IsReconfPossible(_availableRobots, Tasks);

            if (!isReconfPossible)
            {
                OracleState = ReconfStates.Failed;
            }
            else if (OracleState != ReconfStates.Failed)
            {
                OracleState = ReconfStates.Succedded;
            }

            // find optimal path that satisfies the required capabilities
            CalculateShortestPaths();
            var path  = FindPath(Tasks[0]);
            var roles = path == null ? null : Convert(Tasks[0], path).ToArray();

#if ENABLE_F5
            var length = roles?.Sum(role => Math.Max(role.Item2.Length, 1));
            if (roles == null || length > 2 * Tasks[0].Capabilities.Length)
#else
            if (roles == null)
#endif
            {
                if (isReconfPossible)
                {
                    throw new Exception("Reconfiguration failed even though there is a solution.");
                }
                ReconfigurationState = ReconfStates.Failed;
            }
            else
            {
                ApplyConfiguration(roles);
                if (!isReconfPossible)
                {
                    throw new Exception("Reconfiguration successful even though there is no valid configuration.");
                }
                if (ReconfigurationState != ReconfStates.Failed)
                {
                    ReconfigurationState = ReconfStates.Succedded;
                }
            }

            // validate invariant
            if (!Agents.All(agent => agent.ValidateConstraints()))
            {
                throw new Exception("Reconfiguration violated constraints");
            }
        }
        // GET: Agent/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Agents agents = db.Agents.Find(id);

            if (agents == null)
            {
                return(HttpNotFound());
            }
            return(View(agents));
        }
Example #27
0
        // GET: Agents/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Agents agents = await db.Agents.FindAsync(id);

            if (agents == null)
            {
                return(HttpNotFound());
            }
            return(View(agents));
        }
        public ActionResult Edit(int agentId, EditAgent agent)
        {
            AgentRepository repository = new AgentRepository();

            Agents agentToUpdate = new Agents
            {
                id        = agent.agentId,
                Contracts = repository.GetById(agentId).Contracts,
                name      = agent.agentName
            };

            repository.Update(agentToUpdate);
            return(RedirectToAction("Index"));
        }
Example #29
0
 /// <summary>
 /// Adds an agent to the environment. Its name should be unique.
 /// </summary>
 /// <param name="agent">The concurrent agent that will be added</param>
 /// <param name="name">The name of the agent</param>
 public void Add(TurnBasedAgent agent, string name)
 {
     if (AgentsDict.ContainsKey(name))
     {
         throw new Exception("Trying to add an agent with an existing name: " + name + " (TurnBasedEnvironment.Add(agent, name))");
     }
     else
     {
         agent.Name        = name;
         agent.Environment = this;
         Agents.Add(agent);
         AgentsDict[name] = agent;
     }
 }
        public IEnumerable <EngineAgent <TAgent, TObject> > GetFreeList()
        {
            if (Agents.Count == 0)
            {
                throw new ArgumentException("No agents defined");
            }
            var eng = Agents.First(x => !x.InUse);

            if (eng == null)
            {
                yield break;
            }
            yield return(eng);
        }
        public AgentsViewModel(IAgentRepository agentRepo, IViewModelFactory vmFactory,
                               IUserInteraction ui)
        {
            _agentRepo = agentRepo;
            _vmFactory = vmFactory;

            var agentVms = agentRepo.GetAll().Select(x => CreateAgentViewModel(x));

            Agents.ReplaceItems(agentVms);

            AddAgentCommand = new ActionCommand(o =>
            {
                Agents.Add(CreateAgentViewModel(null));
                IsDirty = true;
            });

            DeleteAgentCommand = new ActionCommand(_ =>
            {
                var selectedAgent = Agents.FirstOrDefault(x => x.IsSelected);
                if (selectedAgent == null)
                {
                    ui.ShowWarning("No agent selected.");
                    return;
                }
                if (!ui.AskForConfirmation($"Are you sure you want to delete the selected '{selectedAgent.Id}' agent?", "Delete agent"))
                {
                    return;
                }

                Agents.Remove(selectedAgent);
                if (!string.IsNullOrEmpty(selectedAgent.Id))
                {
                    agentRepo.Delete(selectedAgent.Id);
                }
            });

            CommitAgentsCommand = new ActionCommand(_ => CommitAgents(),
                                                    _ => IsDirty && !HasErrors);

            ResetChangesCommand = new ActionCommand(_ => {
                foreach (var agent in Agents)
                {
                    agent.ResetForm();
                }
                IsDirty = false;
            }, _ => IsDirty);

            PropertiesAreInitialized = true;
        }
Example #32
0
        public void HandleParcelReturnObjects(Message m)
        {
            var req = (ParcelReturnObjects)m;

            if (req.AgentID != req.CircuitAgentID ||
                req.SessionID != req.CircuitSessionID)
            {
                return;
            }

            ParcelInfo pinfo = null;
            IAgent     agent;
            var        returnlist = new List <UUID>();

            if (Agents.TryGetValue(req.AgentID, out agent) && (req.LocalID == -1 || Parcels.TryGetValue(req.LocalID, out pinfo)))
            {
                foreach (Object.ObjectGroup grp in ObjectGroups)
                {
                    if (grp.IsAttached)
                    {
                        continue;
                    }

                    if (pinfo != null && !pinfo.LandBitmap.ContainsLocation(grp.GlobalPosition))
                    {
                        continue;
                    }

                    bool isOwner = grp.Owner.EqualsGrid(pinfo.Owner);

                    if (!CanReturn(agent, grp, grp.GlobalPosition))
                    {
                        continue;
                    }

                    if (((req.ReturnType & ObjectReturnType.Owner) != 0 && isOwner) ||
                        ((req.ReturnType & ObjectReturnType.Other) != 0 && !isOwner) ||
                        ((req.ReturnType & ObjectReturnType.Group) != 0 && grp.Group == pinfo.Group) ||
                        ((req.ReturnType & ObjectReturnType.Sell) != 0 && grp.SaleType != InventoryItem.SaleInfoData.SaleType.NoSale) ||
                        ((req.ReturnType & ObjectReturnType.List) != 0 && req.TaskIDs.Contains(grp.ID)) ||
                        ((req.ReturnType & ObjectReturnType.List) != 0 && req.OwnerIDs.Contains(grp.Owner.ID)))
                    {
                        returnlist.Add(grp.ID);
                    }
                }
            }

            ReturnObjects(agent.Owner, returnlist);
        }
Example #33
0
        private void OpenFileCommand_Executed(object sender, RoutedEventArgs e)
        {
            #region SettingUp OpenDialog
            // Set filter for file extension and default file extension
            dlg.Filter = "All Files (*.*)|*.*|Text documents (*.txt)|*.txt|XML Files (*.xml;*.xsl;*xsd;*dtd)|*.xml;*.xsl;*xsd;*dtd";

            // Display OpenFileDialog by calling ShowDialog method
            Nullable<bool> result = dlg.ShowDialog();

            #endregion //  SettingUp OpenDialog

            #region Load the object

            filename = dlg.SafeFileName;
            Agents tempAgents = new Agents();

            // Create an instance of the XmlSerializer class and specify the type of object to serialize.
            XmlSerializer serializer = new XmlSerializer(typeof(Agents));
            try
            {
                TextReader reader = new StreamReader(filename);
                // Deserialize all the agents.
                tempAgents = (Agents)serializer.Deserialize(reader);
                reader.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Unable to open file", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            // We have to insert the agents in the existing collection. If we just assign tempAgents to agents then the bindings to agents will brake!
            agentCollection.Clear();
            foreach (var agent in tempAgents)
                agentCollection.Add(agent);

            #endregion // Load the object
        }
Example #34
0
 public XnaUIController(Agents.BaseAgent[] agents, int seed)
 {
     m_agents = agents;
     Agents = m_agents.ToIndexable();
     RandomSeed = seed;
 }
Example #35
0
 public ToolbarButton(string module, string name, Agents agent,
     string on_enabled_check, string on_pushed_check, string on_click, 
     bool show_in_context_menu)
     : base(module, name, agent)
 {
     this.OnEnabledCheck = on_enabled_check;
     this.OnPushedCheck = on_pushed_check;
     this.OnClick = on_click;
     this.ShowInContextMenu = show_in_context_menu;
 }
Example #36
0
 public ToolbarDropdown(string module, string name, Agents agent,
     ConfigurationItem data, string on_enabled_check, string on_status_check,
     string on_change)
     : base(module, name, agent)
 {
     if (data != null && !data.IsValueItem)
     {
         this.Data = new ListItemCollection();
         foreach(XmlNode item in data.XmlNode.ChildNodes)
             this.Data.Add(new ListItem(item.Attributes["value"].Value, item.Attributes["name"].Value));
     }
     this.OnEnabledCheck = on_enabled_check;
     this.OnStatusCheck = on_status_check;
     this.OnChange = on_change;
 }
Example #37
0
 public ToolbarImage(string module, string name, Agents agent)
     : base(module, name, agent)
 {
 }
Example #38
0
 public ToolbarItem(string module, string name, Agents agent)
 {
     this.Module = module;
     this.Name = name;
     this.Agent = agent;
 }