예제 #1
0
 public EditRoleViewModel(AgentRole role)
 {
     this.RoleID           = role.Id;
     this.OriginalRoleName = role.Name;
     this.RoleName         = role.Name;
     this.Description      = role.Description;
 }
예제 #2
0
 public void JoinBlueTeam(AgentRole role)
 {
     agentRole = role;
     team      = Team.Blue;
     m_AgentRenderer.material = m_Academy.blueMaterial;
     tag = "blueAgent";
 }
예제 #3
0
 public void JoinBlueTeam(AgentRole role)
 {
     agentRole = role;
     team      = Team.Blue;
     m_AgentRenderer.material = m_SoccerSettings.blueMaterial;
     tag = "blueAgent";
 }
예제 #4
0
 public void JoinRedTeam(AgentRole role)
 {
     agentRole = role;
     team      = Team.Red;
     agentRenderer.material = academy.redMaterial;
     tag = "redAgent";
 }
예제 #5
0
 public AgentStateStatic(AgentStateStatic clone)
 {
     name        = clone.name;
     role        = clone.role;
     hasHashCode = clone.hasHashCode;
     hashCode    = clone.hashCode;
 }
예제 #6
0
 public void JoinPurpleTeam(AgentRole role)
 {
     agentRole = role;
     team      = Team.Purple;
     m_AgentRenderer.material = m_Academy.purpleMaterial;
     tag = "purpleAgent";
 }
예제 #7
0
        public void Elevate(int aimFloor, int currentAgentFloor, AgentRole role)
        {
            switch (elevatorStatus)
            {
            case ElevatorStatus.Down:
                GoDown(aimFloor, currentAgentFloor, role);
                break;

            case ElevatorStatus.Up:
                GoUp(aimFloor, currentAgentFloor, role);
                break;

            case ElevatorStatus.Stopped:
                if (CurrentFloor < currentAgentFloor)
                {
                    GoUp(aimFloor, currentAgentFloor, role);
                }
                else if (CurrentFloor > currentAgentFloor)
                {
                    GoDown(aimFloor, currentAgentFloor, role);
                }
                else
                {
                    Stop(aimFloor, currentAgentFloor, role);
                }
                break;
            }
        }
예제 #8
0
 public void JoinPurpleTeam(AgentRole role)
 {
     agentRole = role;
     team      = Team.Purple;
     m_AgentRenderer.material = m_SoccerSettings.purpleMaterial;
     tag = "purpleAgent";
 }
 public void JoinPurpleTeam(AgentRole role)               // 퍼플팀의 역할을 부여, 초기화 관련 함수
 {
     agentRole = role;                                    // 역할
     team      = Team.Purple;                             // 퍼플팀에 넣음
     m_AgentRenderer.material = m_Academy.purpleMaterial; // 채색
     tag = "purpleAgent";                                 //퍼플에이전트로 태깅
 }
예제 #10
0
 /// <summary>
 /// Method-constructor of the static part of the agent (without input parameters).
 /// </summary>
 public AgentStateStatic()
 {
     name        = "";
     role        = AgentRole.USUAL;
     hasHashCode = false;
     hashCode    = 0;
 }
예제 #11
0
 public BeliefsAboutAgent(AgentStateStatic info, AgentRole role, bool isAlive, LocationStatic inLocation, AgentAngryAt angryAt)
 {
     this.info       = info;
     this.role       = role;
     this.isAlive    = isAlive;
     this.inLocation = inLocation;
     this.angryAt    = angryAt;
 }
예제 #12
0
        public NetworkAgent(AgentRole role, string tag) {
            _role = role;
            _config = new NetPeerConfiguration(tag);

            _incomingMessages = new List<NetIncomingMessage>();
    
            Initialize();
        }
예제 #13
0
 /// <summary>
 /// Method-constructor of the static part of the agent (with input parameters).
 /// </summary>
 /// <param name="name"></param>
 /// <param name="role"></param>
 public AgentStateStatic(string name, AgentRole role)
 {
     // We assign the specified name and role.
     SetName(name);
     AssignRole(role);
     hasHashCode = false;
     hashCode    = 0;
 }
예제 #14
0
 public BeliefsAboutAgent()
 {
     info       = new AgentStateStatic();
     role       = AgentRole.USUAL;
     isAlive    = true;
     inLocation = new LocationStatic();
     angryAt    = new AgentAngryAt();
 }
예제 #15
0
 public BeliefsAboutAgent(BeliefsAboutAgent clone)
 {
     info       = (AgentStateStatic)clone.info.Clone();
     role       = clone.role;
     isAlive    = clone.isAlive;
     inLocation = (LocationStatic)clone.inLocation.Clone();
     angryAt    = (AgentAngryAt)clone.angryAt.Clone();
 }
예제 #16
0
 public void JoinBlueTeam(AgentRole role)
 {
     agentRole = role;
     team      = Team.blue;
     for (int i = 0; i < transform.GetChild(0).childCount; ++i)
     {
         transform.GetChild(0).GetChild(i).gameObject.GetComponent <Renderer>().material = academy.blueMaterial;
     }
 }
