public int[] timeOfWorkWithThreats(int graphSize, int interval, int nrOfSamples) { Graph graph = sim.simulateGraph(graphSize, 1); Threats threats = new Threats(graph); Threats threatsClear = new Threats(graph); int[] resultsThreats = new int[nrOfSamples + 1]; int[] results = new int[nrOfSamples + 1]; // Pierwsze użycie trwa dłużej TimeValue(graph, threatsClear); for (int i = 0; i < nrOfSamples + 1; i++) { results[i] = TimeValue(graph, threatsClear); resultsThreats[i] = TimeValue(graph, threats); threats = sim.addThreats(graph, threats, interval); } Console.WriteLine("Wyniki bez zagrożenia : "); foreach (int res in results) { Console.Write(" " + res); } Console.WriteLine("\nWyniki z zagrożeniami : "); foreach (int res in resultsThreats) { Console.Write(" " + res); } return(resultsThreats); }
protected InternalThreat GetFirstThreatOfType(PlayerAction playerAction) { return(Threats .Where(threat => threat.ActionType == playerAction) .OrderBy(threat => threat.TimeAppears) .FirstOrDefault()); }
static void startAsync(int graphSize) { Simulator sim = new Simulator(); Graph graf = sim.simulateGraph(graphSize, 1); Threats threat = sim.simulateThreats(graf); ClientClass clnt = new ClientClass(); clnt.sendGraph(graf); var path = clnt.receivePath(); Console.WriteLine("PATH :"); foreach (int i in path) { Console.Write("{0}\t", i.ToString()); } Console.WriteLine("Trying to send"); while (true) { // await Task.Delay(1000); clnt.sendGraph(graf, threat); Console.WriteLine("dbg : sent"); Console.ReadKey(); path = clnt.receivePath(); Console.WriteLine("PATH :"); foreach (int i in path) { Console.Write("{0}\t", i.ToString()); } Console.WriteLine(); threat = sim.changeThreats(graf, threat); Console.WriteLine("Waiting ... "); Console.ReadKey(); //await Task.Delay(5000); } }
public void SettleThreats() { var victims = new Dictionary <IPlayer, IDeath>(); foreach (var threat in Threats) { if (threat.Victim.Perks.CurrentDefense >= threat.Strength) { continue; } var victim = threat.Victim; if (victims.TryGetValue(victim, out _)) { victims[victim].Description += Environment.NewLine + threat.Description; } else { threat.Victim.Alive = false; // TODO: Change active depending on the action victims[victim] = threat; } } Threats.Clear(); UndisclosedDeaths.AddRange(victims.Values); }
public void HandleThreats() { List <Task> tasks = new List <Task>(); List <Creature> threatsToRemove = new List <Creature>(); foreach (Creature threat in Threats) { if (threat != null && !threat.IsDead) { if (!Designations.IsDesignation(threat.Physics, DesignationType.Attack)) { var g = new KillEntityTask(threat.Physics, KillEntityTask.KillType.Auto); Designations.AddEntityDesignation(threat.Physics, DesignationType.Attack, null, g); tasks.Add(g); } else { threatsToRemove.Add(threat); } } else { threatsToRemove.Add(threat); } } foreach (Creature threat in threatsToRemove) { Threats.Remove(threat); } TaskManager.AssignTasksGreedy(tasks, Minions); }
// Z zagrożeniami private int TimeValue(Graph graph, Threats threats) { stopwatch.Restart(); clnt.sendGraph(graph, threats); var path = clnt.receivePath(); stopwatch.Stop(); return((int)stopwatch.ElapsedMilliseconds); }
private static void Scanner_ThreatDetected(ScanController sender, ThreatDetectedArgs args) { // Notify user //Console.WriteLine("\nTHREAT DETECT: {0}\n{1}", args.Detection.Definition, args.FilePath); // Add threat detection to list lock (locker) { Threats.Add(args); } }
public Threats simulateThreats(Graph graph) { Threats threats = new Threats(graph); int temp = rnd.Next(graph.nrOfNodes - 1); while (temp == graph.start || temp == graph.end) { temp = rnd.Next(graph.nrOfNodes - 1); } threats.positionsOfThreats[rnd.Next(graph.nrOfNodes - 1)] = true; return(threats); }
public void OnDeserialized(StreamingContext ctx) { World = ((WorldManager)ctx.Context); HandleThreatsTimer = new Timer(1.0f, false, Timer.TimerMode.Real); if (Threats == null) { Threats = new List <Creature>(); } if (Minions == null) { Minions = new List <CreatureAI>(); } Threats.RemoveAll(threat => threat == null || threat.IsDead); Minions.RemoveAll(minion => minion == null || minion.IsDead); }
public bool Equals(PedType other) { if (other == null) { return(false); } return(Flag.Equals(other.Flag) && Unknown0.Equals(other.Unknown0) && Unknown1.Equals(other.Unknown1) && Unknown2.Equals(other.Unknown2) && Unknown3.Equals(other.Unknown3) && Unknown4.Equals(other.Unknown4) && Threats.Equals(other.Threats) && Avoid.Equals(other.Avoid)); }
public Threats addThreats(Graph graph, Threats threats, int nrOfThreats) { int tempRand = 0; for (int i = 0; i < nrOfThreats; i++) { while (threats.positionsOfThreats[tempRand = rnd.Next(graph.nrOfNodes)]) { ; } threats.positionsOfThreats[tempRand] = true; } return(threats); }
public void sendGraph(Graph graf, Threats threats) { // Creating stream and encoder Stream stm = tcpclnt.GetStream(); ASCIIEncoding asen = new ASCIIEncoding(); // Packing, serializing and encoding data to send DataToSend toSend = new DataToSend(graf, threats); string jsonString = JsonConvert.SerializeObject(toSend); byte[] ba = asen.GetBytes(jsonString); Console.WriteLine("Sending data about graph and threats to server ..."); // Writing data to stream stm.Write(ba, 0, ba.Length); }
public Threats changeThreats(Graph graph, Threats threats) { for (int i = 0; i < graph.nrOfNodes; i++) { if (threats.positionsOfThreats[i]) { for (int j = 0; j < graph.nrOfNodes; j++) { if (rnd.Next(Constants.MAXWEIGHT * 3) > (graph.graph[i, j] + 2 * Constants.MAXWEIGHT) && graph.start != j && graph.end != j) { threats.positionsOfThreats[j] = true; return(threats); } } } } return(threats); }
public void AddThreat(Actor aggressor, int value) { foreach (var threat in Threats) { if (threat.Target == aggressor) { IncreaseThreat(threat, value); return; } } var hates = Threats.ToList(); var newThreat = new Threat(aggressor, value); hates.Add(newThreat); Threats = hates.ToArray(); IncreaseThreat(newThreat, value); }
public void HandleThreats() { List <Task> tasks = new List <Task>(); List <Creature> threatsToRemove = new List <Creature>(); foreach (Creature threat in Threats) { if (threat != null && !threat.IsDead) { Task g = new KillEntityTask(threat.Physics, KillEntityTask.KillType.Auto); if (!IsTaskAssigned(g)) { if (!AttackDesignations.Contains(threat.Physics)) { AttackDesignations.Add(threat.Physics); } tasks.Add(g); } else { threatsToRemove.Add(threat); } } else { threatsToRemove.Add(threat); } } foreach (Creature threat in threatsToRemove) { Threats.Remove(threat); } TaskManager.AssignTasks(tasks, Minions); }
public List <IDeath> ThreatsOn(IPlayer victim) { return(Threats.Where(death => death.Victim != null && death.Victim == victim).ToList()); }
public List <IDeath> ThreatsBy(IPlayer killer) { return(Threats.Where(death => death.Killer != null && death.Killer == killer).ToList()); }
public DataToSend(Graph _graph, Threats _threats) { graph = _graph; threats = _threats; }
public DataToSend(Graph _graph) { graph = _graph; threats = new Threats(graph); }