コード例 #1
0
ファイル: Menu_form.cs プロジェクト: 0rbit3r/BrABENECi
        private void New_evol_button_Click(object sender, EventArgs e)//Vytvoří novou Simulaci s náhodně inicializovanými agenty
        {
            bool safe_to_continue = false;

            if (Num_of_agents_txtbox.Text != "" && Party_size_txbox.Text != "")
            {
                try
                {
                    if (Convert.ToInt32(Num_of_agents_txtbox.Text) < 1 || Convert.ToInt32(Num_of_agents_txtbox.Text) > 30 ||
                        Convert.ToInt32(Party_size_txbox.Text) < 1 || Convert.ToInt32(Party_size_txbox.Text) > 10)
                    {
                        throw new Exception("WrongInput");
                    }
                    safe_to_continue = true;
                }
                catch
                {
                    MessageBox.Show("Invalid input! Number of agents must be between  1 and 30 and Parties must be between 1 and 10. ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    safe_to_continue = false;
                }
            }
            if (safe_to_continue)
            {
                Logic.sim_in_progress = false;
                sim_form.Hide();
                Visual_bridge.Reset();
                Sim_control_group.Enabled  = true;
                Evol_control_group.Enabled = true;
                Logic.parties_num          = Convert.ToInt32(Num_of_agents_txtbox.Text);
                Logic.PARTY_SIZE           = Convert.ToInt32(Party_size_txbox.Text);
                Logic.agents_in_race       = Convert.ToInt32(Num_of_agents_txtbox.Text) * Logic.PARTY_SIZE;
                Logic.num_of_agents        = Convert.ToInt32(Num_of_agents_txtbox.Text) * Logic.PARTY_SIZE * 3;
                Logic.Evolution_init(Sim_timer, sim_form, this);
            }
        }
コード例 #2
0
ファイル: Logic.cs プロジェクト: 0rbit3r/BrABENECi
 public static void Cancel_battle()
 {
     timer.Enabled   = false;
     sim_in_progress = false;
     Visual_bridge.Reset();
     Generation_init();
 }//Zruší bitvu
コード例 #3
0
ファイル: Menu_form.cs プロジェクト: 0rbit3r/BrABENECi
 private void show_gen_button_Click(object sender, EventArgs e)//Zobrazí genomy jednotlivých agentů
 {
     sim_form.Show();
     sim_form.Refresh();
     Visual_bridge.Reset();
     Visual_bridge.Render_genome();
 }
コード例 #4
0
ファイル: Logic.cs プロジェクト: 0rbit3r/BrABENECi
        public static void Simulate_battle()//Má na starosti bitvy a jejich správný průběh
        {
            timer.Enabled = false;
            if (current_party >= parties_num) //Keeps control over which battle goes on
            {
                Finish_simulation();
            }
            else
            {
                menu_form.progress_label.Text = "Simulating...";
                Divide_agents();
                Visual_bridge.Reset();
                Position_init(Current_agents, PARTY_SIZE * 3);
                sim_in_progress = true;
                elapsed_ticks   = 0;

                timer.Enabled = true;
            }
        }