예제 #17
0
        public NetworkAgent(AgentRole role, string tag)
        {
            _role   = role;
            _config = new NetPeerConfiguration(tag);

            _incomingMessages = new List <NetIncomingMessage>();

            Initialize();
        }
        /// <summary>
        /// Returns the first founded agent with the specified role.
        /// </summary>
        /// <param name="role"></param>
        public KeyValuePair <AgentStateStatic, AgentStateDynamic> GetAgentByRole(AgentRole role)
        {
            foreach (var agent in agents.Where(a => a.Key.GetRole().Equals(role)))
            {
                return(agent);
            }

            throw new KeyNotFoundException();
        }
예제 #19
0
        public KeyValuePair <AgentStateStatic, AgentRole> GetAgentByRole(AgentRole role)
        {
            foreach (var agent in agentsInWorld)
            {
                if (agent.GetRole() == role)
                {
                    return(new KeyValuePair <AgentStateStatic, AgentRole>(agent.GetInfo(), agent.GetRole()));
                }
            }

            throw new KeyNotFoundException();
        }
예제 #20
0
 public bool CanGetOffElevator(int chosenFloor, AgentRole role)
 {
     if (role == AgentRole.Confidential && chosenFloor > 0)
     {
         return(false);
     }
     else if (role == AgentRole.Secret && chosenFloor >= 2)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
예제 #21
0
 public void GoDown(int aimFloor, int currentAgentFloor, AgentRole role)
 {
     elevatorStatus = ElevatorStatus.Down;
     for (int i = CurrentFloor; i >= 0; i--)
     {
         Thread.Sleep(1000);
         Console.WriteLine($"The Elevator is on {i + 1} floor.");
         if (currentAgentFloor == i)
         {
             Stop(aimFloor, i, role);
             break;
         }
         else
         {
             continue;
         }
     }
 }
        public void AddAgent(AgentRole role, bool status, string name)
        {
            AgentStateStatic  newAgentStateStatic  = new AgentStateStatic();
            AgentStateDynamic newAgentStateDynamic = new AgentStateDynamic();

            newAgentStateStatic.AssignRole(role);
            newAgentStateStatic.SetName(name);
            newAgentStateDynamic.SetStatus(status);

            agents.Add(newAgentStateStatic, newAgentStateDynamic);

            // Очистка
            newAgentStateStatic  = null;
            newAgentStateDynamic = null;
            GC.Collect();

            UpdateHashCode();
        }
예제 #23
0
 public MessageQueueRunner(string id, AgentRole role, TimeSpan delayMin, TimeSpan delayMax)
 {
     this.Id       = id;
     this.Role     = role;
     this.DelayMin = delayMin;
     this.DelayMax = delayMax;
     this.TimeLine = new RobustTimeLine(
         TimeSpan.FromSeconds(5),
         onCompleted: (histo, idx) =>
     {
         Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "{0,3} | {1} | {2,6:#,##0.0} ms (+/- {3:#0.0})", idx, histo.GetDistribution(1, 5000 - 1), histo.Median, histo.MedianAbsoluteDeviation()));
         if (idx % 30 == 29)
         {
             Console.WriteLine(this.TimeLine.MergeResults().GetReport(true));
             return(true);
         }
         return(false);
     }
         );
 }
		public MessageQueueRunner(string id, AgentRole role, TimeSpan delayMin, TimeSpan delayMax)
		{
			this.Id = id;
			this.Role = role;
			this.DelayMin = delayMin;
			this.DelayMax = delayMax;
			this.TimeLine = new RobustTimeLine(
				TimeSpan.FromSeconds(5),
				onCompleted: (histo, idx) =>
				{
					Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "{0,3} | {1} | {2,6:#,##0.0} ms (+/- {3:#0.0})", idx, histo.GetDistribution(1, 5000 - 1), histo.Median, histo.MedianAbsoluteDeviation()));
					if (idx % 30 == 29)
					{
						Console.WriteLine(this.TimeLine.MergeResults().GetReport(true));
						return true;
					}
					return false;
				}
			);
		}
예제 #25
0
        private async Task <AgentRole[]> SetAgentRoleCode(long agentId, AgentRole[] requestedAgentRoles)
        {
            if (requestedAgentRoles == null || requestedAgentRoles.Length == 0)
            {
                return(null);
            }
            var getAgentResp = await _client.GetAgentAsync(new GetAgentRequest
            {
                ContractVersion        = _navApiContractVer,
                MessageContractVersion = _navMsgContractVer,
                Signature = await _sessionBag.Signature(),
                EnableExceptionStackTrace = false,
                GetAgentReqData           = new GetAgentRequestData
                {
                    GetAgentBy = nskCommonEnum.GetAgentBy.AgentID,
                    AgentID    = agentId,
                    GetDetails = true
                }
            });

            var requestedAgentRoleCode = requestedAgentRoles[0].RoleCode;

            if (getAgentResp.Agent.AgentRoles.ToList().Exists(p => p.RoleCode == requestedAgentRoleCode))
            {
                // no role change
                return(null);
            }
            var updatedRoles = new AgentRole[getAgentResp.Agent.AgentRoles.Length + 1];

            // delete currently assigned roles
            for (var i = 0; i < getAgentResp.Agent.AgentRoles.Length; i++)
            {
                var role = getAgentResp.Agent.AgentRoles[i];
                role.State      = nskCommonEnum.MessageState.Deleted;
                updatedRoles[i] = role;
            }
            // assign new role requested
            updatedRoles[updatedRoles.Length - 1] = GetNewRole(requestedAgentRoleCode)[0];
            return(updatedRoles);
        }
