//Initialize and add agents of corresponding types public AgentEnv createDummy1() { AgentInfo info = new AgentInfo(Color.Green, 0.01f, AgentType.Dummy, generateID(), AgentState.Searching, Average.commRadius, new Coordinates(0.5f, 0.5f), Average.speed / 5, Average.viewRadius); AgentEnv env = new AgentEnv(Average.speed, Average.viewRadius, info); Agent bill = new Dummy1(ref env); env.setAgent(bill); addAgent(ref env); return env; }
public AgentEnv createLittleGirl1() { AgentInfo info = new AgentInfo(Color.Pink, 0.005f, AgentType.Little_Girl, generateID(), AgentState.Find_Me, float.Epsilon, new Coordinates(0.5f, 0.5f), Average.speed / 5, Average.viewRadius); AgentEnv env = new AgentEnv( Average.speed, Average.viewRadius, info); Agent nancy = new LittleGirl1(ref env); env.setAgent(nancy); addAgent(ref env); return env; }
public AgentEnv createFinder1() { AgentInfo info = new AgentInfo(Color.Magenta, 0.01f, AgentType.Finder, generateID(), AgentState.Searching,Average.commRadius, new Coordinates(0.5f, 0.5f), Average.speed/5, Average.viewRadius); AgentEnv env = new AgentEnv(Average.speed/5, Average.viewRadius, info); //причесать это и перенести в info Agent holmes = new Finder1(ref env); env.setAgent(holmes); addAgent(ref env); return env; }
public Finder1(ref AgentEnv env) : base(ref env) { cells = new SearchCells(getMyViewRadius()); genAim(); }
List<AgentCutaway> IAgentFunctions.agentsInRange(ref AgentEnv client) { //Returns list of Agents Cutaways of observable agents Coordinates obs = client.getCoord(); List<AgentCutaway> rez = new List<AgentCutaway>(); foreach (AgentEnv ag in agentListm) { if (ag.getTypeName() == AgentType.Finder && client.getTypeName() == AgentType.Finder && canCommunicate(client, ag)) { rez.Add(ag.getCutaway()); } else if ((ag.getCoord() - obs).norm() < client.getViewRadius() && canSee(obs, ag.getCoord()) && ag.getID() != client.getID()) { rez.Add(ag.getCutaway()); } } return rez; }
bool IAgentFunctions.canTouch(Coordinates point, ref AgentEnv client) { //Check if the agent can grab object in specific point return canTouch1(point, ref client); }
private bool canCommunicate(AgentEnv sender, AgentEnv reciever) { //Checks if sender can send messages to reciever return (sender.getCoord() - reciever.getCoord()).norm() < sender.getCommRadius(); }
public Dummy1(ref AgentEnv env) : base(ref env) { genAim(); }
List<Wall> IAgentFunctions.wallsAround(ref AgentEnv agent) { // Returns List of observable walls return wallList.wallsAroundPoint(agent.getCoord(), agent.getViewRadius()); }
private void addAgent(ref AgentEnv ag) { Board me = this; agentListm.Add(ag); ag.setBoard(me); return; }
bool IAgentFunctions.takeObj(Int32 objId, ref AgentEnv agent) { //If agent can "take" object and he can touch that object, the object removes from the field AgentEnv billy = findAgent(objId); if (canTake(agent.getState(), billy.getState()) && canTouch1(billy.getCoord(), ref agent)) { billy.setState(AgentState.Found); billy.imageSetColor(Color.Black); return true; } else { return false; } }
bool IAgentFunctions.sendCellMatrix(int recieverID, ref AgentEnv sender) { // Send own search matrix to another agent AgentEnv reciever = findAgent(recieverID); if (canCommunicate(sender, reciever) && sender.getTypeName() == AgentType.Finder && reciever.getTypeName() == AgentType.Finder) { SearchCells temp; sender.getCellMatrix(out temp); reciever.uniteMatrix(temp); return true; } return false; }
void IAgentFunctions.changeAgentColor(Color col, ref AgentEnv agent) { //Change own color agent.imageSetColor(col); }
public DummyAgent(ref AgentEnv env) : base(ref env) { }
bool canTouch1(Coordinates point, ref AgentEnv client) { //Checks if one agent is in proper distance to pick up another agent Coordinates pos = client.getCoord(); return (isPathLegal(pos, point) && ((pos - point).norm() < touchDist)); }
public Agent(ref AgentEnv env_) { env = env_; }
private void removeAgent(ref AgentEnv ag) { agentListm.Remove(ag); }
public LittleGirl1(ref AgentEnv env) : base(ref env) { }
bool IAgentFunctions.askStep(Coordinates direction, float speedPercent, ref AgentEnv client) { //Try to make step in specific direction. The length = max(speedPercent,1) * maxSpeed Coordinates pos = client.getCoord(), des; float perc = Math.Min(Math.Max(0.0f, speedPercent), 1.0f); des = pos + (direction.normalize()) * (perc * client.getSpeed()); if (isPathLegal(pos, des)) { client.setCoord(des); return true; } else { return false; } }