예제 #1
0
        /// <summary>
        /// Allocate the resources to try to satisfy demand as well as possible
        /// </summary>
        /// <param name="currentTime"></param>
        private void AllocateDemand(Time currentTime, Dictionary <string, IResource> resources, Map map)
        {
            foreach (var r in resources)
            {
                Allocation allocation;
                Resource   resource = (Resource)r.Value;
                switch (resource.Distribution)
                {
                case "first":
                case "nearest":
                    allocation = Allocation.AllocateAsHarpagon(currentTime, resource, map.Cells,
                                                               Math.Max(map.SizeX, map.SizeY), resource.Distribution);
                    break;

                default:
                    allocation = Allocation.AllocateAsSolomon(currentTime, resource, map.Cells);
                    break;
                }

                Allocations[resource.Id] = allocation;
            }
        }
예제 #2
0
 public void AddAllocation(string resourceId, Allocation allocation)
 {
     Allocations[resourceId] = allocation;
 }