예제 #26
0
        public void Stop(int aimFloor, int currentAgentFloor, AgentRole role)
        {
            elevatorStatus = ElevatorStatus.Stopped;
            CurrentFloor   = currentAgentFloor;

            if (currentAgentFloor != aimFloor)
            {
                currentAgentFloor = aimFloor;
                Elevate(aimFloor, currentAgentFloor, role);
                return;
            }

            if (CanGetOffElevator(aimFloor, role))
            {
                CanOpen = true;
            }
            else
            {
                Console.WriteLine($"Agent with {role} role can't get off on this floor - {aimFloor + 1}");
                CanOpen = false;
            }
        }
예제 #27
0
        public async Task <ActionResult> RoleForCreate([Bind(Include = "RoleName, Description")] RoleViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (await RoleManager.RoleExistsAsync(model.RoleName))
                {
                    ModelState.AddModelError("", "权限名已被使用");
                }
                else
                {
                    var role = new AgentRole(model.RoleName, model.Description);
                    var res  = await RoleManager.CreateAsync(role);

                    if (res.Succeeded)
                    {
                        return(RedirectToAction("Role", "Agent"));
                    }
                    AddErrors(res);
                }
            }
            return(View());
        }
        /// <summary>
        /// Add the agent to the existing collection of agents using only the specified role and name.
        /// </summary>
        /// <param name="role"></param>
        /// <param name="name"></param>
        public void AddAgent(AgentRole role, string name)
        {
            // Create empty instances of the static and dynamic parts of the agent.
            AgentStateStatic  newAgentStateStatic  = new AgentStateStatic();
            AgentStateDynamic newAgentStateDynamic = new AgentStateDynamic();

            // Assign the role and name of the static part.
            newAgentStateStatic.AssignRole(role);
            newAgentStateStatic.SetName(name);

            // We give the dynamic part a link to the static part.
            newAgentStateDynamic.SetAgentInfo(newAgentStateStatic);

            // We combine both parts into one and add to the collection.
            agents.Add(newAgentStateStatic, newAgentStateDynamic);

            // Очистка
            newAgentStateStatic  = null;
            newAgentStateDynamic = null;
            GC.Collect();

            UpdateHashCode();
        }
        /// <summary>
        /// This method creates a separate agent using the information passed to it.
        /// Then it places the agent on the environment and passes information about it to it.
        /// </summary>
        public void CreateAgent(string name, bool status, AgentRole role, Goal goals, WorldContext beliefs, string spawnLocationName)
        {
            // We clone locations from the world.
            Dictionary <LocationStatic, LocationDynamic> locations = currentStoryState.CloneLocations();

            // We construct a new agent, from static and dynamic parts.
            AgentStateStatic  newAgentStateStatic  = new AgentStateStatic(name, role);
            AgentStateDynamic newAgentStateDynamic = new AgentStateDynamic(status, goals, beliefs, newAgentStateStatic);
            KeyValuePair <AgentStateStatic, AgentStateDynamic> newAgent =
                new KeyValuePair <AgentStateStatic, AgentStateDynamic>(newAgentStateStatic, newAgentStateDynamic);

            // Add the agent to the list of agents.
            currentStoryState.AddAgent(newAgent, currentStoryState.GetLocationByName(spawnLocationName));

            // We transfer information about the locations in the world to the agent.
            newAgent.Value.GetBeliefs().SetLocationsInWorld(locations);

            // We inform the agent in which location it was created.
            newAgent.Value.GetBeliefs().SetMyLocation(newAgent.Value.GetBeliefs().GetLocationByName(spawnLocationName));
            newAgent.Value.GetBeliefs().AddAgentInBeliefs(newAgent, newAgent.Key.GetRole());
            newAgent.Value.GetBeliefs().GetAgentByName(newAgent.Key.GetName()).
            SetLocation(newAgent.Value.GetBeliefs().GetLocationByName(spawnLocationName));
        }
 private static AgentRoleInfo ToAgentRoleInfo(AgentRole agentRole)
 => new ()
예제 #31
0
 public void JoinBlueTeam(AgentRole role)
 {
     agentRole = role;
     team      = Team.blue;
     agentRenderer.material = academy.blueMaterial;
 }
예제 #32
0
 public void AssignRole(AgentRole role)
 {
     this.role = role;
 }