public static void SetCurrentMove(BasePrediction prediction, bool isDefaultTarget = false) { TargetLogLogic.Add(prediction.Point); State.ThisRound.CurrentMoveSelectedPrediction = prediction; State.ThisRound.CurrentMoveIsToDefaultTarget = isDefaultTarget; if (!prediction.Commands.Any()) { return; } var command = prediction.Commands[0]; State.ThisRound.CurrentMoveCommands.AddRange(command); }
private string SetBoard(Board board) { var resultString = string.Empty; // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (this.label1.InvokeRequired) { var d = new SetBoardCallback(SetBoard); try { var invokeResult = this.Invoke(d, new object[] { board }); if (invokeResult is string invokeResultStr) { resultString = invokeResultStr; } } catch (Exception) { } } else { if (checkBoxRunProcessing.Checked) { _stopWatch.Restart(); if (State.IsNewBoardString(board)) { if (State.PrevRound != null && !State.PrevRound.GameIsRunning) { Field.Reset(true); TargetLogLogic.Clear(); } } State.SetThisRound(board); State.ThisRound.GameIsRunning = State.GameIsRunning; if (State.GameIsRunning) { //todo: perform calculations Task.Run(CalculationLogic.PerformCalculations).Wait(); for (var i = 0; i < Constants.FieldWidth; i++) { Parallel.For(0, Constants.FieldHeight, (j) => { if (ChangeFieldItem != null) { ChangeFieldItem(null, new ChangeFieldItemEvent { X = i, Y = j }); } }); } if (IsKeyControl) { State.ThisRound.CurrentMoveCommands.Clear(); State.ThisRound.CurrentMoveCommands.AddRange(KeyControlCommand); ResetKeyControls(); } resultString = State.ThisRound.CurrentMoveCommandString; } else { Field.Reset(true); TargetLogLogic.Clear(); } _stopWatch.Stop(); label1.Text = $"{_stopWatch.ElapsedMilliseconds}ms"; label2.Text = State.ThisRound.MyTank == null ? string.Empty : GetMyStateString(); } } return(resultString); }
private static List <BasePrediction> FilterOutRepeatedTargets(List <BasePrediction> allMyKillPredictions) { return(allMyKillPredictions.Where(x => !TargetLogLogic.IsSameTargetMultipleRounds(x)).ToList()); }