public override void SimulationStartNotification(IPopulation pop) { _startTime = Scheduler.GetTime(); double myValue = Coordinates.getCoordinate(Coordinates.Space.getAxisIndex(Type_PROPERTYNAME)); IBlauSpaceAxis axis = Coordinates.Space.getAxis(Coordinates.Space.getAxisIndex(Type_PROPERTYNAME)); bool seller = pop.partition(Coordinates.Space, axis, myValue, ID); if (seller) { _Type = -1; // play short } else { _Type = +1; // play long } }
public bool partition(IBlauSpace s, IBlauSpaceAxis axis, double myValue, int myId) { // filter pop based on myValue on axis IList <IAgent> filteredSet = new List <IAgent> (); foreach (IAgent ag in this) { if (ag is IAgent_NonParticipant) { continue; } int axisIndex = s.getAxisIndex(axis.Name); double agentCoord = ag.Coordinates.getCoordinate(axisIndex); // POTENTIAL PROBLEM WITH FLOATING POINT if (agentCoord == myValue) { filteredSet.Add(ag); } } // get size of filtered set int fcount = filteredSet.Count; int c = 0; foreach (IAgent fa in filteredSet) { if (fa.ID == myId) { return(true); } c++; if (c > myValue * fcount) { return(false); } } throw new Exception("Wierd inconsistency in population partition"); // return false; }