public UCJudgeInspect(User user, JudgeResult judgeResult) : base(user) { InitializeComponent(); base.btnOrder.Text = "合格"; this.judgeResult = judgeResult; }
public void FreeLeftTopPlace() { objectManager.UpdateFromScene(); JudgeResult judgeResult = new JudgeResult { Actor = Side.Yellow, ResultType = ResultType.FreeKickLeftTop }; matchInfo.Referee.JudgeAutoPlacement(matchInfo, judgeResult); objectManager.RevertScene(matchInfo); }
/// <summary> /// 根据JudgeResult生成用于提交的Body /// </summary> private string CreateResultBody(JudgeResult result) { int resultCode; switch (result.ResultCode) { case JudgeResultCode.Accepted: resultCode = 4; break; case JudgeResultCode.CompileError: resultCode = 11; break; case JudgeResultCode.JudgeFailed: resultCode = 11; break; case JudgeResultCode.MemoryLimitExceed: resultCode = 8; break; case JudgeResultCode.OutputLimitExceed: resultCode = 9; break; case JudgeResultCode.PresentationError: resultCode = 5; break; case JudgeResultCode.RuntimeError: resultCode = 10; break; case JudgeResultCode.TimeLimitExceed: resultCode = 7; break; case JudgeResultCode.WrongAnswer: resultCode = 6; break; default: resultCode = 0; break; } string body = $"update_solution=1&sid={result.SubmitId}&result={resultCode}&time={result.TimeCost}" + $"&memory={result.MemoryCost}&sim=0&simid=0&pass_rate={result.PassRate}"; return(body); }
public void FreeRiBotPlace() { objectManager.UpdateFromScene(); JudgeResult judgeResult = new JudgeResult { Actor = Side.Blue, ResultType = ResultType.FreeKickRightBot }; matchInfo.Referee.JudgeAutoPlacement(matchInfo, judgeResult); objectManager.RevertScene(matchInfo); }
public void PenaltyYellowPlace() { objectManager.UpdateFromScene(); JudgeResult judgeResult = new JudgeResult { Actor = Side.Yellow, ResultType = ResultType.PenaltyKick }; matchInfo.Referee.JudgeAutoPlacement(matchInfo, judgeResult); objectManager.RevertScene(matchInfo); }
public void GoalieBluePlace() { objectManager.UpdateFromScene(); JudgeResult judgeResult = new JudgeResult { Actor = Side.Blue, ResultType = ResultType.GoalKick }; matchInfo.Referee.JudgeAutoPlacement(matchInfo, judgeResult); objectManager.RevertScene(matchInfo); }
/// <summary> /// 创建JudgeTask实例 /// </summary> /// <param name="submitId">提交ID</param> /// <param name="problemId">问题ID</param> /// <param name="dataVersion">测试数据版本</param> /// <param name="language">语言</param> /// <param name="sourceCode">源代码</param> /// <param name="author">作者</param> /// <param name="timeLimit">时间限制</param> /// <param name="memoryLimit">内存限制</param> /// <param name="judgeAllCases">是否评测全部样例(即使遇到错误答案)</param> /// <param name="judgeType">评测类型</param> /// <returns>JudgeTask实例</returns> public static JudgeContext Create(int submitId, int problemId, string dataVersion, string language, string sourceCode, string author = "", int timeLimit = 1000, int memoryLimit = 262144, bool judgeAllCases = false, JudgeType judgeType = JudgeType.ProgramJudge) { ILangConfig langConfig = ConfigManager.GetLanguageConfig(language); if (langConfig == null) { throw new JudgeException("Unsupported language: " + language); } // 分配评测临时目录 string tempDirectory = RandomString.Next(16); if (langConfig is ProgramLangConfig) { ProgramLangConfig langCfg = langConfig as ProgramLangConfig; tempDirectory = GetTempDirectory(langCfg.JudgeDirectory); UpdatePathInfo(langCfg, tempDirectory); } double timeCompensation = GetTimeCompensation(langConfig); JudgeTask task = new JudgeTask { SubmitId = submitId, ProblemId = problemId, DataVersion = dataVersion, Language = language, SourceCode = sourceCode, Author = author, TimeLimit = (int)(timeLimit / timeCompensation), MemoryLimit = memoryLimit, JudgeAllCases = judgeAllCases, JudgeType = judgeType }; JudgeResult result = new JudgeResult { SubmitId = task.SubmitId, ProblemId = task.ProblemId, Author = task.Author, JudgeDetail = "", MemoryCost = Config.MinimumMemoryCost, TimeCost = 0, PassRate = 0, ResultCode = JudgeResultCode.Accepted }; return(new JudgeContext(task, result, tempDirectory, langConfig)); }
public JudgeResult JudgeNext() { if (_fileIndex >= _inputFiles.Length) { return(new JudgeResult { Result = ResultCode.JudgeFailed }); } string inputPath = _inputFiles[_fileIndex++]; string outputPath = ""; string testCaseName = Path.GetFileNameWithoutExtension(inputPath); string outputPathProfix = Path.Combine(OutPutPath, testCaseName); foreach (string file in _outputFiles) { if (file.StartsWith(outputPathProfix)) { outputPath = file; break; } } string input = ""; string output = ""; try { input = File.ReadAllText(inputPath); if (!string.IsNullOrEmpty(outputPath)) { output = File.ReadAllText(outputPath); } } catch { return(new JudgeResult { TestCaseName = testCaseName, Result = ResultCode.JudgeFailed }); } JudgeResult jr = _judger.Judge(input, output, testCaseName); if (jr.Result == ResultCode.OutPut) { File.WriteAllText(outputPathProfix + ".out", jr.OutPut); } return(jr); }
//判题核心 private void backgroundWorker_Main_DoWork(object sender, DoWorkEventArgs e) { MultipleJudgeController controller = new MultipleJudgeController( textBox_ProgramPath.Text, textBox_InputPath.Text, textBox_OutputPath.Text, int.Parse(textBox_TimeLimit.Text)); while (controller.HasNextCase()) { JudgeResult judgeResult = controller.JudgeNext(); _resultForm.AddJudgeResult(judgeResult); } }
protected ProgramTestDataFile[] GetTestDataFiles() { JudgeResult result = JudgeResult; ProgramTestDataFile[] dataFiles = TestDataManager.GetTestDataFiles(JudgeTask.ProblemId); if (dataFiles.Length > 0) { return(dataFiles); } result.ResultCode = JudgeResultCode.JudgeFailed; result.JudgeDetail = "No test data."; throw new ExpectedJudgeStopException("No test data"); }
protected void CheckUnsafeCode() { JudgeResult result = JudgeResult; if (!CodeChecker.Instance.Check(JudgeTask.SourceCode, JudgeTask.Language, out string unsafeCode, out int line)) { result.ResultCode = JudgeResultCode.CompileError; result.JudgeDetail = "Include unsafe code, please remove them!"; result.JudgeDetail += "\r\n"; result.JudgeDetail += $"line {line}: {unsafeCode}"; throw new ExpectedJudgeStopException("Unsafe code"); } }
protected void JudgeAllCases(BaseSingleCaseJudger judger, ProgramTestDataFile[] dataFiles) { JudgeResult result = JudgeResult; int acceptedCasesCount = 0; foreach (var dataFile in dataFiles) { try { ProgramTestData testData = TestDataManager.GetTestData(JudgeTask.ProblemId, dataFile); SingleJudgeResult singleResult = judger.Judge(testData.Input, testData.Output); if (result.ResultCode == JudgeResultCode.Accepted) { // 计算有时间补偿的总时间 result.TimeCost = Math.Max(result.TimeCost, (int)(singleResult.TimeCost * LangConfig.TimeCompensation)); result.MemoryCost = Math.Max(result.MemoryCost, singleResult.MemoryCost); } if (singleResult.ResultCode == JudgeResultCode.Accepted) { acceptedCasesCount++; } else { // 出错时只记录第一组出错的信息 if (result.ResultCode == JudgeResultCode.Accepted) { result.ResultCode = singleResult.ResultCode; result.JudgeDetail = singleResult.JudgeDetail; } if (!JudgeTask.JudgeAllCases) { break; } } } catch (Exception e) { result.ResultCode = JudgeResultCode.JudgeFailed; result.JudgeDetail = e.ToString(); throw new ExpectedJudgeStopException("Judge failed"); } } result.JudgeDetail = result.JudgeDetail.Replace(Context.TempDirectory, ""); result.PassRate = (double)acceptedCasesCount / dataFiles.Length; }
/// Extract <see cref="FoulInfo"/> from inner <see cref="JudgeResult"/> type private static FoulInfo ExtractFoulInfo(JudgeResult judgeResult, MatchInfo matchInfo) { // Don't use FoulInfo.Types.PhaseType.Stopped. FoulInfo info = new FoulInfo { Actor = Side.Self, Phase = matchInfo.MatchPhase switch { MatchPhase.FirstHalf => FoulInfo.Types.PhaseType.FirstHalf, MatchPhase.SecondHalf => FoulInfo.Types.PhaseType.SecondHalf, MatchPhase.OverTime => FoulInfo.Types.PhaseType.Overtime, MatchPhase.Penalty => FoulInfo.Types.PhaseType.PenaltyShootout, _ => throw new ArgumentOutOfRangeException() },
/// <summary> /// 根据JudgeResult生成用于提交的Body /// </summary> private string CreateResultBody(JudgeResult result) { int resultCode = 0; switch (result.ResultCode) { case JudgeResultCode.Accepted: resultCode = 4; break; case JudgeResultCode.CompileError: resultCode = 11; break; case JudgeResultCode.JudgeFailed: resultCode = 11; break; case JudgeResultCode.MemoryLimitExceed: resultCode = 8; break; case JudgeResultCode.OutputLimitExceed: resultCode = 9; break; case JudgeResultCode.PresentationError: resultCode = 5; break; case JudgeResultCode.RuntimeError: resultCode = 10; break; case JudgeResultCode.TimeLimitExceed: resultCode = 7; break; case JudgeResultCode.WrongAnswer: resultCode = 6; break; } string body = string.Format( "update_solution=1&sid={0}&result={1}&time={2}&memory={3}&sim=0&simid=0&pass_rate={4}", result.SubmitId, resultCode, result.TimeCost, result.MemoryCost, result.PassRate); return(body); }
IEnumerator LoadResults() { yield return(new WaitForSeconds(TimeWaitingAnim)); Player.gameObject.SetActive(false); enemy.gameObject.SetActive(false); ResultsPoster.gameObject.SetActive(true); ResultsPoster.SetBool("Inside", true); yield return(new WaitForSeconds(1.1f)); if (CurrentRound >= NumersOfRounds) { string Sentence = ""; JudgeResult J1 = FinalResultsTable.Judge1; JudgeResult J2 = FinalResultsTable.Judge2; JudgeResult J3 = FinalResultsTable.Judge3; int PlayerScore = J1.Player + J2.Player + J3.Player; int EnemyScore = J1.Enemy + J2.Enemy + J3.Enemy; if (PlayerScore > EnemyScore) { Sentence = "VICTORY"; FinalResult.color = WinColor; Results.Win = true; } else { Sentence = "DEFEAT"; FinalResult.color = DefeatColor; Results.Win = false; } //Aqui debo determinar si gana o pierde el jugador //inserte codigo aqui //F comitada int i = 0; foreach (char letter in Sentence.ToCharArray()) { FinalResult.text += letter; yield return(new WaitForSeconds(Speed)); } } ContinueButton.gameObject.SetActive(true); }
/// <summary> /// 创建评测失败的JudgeResult /// </summary> /// <param name="context">JudgeContext</param> /// <param name="message">错误信息</param> /// <returns>结果为失败的JudgeResult</returns> private JudgeResult CreateFailedJudgeResult(JudgeContext context, string message = "") { JudgeResult result = new JudgeResult { Author = context.Task.Author, JudgeDetail = message, MemoryCost = 0, TimeCost = 0, PassRate = 0, ProblemId = context.Task.ProblemId, SubmitId = context.Task.SubmitId, ResultCode = JudgeResultCode.JudgeFailed }; return(result); }
/// <summary> /// 创建失败的JudgeResult /// </summary> /// <param name="task">JudgeTask</param> /// <param name="message">错误信息</param> /// <returns>结果为失败的JudgeResult</returns> private JudgeResult CreateFailedJudgeResult(JudgeTask task, string message = "") { JudgeResult result = new JudgeResult { Author = task.Author, JudgeDetail = message, MemoryCost = 0, TimeCost = 0, PassRate = 0, ProblemID = task.ProblemID, SubmitID = task.SubmitID, ResultCode = JudgeResultCode.JudgeFailed }; return(result); }
private void ViewDiff(JudgeResult judgeResult) { if (judgeResult.Diff > 0) { //はやい diffText.text = "early " + judgeResult.Diff.ToString("0"); } else if (judgeResult.Diff == 0) { diffText.text = judgeResult.Diff.ToString("0"); } else { diffText.text = "late " + judgeResult.Diff.ToString("0"); } }
public bool Submit(JudgeResult result) { try { using (HttpWebClient client = ConfiguredClient.Create()) { client.CookieContainer = Authenticator.Singleton.CookieContainer; client.UploadString(_config.ResultSubmitUrl, GetDataForSubmit(result), 3); return(true); } } catch { } return(false); }
private async Task <JudgeResult> ExtractAsync() { try { var filename = Encoding.UTF8.GetString(Convert.FromBase64String(_submission.Program.Code)); var archive = Path.Combine(DataPath, "submissions", _submission.Id.ToString(), filename); await Task.Run(() => ZipFile.ExtractToDirectory(archive, Path.Combine(Root, "extract"))); } catch (FileNotFoundException) { return(JudgeResult.NewFailedResult("E: Could not find submission archive on server. Is it deleted?")); } catch (InvalidDataException) { return(JudgeResult.NewRejectedResult("E: The zip archive is corrupted and cannot be extracted.")); } catch (Exception e) { return(JudgeResult.NewFailedResult($"E: Failed to extract zip archive: {e.Message}")); } var info = new DirectoryInfo(Path.Combine(Root, "extract")); var target = string.Empty; if (info.GetDirectories().Any(d => d.Name.Equals(".git"))) { target = Path.Combine(Root, "extract", ".git"); } else if (info.GetDirectories().Length == 1) { var folder = info.GetDirectories()[0].Name; target = Path.Combine(Root, "extract", folder, ".git"); if (!Directory.Exists(target)) { return(JudgeResult.NewRejectedResult("E: Could not find git repository." + $" There is no .git in folder {folder}.")); } } else { return(JudgeResult.NewRejectedResult("E: Could not find git repository." + " There is none or more than one folders in zip archive.")); } Directory.Move(target, Path.Combine(Jail, ".git")); return(null); }
public async Task <ActionResult <SubmissionModel> > Get() { _logger.LogInformation("Fetching submission info for judge node {0}", HttpContext.Connection.RemoteIpAddress); var address = HttpContext.Connection.RemoteIpAddress; if (await _manager.IsBlockedAsync(address)) { _logger.LogDebug("{} is blocked for fetching submissions. Respond with 204.", address); return(NoContent()); } while (true) { var submission = await _repo.Submissions.FindOneUnjudgedSubmissionAsync(); if (submission == null) { return(NoContent()); } var archiveId = await _repo.Problems.GetProblemTestDataArchiveIdAsync(submission.ProblemId); if (archiveId == null) { // No available test data archive. The verdict of the submission should be directly set to // Verdict.NoTestData. _logger.LogWarning("No available test data archive found for submission: {0}, problem: {}", submission.Id, submission.ProblemId); var judgeResult = new JudgeResult { Verdict = Verdict.NoTestData }; await _repo.Submissions.SetJudgeResultAsync(submission.Id, judgeResult); continue; } var model = _mapper.Map <Submission, SubmissionModel>(submission); model.ArchiveId = archiveId.Value; return(model); } }
private string CreateRequestBody(JudgeResult result) { InnerJudgeResult innerResult = new InnerJudgeResult { SubmitId = result.SubmitId, JudgeDetail = result.JudgeDetail, MemoryCost = result.MemoryCost, PassRate = result.PassRate, ResultCode = result.ResultCode, TimeCost = result.TimeCost }; JObject requestJObject = TokenUtil.CreateJObject(); requestJObject.Add("result", Json.Serialize(innerResult)); return(requestJObject.ToString()); }
public void SetTable() { float PlyrHealthPerc = (Player.CurrentHealth / Player.MaxHealth); float EnmyHealthPerc = (enemy.CurrentHealth / enemy.MaxHealth); int plyrKOs = Player.CurrentKnockouts; int EnmyKOs = enemy.CurrentKnockouts; int DiffKO = plyrKOs - EnmyKOs; int PlyrPointsBase = 0; int EnmyPointBase = 0; JudgeResult jdge1 = new JudgeResult(PlyrPointsBase, EnmyPointBase); JudgeResult jdge2 = new JudgeResult(PlyrPointsBase, EnmyPointBase); JudgeResult jdge3 = new JudgeResult(PlyrPointsBase, EnmyPointBase); //llenar la tabla... ResultsTable.Add(new ResultsbyRound(jdge1, jdge2, jdge3)); JudgeResult finalResult1 = new JudgeResult(0, 0); JudgeResult finalResult2 = new JudgeResult(0, 0); JudgeResult finalResult3 = new JudgeResult(0, 0); foreach (ResultsbyRound item in ResultsTable) { JudgeResult J1 = item.Judge1; JudgeResult J2 = item.Judge2; JudgeResult J3 = item.Judge3; finalResult1 = new JudgeResult(finalResult1.Player + J1.Player, finalResult1.Enemy + J1.Enemy); finalResult2 = new JudgeResult(finalResult2.Player + J2.Player, finalResult2.Enemy + J2.Enemy); finalResult3 = new JudgeResult(finalResult3.Player + J3.Player, finalResult3.Enemy + J3.Enemy); } float count = (float)ResultsTable.Count; finalResult1 = new JudgeResult(Rounding(finalResult1.Player / count), Rounding(finalResult1.Enemy / count)); finalResult2 = new JudgeResult(Rounding(finalResult2.Player / count), Rounding(finalResult2.Enemy / count)); finalResult3 = new JudgeResult(Rounding(finalResult3.Player / count), Rounding(finalResult3.Enemy / count)); FinalResultsTable = new ResultsbyRound(finalResult1, finalResult2, finalResult3); CleanTableUI(); FillTableUI(); }
/// <summary> /// 创建提交测试结果的请求 /// </summary> /// <returns>提交测试结果的请求</returns> private string CreateRequestBody(JudgeResult result) { InnerJudgeResult judgeResult = new InnerJudgeResult { SubmitId = result.SubmitId, JudgeDetail = result.JudgeDetail, MemoryCost = result.MemoryCost, PassRate = result.PassRate, ResultCode = result.ResultCode, TimeCost = result.TimeCost }; JObject requestBody = JObject.FromObject(new { result = judgeResult }); Token.AddTokenToJObject(requestBody); return(requestBody.ToString()); }
/// <summary> /// 判定結果テキストを表示する /// </summary> /// <param name="text"></param> public void PopupPointText(JudgeResult judgeResult) { if (enableDiffView) { ViewDiff(judgeResult); } if (judgeResult.Type == JudgeResultType.Ignore) { return; } audioSource.PlayOneShot(soundManager.TapAudio); GameObject prefab = null; if (judgeResult.Type == JudgeResultType.Success) { prefab = Instantiate(perfectTextPrefab); } else if (judgeResult.Type == JudgeResultType.Good) { prefab = Instantiate(goodTextPrefab); } else if (judgeResult.Type == JudgeResultType.Miss) { prefab = Instantiate(missTextPrefab); } else { return; } prefab.transform.SetParent(transform); prefab.transform.position = transform.position; //TODO: 固定? prefab.transform.localScale = new Vector3(120, 120, 0); prefab.GetComponent <Animator>().Play(0); }
public void AddJudgeResult(JudgeResult judgeResult) { if (this.InvokeRequired) { this.Invoke(new AddJudgeResultHandel(AddJudgeResult), judgeResult); return; } var item = listView_Main.Items.Add(judgeResult.TestCaseName); item.SubItems.Add(judgeResult.TestCaseSize.ToString() + "B"); item.SubItems.Add(judgeResult.Result.ToString()); item.SubItems.Add(judgeResult.TimeCost.ToString() + "ms"); item.SubItems.Add(judgeResult.MemoryCost.ToString() + "KB"); Color color; switch (judgeResult.Result) { case ResultCode.Accepted: color = Color.LightGreen; break; case ResultCode.OutPut: color = Color.LightGreen; break; case ResultCode.RuntimeError: color = Color.Orange; break; default: color = Color.PaleVioletRed; break; } item.BackColor = color; _judgeResultsList.Add(judgeResult); }
protected void CompileSourceCode() { JudgeResult result = JudgeResult; if (!LangConfig.NeedCompile) { return; } Compiler compiler = new Compiler(Context); string compileResult = compiler.Compile(); if (string.IsNullOrEmpty(compileResult)) { return; } // compileResult不为空则编译有错误 result.JudgeDetail = compileResult.Replace(Context.TempDirectory, ""); result.ResultCode = JudgeResultCode.CompileError; result.MemoryCost = 0; throw new ExpectedJudgeStopException("Compile error"); }
public override void Judge() { JudgeResult result = JudgeResult; string[] dataNames = TestDataManager.GetDbTestDataNames(JudgeTask.ProblemId, _dbType); if (dataNames.Length == 0) { result.ResultCode = JudgeResultCode.JudgeFailed; result.JudgeDetail = "No test data."; return; } int acceptedCount = 0; foreach (string dataName in dataNames) { SingleJudgeResult singleResult = JudgeOneCase(dataName); result.TimeCost = Math.Max(result.TimeCost, singleResult.TimeCost); if (singleResult.ResultCode == JudgeResultCode.Accepted) { acceptedCount++; } else { result.ResultCode = singleResult.ResultCode; result.JudgeDetail = singleResult.JudgeDetail; if (!JudgeTask.JudgeAllCases) { break; } } } result.PassRate = (double)acceptedCount / dataNames.Length; }
/// <summary> /// 根据JudgeResult生成用于提交的数据 /// </summary> /// <param name="result">JudgeResult</param> private string GetDataForSubmit(JudgeResult result) { int resultCode = 0; switch (result.ResultCode) { case JudgeResultCode.Accepted: resultCode = 10; break; case JudgeResultCode.CompileError: resultCode = 3; break; case JudgeResultCode.JudgeFailed: resultCode = 255; break; case JudgeResultCode.MemoryLimitExceed: resultCode = 6; break; case JudgeResultCode.OutputLimitExceed: resultCode = 7; break; case JudgeResultCode.PresentationError: resultCode = 9; break; case JudgeResultCode.RuntimeError: resultCode = 4; break; case JudgeResultCode.TimeLimitExceed: resultCode = 5; break; case JudgeResultCode.WrongAnswer: resultCode = 8; break; } int sid = result.SubmitID; string detail = result.JudgeDetail; int timeCost = result.TimeCost; int memCost = result.MemoryCost; int pid = result.ProblemID; string username = result.Author; string data = string.Format("sid={0}&resultcode={1}&detail={2}&timecost={3}&memorycost={4}&pid={5}&username={6}", sid, resultCode, detail, timeCost, memCost, pid, username); return(data.ToString()); }
/// <summary> /// 結果を聞く /// </summary> void INumeronAI.SetResult(List<int> number, JudgeResult result) { // 結果履歴を更新 ResultHistory resultHistory = new ResultHistory(); resultHistory.Number = number; resultHistory.Result = result; resultList.Add(resultHistory); // 点数評価 foreach (int num in number) { point[num] += result.Eat + result.Bite; } // 桁毎の評価 pointDigit1[number[0]] += result.Eat + result.Bite; pointDigit2[number[1]] += result.Eat + result.Bite; pointDigit3[number[2]] += result.Eat + result.Bite; // 回答した番号をNGに登録 if (result.Eat != 3) { List<int> ng = new List<int>(number); ngNumeronNumber.Add(ng); } // 全ての数字は間違い(EAT + BITE = 0) -> NG番号を登録 if (((result.Eat + result.Bite) == 0)) { foreach (int num in number) { ngNumber.Add(num); } } // 3個確定(EAT + BITE = 3) if ((result.Eat + result.Bite) == GameMaster.NumeronDigit) { for (int i = 0; i < 10; i++) { if ((number[0] != i) && (number[1] != i) && (number[2] != i)) { ngNumber.Add(i); } } } // 3個確定してないため、並び変えてもだめ(EAT + BITE != 3) else { // NG List<int> ng = null; ng = new List<int>() { number[0], number[1], number[2] }; ngNumeronNumber.Add(ng); ng = new List<int>() { number[0], number[2], number[1] }; ngNumeronNumber.Add(ng); ng = new List<int>() { number[1], number[0], number[2] }; ngNumeronNumber.Add(ng); ng = new List<int>() { number[1], number[2], number[0] }; ngNumeronNumber.Add(ng); ng = new List<int>() { number[2], number[0], number[1] }; ngNumeronNumber.Add(ng); ng = new List<int>() { number[2], number[1], number[0] }; ngNumeronNumber.Add(ng); } // 0EATの場合 // 各桁ごとのNG番号登録 if (result.Eat == 0) { ngDigit1.Add(number[0]); ngDigit2.Add(number[1]); ngDigit3.Add(number[2]); } }
/// <summary> /// 维护比赛状态,根据裁判的判定结果执行不同的动作。<br/> /// 完整的一拍有三个步骤: /// 时间递增、更新输入(轮速或摆位)---> 物理引擎运行 ---> 触发事件。<br/> /// 这个函数会在每次“物理引擎运行”结束被调用,因此,一是需要处理上一拍的运行结果,二是作下一拍(本拍)的准备。<br/> /// </summary> public void InMatchLoop() { if (ManualPlacing) { throw new InvalidOperationException("manual placing"); } if (!LoadSucceed || !Started || Paused) { return; } // 触发事件,作为上一拍的结束 // 如果现在是阶段的第一拍,上一拍无意义,不用触发事件 if (GlobalMatchInfo.TickPhase != 0) { Event.Send(Event.EventType1.MatchInfoUpdate, GlobalMatchInfo); } else { // 在第一拍做初始化 placementCount = 0; callbackCount = 0; lastPlacementId = 0; placementToIgnore = new Queue <int>(); } /* 之前处理上一拍 */ /* 之后为本拍做准备 */ // 从裁判中获取下一拍的动作。 JudgeResult judgeResult = GlobalMatchInfo.Referee.Judge(GlobalMatchInfo); // 时间加一 GlobalMatchInfo.TickMatch++; GlobalMatchInfo.TickPhase++; switch (judgeResult.ResultType) { // 执行动作,更新输入 case ResultType.GameOver: // 整场比赛结束 // 可能最后一拍正好进球,需要判断 switch (judgeResult.WhoGoal) { case Side.Blue: GlobalMatchInfo.Score.BlueScore++; break; case Side.Yellow: GlobalMatchInfo.Score.YellowScore++; break; } StopMatch(); break; case ResultType.NextPhase: // 阶段结束 // 这之后的物理引擎运行的一拍无意义,不用触发MatchInfoUpdate事件 if (GlobalMatchInfo.MatchPhase == MatchPhase.FirstHalf) { SwitchRole(); } GlobalMatchInfo.MatchPhase = GlobalMatchInfo.MatchPhase.NextPhase(); GlobalMatchInfo.TickPhase = 0; // 时间指定为0,使得下一拍的裁判得知新阶段的开始 OnNextPhase(); // 通知策略 switch (GlobalMatchInfo.MatchPhase) { case MatchPhase.FirstHalf: break; case MatchPhase.SecondHalf: StrategyManager.Blue.OnSecondHalfStart(); StrategyManager.Yellow.OnSecondHalfStart(); break; case MatchPhase.OverTime: StrategyManager.Blue.OnOvertimeStart(); StrategyManager.Yellow.OnOvertimeStart(); break; case MatchPhase.Penalty: StrategyManager.Blue.OnPenaltyShootoutHalfStart(); StrategyManager.Yellow.OnPenaltyShootoutHalfStart(); break; default: throw new ArgumentOutOfRangeException(); } break; case ResultType.NormalMatch: // 正常比赛,输入轮速 UpdateWheelsToScene(); break; default: // 判断是否进球 switch (judgeResult.WhoGoal) { case Side.Blue: GlobalMatchInfo.Score.BlueScore++; break; case Side.Yellow: GlobalMatchInfo.Score.YellowScore++; break; } // 手动摆位 if (manualPlaceEnabled) { BroadcastJudgeResult(judgeResult); BeginManualPlace(); } else { void Callback() { #region Patch to placement int callbackId = callbackCount; callbackCount++; if (callbackId == lastPlacementId) { lastPlacementId = 0; } else { Debug.Assert(placementToIgnore.Peek() == callbackId); placementToIgnore.Dequeue(); return; } #endregion BroadcastJudgeResult(judgeResult); //Debug.Log($"callback placement {callbackId}"); UpdatePlacementToScene(judgeResult); ObjectManager.SetStill(); Event.Send(Event.EventType1.AutoPlacement, GlobalMatchInfo); } #region Patch to placement int placementId = placementCount; placementCount++; if (lastPlacementId == 0) { lastPlacementId = placementId; } else { placementToIgnore.Enqueue(placementId); } #endregion if (GlobalMatchInfo.TickMatch > 1) { //Debug.Log($"Will stop at {GlobalMatchInfo.TickMatch} {placementId}"); PauseForSeconds(2, Callback); } else { Callback(); } } break; } }
/// <summary> /// 結果を聞く /// </summary> void INumeronAI.SetResult(List<int> number, JudgeResult result) { if ((result.Eat == 0) && (result.Bite == 0)) { ngNumber.Add(number[0]); ngNumber.Add(number[1]); ngNumber.Add(number[2]); } }
/// <summary> /// 結果を聞く /// </summary> void INumeronAI.SetResult(List<int> number, JudgeResult result) { // 回答した番号をNGに登録 if (result.Eat != 3) { List<int> ng = new List<int>(number); ngNumeronNumber.Add(ng); } // 全ての数字は間違い(EAT + BITE = 0) -> NG番号を登録 if (((result.Eat + result.Bite) == 0)) { foreach (int num in number) { ngNumber.Add(num); } } // 3個確定(EAT + BITE = 3) if ((result.Eat + result.Bite) == GameMaster.NumeronDigit) { for (int i = 0; i < 10; i++) { if ((number[0] != i) && (number[1] != i) && (number[2] != i)) { ngNumber.Add(i); } } } // 3個確定してないため、並び変えてもだめ(EAT + BITE != 3) else { // NG List<int> ng = null; ng = new List<int>() { number[0], number[1], number[2] }; ngNumeronNumber.Add(ng); ng = new List<int>() { number[0], number[2], number[1] }; ngNumeronNumber.Add(ng); ng = new List<int>() { number[1], number[0], number[2] }; ngNumeronNumber.Add(ng); ng = new List<int>() { number[1], number[2], number[0] }; ngNumeronNumber.Add(ng); ng = new List<int>() { number[2], number[0], number[1] }; ngNumeronNumber.Add(ng); ng = new List<int>() { number[2], number[1], number[0] }; ngNumeronNumber.Add(ng); } // 0EATの場合 // 各桁ごとのNG番号登録 if (result.Eat == 0) { ngDigit1.Add(number[0]); ngDigit2.Add(number[1]); ngDigit3.Add(number[2]); } }
private void LogJudgeResult(JudgeResult result) { LogManager.Info( $"Task {result.SubmitId} result: Time:{result.TimeCost} Mem:{result.MemoryCost} " + $"Code:{result.ResultCode} PassRate:{result.PassRate} Details:{result.JudgeDetail} "); }
public void SetResult(List<int> answer, JudgeResult result) { }
/// <summary> /// 結果を聞く /// </summary> void INumeronAI.SetResult(List<int> number, JudgeResult result) { // NG数字登録 if ((result.Eat == 0) && (result.Bite == 0)) { foreach (int num in number) { ngNumber.Add(num); } } // 3個確定 if ((result.Eat + result.Bite) == GameMaster.NumeronDigit) { for (int i = 0; i < 10; i++) { if ((number[0] != i) && (number[1] != i) && (number[2] != i)) { ngNumber.Add(i); } } } // 0EATの場合 if (result.Eat == 0) { ngDigit1.Add(number[0]); ngDigit2.Add(number[1]); ngDigit3.Add(number[2]); } }