public bool DebugStep(ParallelType pType = ParallelType.Sequential) { switch (pType) { case ParallelType.ParallelFree: case ParallelType.ParallelLockstep: { Parallel.ForEach(Dwarves.Where(dorf => !dorf.Dead), d => { d.Turn(this); }); break; } case ParallelType.Sequential: default: { foreach (var d in Dwarves.Where(dorf => !dorf.Dead)) { d.Turn(this); } break; } } return Dwarves.Any(x => !x.Dead); }
public bool DebugStep(ParallelType pType = ParallelType.Sequential) { switch (pType) { case ParallelType.ParallelFree: case ParallelType.ParallelLockstep: { Parallel.ForEach(Dwarves.Where(dorf => !dorf.Dead), d => { d.Turn(this); }); break; } case ParallelType.Sequential: default: { foreach (var d in Dwarves.Where(dorf => !dorf.Dead)) { d.Turn(this); } break; } } return(Dwarves.Any(x => !x.Dead)); }
public World Execute(string consoleInput, ParallelType pType = ParallelType.Sequential) { World world = new World(dwarves, routines); world.Run(consoleInput, pType); return world; }
public World Execute(string consoleInput, ParallelType pType = ParallelType.Sequential) { World world = new World(dwarves, routines); world.Run(consoleInput, pType); return(world); }
public void Run(string consoleInput, ParallelType pType = ParallelType.Sequential) { sb = new StringBuilder(); input = consoleInput.ToArray(); int turn = 0; switch (pType) { case ParallelType.ParallelFree: { Parallel.ForEach(Dwarves, d => { int t = 0; while (!d.Dead) { DoTurn(d, t); } t++; }); break; } case ParallelType.ParallelLockstep: { while (Dwarves.Any(x => !x.Dead)) { Parallel.ForEach(Dwarves.Where(dorf => !dorf.Dead), d => { DoTurn(d, turn); }); turn++; } break; } case ParallelType.Sequential: default: { while (Dwarves.Any(x => !x.Dead)) { foreach (var d in Dwarves.Where(dorf => !dorf.Dead)) { d.Turn(this); if (turn > 1000000) { d.Dead = true; Trace.WriteLine(d.Name + " went berserk: infinite loop?"); } } turn++; } break; } } Trace.WriteLine("All dwarves are dead and/or stopped working after " + turn + " turns"); }
private SMSProvider GetSMSProvider(ParallelType type) { SMSProvider provider; if (type.Equals(ParallelType.Thread)) { provider = new SMSProviderThread(); } else { provider = new SMSProviderTask(); } return(provider); }
private Battery GetBattery(ParallelType type, IUserInOut userInOut) { Battery battery; int capacity = 5000; int chargingTime = 60; if (type.Equals(ParallelType.Thread)) { battery = new BatteryThread(capacity, chargingTime, userInOut); } else { battery = new BatteryTask(capacity, chargingTime, userInOut); } return(battery); }
public SimCorpMobile(IUserInOut userInOut) : base(userInOut) { int micSensitivityRate = 70; string micBandwidth = "40 - 20k Hz"; vMicrophone = new Microphone(micSensitivityRate, micBandwidth, userInOut); int outputPower = 50; string speakerBandwidth = "20 - 18k Hz"; vSpeaker = new Speaker(outputPower, speakerBandwidth, userInOut); CellularType cellModuleType = CellularType.Lte; int workingDistance = 1000; vCellModule = new CellularModule(cellModuleType, workingDistance, userInOut); int screenHeight = 1920; int screenWidth = 1080; ScreenType screenType = ScreenType.Lcd; int brightness = 73; int contrast = 57; IScreenProfile screenProfile = new BasicScreenProfile(brightness, contrast); vScreen = new TuningScreen(screenHeight, screenWidth, screenType, screenProfile, userInOut); int controlHeght = 140; int controlWidth = 68; int touchSensitivityRate = 90; vMultiTouchPanel = new MultiTouchPanel(controlHeght, controlWidth, touchSensitivityRate, userInOut); vMessageStorage = new MessageStorage { Contacts = new List <Contact> { new Contact("John", 380101), new Contact("Nick", 380102), new Contact("Emma", 380103) } }; ParallelType type = ParallelType.Task; vSMSProvider = GetSMSProvider(type); vBattery = GetBattery(type, userInOut); }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Object"/> class. /// </summary> public ParallelisationOptions(ParallelType type = ParallelType.None, int threshold = 0, int maxDegreeOfParallisation = 0) { _type = type; _threshold = threshold; }
public World Debug(ParallelType pType = ParallelType.Sequential) { World world = new World(dwarves, routines); return world; }
public World Debug(ParallelType pType = ParallelType.Sequential) { World world = new World(dwarves, routines); return(world); }
public BTParallel(ParallelType _type, BTPrecondition _precondition) : base(_precondition) { resList = new List <BTResult>(); paraType = _type; }
public BTParallel(ParallelType _type) : this(_type, null) { }