private void Start() { label2.Text = "Раунд: " + (roundId + 1).ToString(); Draw.Init(); if (config == null) { return; } if (roundId == 0) { if (game.future_robots != null) { robots = RobotLoader.LoadRobots(config.robots); } else { game.future_robots = new List <RobotState>(); } } if (robots != null) { List <Tuple <string, IRobot> > robots_base = RobotLoader.LoadRobots(config.robots); int dN = 0; foreach (RobotState rs in game.future_robots) { for (int robot_id = 0; robot_id < robots.Count; robot_id++) { if ((rs.isAlive == true) && (robots[robot_id].Item2.Name == rs.name)) { robots_base.Add(robots[robot_id]); dN++; break; } } } robots.Clear(); robots.AddRange(robots_base); ThreadParam param = new ThreadParam(); param.robots = robots; param.round = roundId; param.dN = dN; Thread game_thread = new Thread(GameThread); game_thread.Start(param); evStop.WaitOne(); evStop.Reset(); gameStats(); roundId++; label2.Text = "Раунд: " + (roundId + 1).ToString(); if (roundId >= config.rounds.Count) { string logPath = "../../log_interface.txt"; try { string json = JsonConvert.SerializeObject(game.future_robots); File.WriteAllText("../../round6_data.json", json); } catch (Exception e) { File.AppendAllText(logPath, "Round 6 data dump failed: " + e.ToString() + Environment.NewLine, Encoding.UTF8); } Application.Exit(); } } }
public void start() { label2.Text = "Раунд: " + (roundId + 1).ToString(); Draw.Start();//Draw.bmp, Draw.xList,Draw.yList); //функция старта, внутри нее отрисовка,и создание параметров поля,узнаем количество роботов if (config == null) { return; } if (robots != null) { dN = 0; pbList = new List <ProgressBar>(); lbList = new List <Label>(); robots_base = RobotLoader.LoadRobots(directoryPath); foreach (RobotState rs in game.future_robots) { if (rs.isAlive == true) { robots_base.Add(robots[rs.id]); dN++; } } robots.Clear(); robots.AddRange(robots_base); //createField //int n = /*game.future_robots.Count;*/robots.Count; ////listBox1.Height = 14 * n; ////Draw.param(100,100); //for (int i = 0; i < n; i++) //{ // // listBox1.Items.Add(/*game.future_robots[i].id*/robots[i]); // Label lb = new Label(); // lb.Size = label1.Size; // lb.Font = label1.Font; // lb.Name = "lb" + i.ToString(); // lb.Location = new System.Drawing.Point(764, 68 + 18 * i); // lb.Text = i.ToString()+". "+robots[i].Name; // this.Controls.Add(lb); // lbList.Add(lb); //} // ProgressBar pb = new ProgressBar(); // pb.Name = "pbH" + i.ToString(); // pb.Location = new System.Drawing.Point(890, 68 + 18 * i); // pb.Size = progressBar1.Size; // this.Controls.Add(pb); // pbList.Add(pb); // pb = new ProgressBar(); // pb.Name = "pbR" + i.ToString(); // pb.Location = new System.Drawing.Point(980, 68 + 18 * i);//подобрать значения // pb.Size = progressBar1.Size; // this.Controls.Add(pb); // pbList.Add(pb); //} Param p = new Param(); p.rId = roundId; p.d = dN; p.g = robots; var th = new Thread(newGame); th.Start(p); evStop.WaitOne(); gameStats(); evStop.Reset(); //game //game.Loop(robots, roundId, dN); //Thread.Sleep(5000); //clearField //listBox1.Items.Clear(); //for(int i = 0; i<pbList.Count;i++) //{ // pbList[i].Dispose(); //} //pbList.Clear(); //statView //Thread.Sleep(3000); //game.future_robots.Sort(); //Form form3 = new Form3(); //form3.Show(); //for (int j = 0; j < game.future_robots.Count; j++) //{ // Form3.dataGridView3.Rows.Add(); // Form3.dataGridView3.Rows[j].Cells[0].Value = game.future_robots[j].id; // Form3.dataGridView3.Rows[j].Cells[1].Value = game.future_robots[j].name; // Form3.dataGridView3.Rows[j].Cells[2].Value = game.future_robots[j].defence + game.future_robots[j].attack + game.future_robots[j].speed; // Form3.dataGridView3.Rows[j].Cells[3].Value = game.future_robots[j].energy; // Form3.dataGridView3.Rows[j].Cells[4].Value = game.future_robots[j].isAlive; //} roundId++; if (roundId > 4) { Application.Exit(); } } }