private void button1_Click(object sender, EventArgs e) { int?[] stNums = new int?[16]; foreach (Control ctrl in this.tableLayoutPanel1.Controls) { if (ctrl.Text != "") { string name = ctrl.Name.Substring(8, ctrl.Name.Length - 8); int x = Int32.Parse(name); stNums[x - 1] = Int32.Parse(ctrl.Text); } } State state1 = new State(stNums); if (state1.checkWin()) { MessageBox.Show("You won!!!"); } else { Minimax mm = new Minimax(); State state2 = mm.minimaxDec(state1, Player.Even); displayState(state2); editLabels(state2); dsCombobox(state2); enableCB(); if (state2.checkWin()) { MessageBox.Show("You lost..."); } } }
private void button1_Click(object sender, EventArgs e) { int?[] stNums = new int?[16]; foreach (Control ctrl in this.tableLayoutPanel1.Controls) { if (ctrl.Text != "") { string name = ctrl.Name.Substring(13, ctrl.Name.Length - 13); int x = Int32.Parse(name); stNums[x - 1] = Int32.Parse(ctrl.Text); } } //numericUpDown1.Text = null; // int?[] stNums = { numericUpDown1.Value, 2, 3, 4, 5, 6, 7, 8, 9, null, null, null, null, 14, null, 15 }; //int?[] stNum = { 1, 2, 3, 4, 5, 6, 7, 8, 9, null, null, null, null, 14, null, 15 }; State state1 = new State(stNums); Minimax mm = new Minimax(); State state2 = mm.minimaxDec(state1, Player.Even); displayState(state2); editLabels(state2); //int[] dec = mm.minmaxDec(state1, Player.Even); //String nm = "numericUpDown" + (dec[0] + 1).ToString(); ////MessageBox.Show(nm); //string numb = dec[1].ToString(); //var numud = this.Controls.Find(nm, true).FirstOrDefault() as NumericUpDown; //numud.Value = (decimal)dec[1]; //List<State> stateList = state1.getNewStates(Player.Odd); //Console.WriteLine("***************"); //List<State> stateList2 = stateList[0].getNewStates(Player.Even); //Console.WriteLine("***************"); //List<State> stateList3 = stateList2[0].getNewStates(Player.Odd); //foreach (State st in stateList) //{ // MessageBox.Show(st.displayState1()); //} }