public int ProcessNext(ref State Current, State aState, int total) { int x = total / 8; int y = total % 8; //int y = Int32.Parse(textBox2.Text); int AssumeChild = 0; int nextMove = 0; aState.GenerateToAllChild(); Current = EnemyMatch(Current, aState, x, y);//global "Current" is the enemy's state now, update enemy state's board; //AddTwoLevelChild(Current,0);//Initialzie the states which self may put, the available position is also calculated AssumeChild = NextStep(Current); if (AssumeChild != 0) { nextMove = Current.AvailablePosition[0][AssumeChild - 1] * 8 + Current.AvailablePosition[1][AssumeChild - 1]; } else { MessageBox.Show("I have no way to go"); nextMove = 64; } Current.DisposeAllButOne(AssumeChild); Current = Current.Child[AssumeChild];//update the current child; return(nextMove); }
public State EnemyMatch(State Current, State aState, int x, int y) { State Current0; bool WrongMove = false; if (aState.AvailablePosition[0].Count == 0) { MessageBox.Show("You do not have move!"); Current0 = aState.Child[0];//No chess to go; return(Current0); } for (int i = 0; i < aState.AvailablePosition[0].Count; i++) { if (aState.AvailablePosition[0][i] == x && aState.AvailablePosition[1][i] == y) { Current0 = aState.Child[i + 1];//The current is updated to the enemy's finished state aState.DisposeAllButOne(i + 1); return(Current0); } } if (WrongMove == false)//The enemy make wrong move; { MessageBox.Show("Wrong Move! Go next Available!"); if (aState.AvailablePosition[0].Count == 0) { Current0 = aState.Child[0];//No chess to go; return(Current0); } else { aState.DisposeAllButOne(1); Current0 = aState.Child[1];//The current is updated to the enemy's finished state return(Current0); } } Current0 = aState; return(Current0); }
public int ProcessNext(ref State Current, State aState, int total) { int x = total / 8; int y = total % 8; //int y = Int32.Parse(textBox2.Text); int AssumeChild = 0; int nextMove = 0; aState.GenerateToAllChild(); Current=EnemyMatch(Current,aState,x,y);//global "Current" is the enemy's state now, update enemy state's board; //AddTwoLevelChild(Current,0);//Initialzie the states which self may put, the available position is also calculated AssumeChild = NextStep(Current); if (AssumeChild != 0) { nextMove = Current.AvailablePosition[0][AssumeChild - 1] * 8 + Current.AvailablePosition[1][AssumeChild - 1]; } else { MessageBox.Show("I have no way to go"); nextMove = 64; } Current.DisposeAllButOne(AssumeChild); Current = Current.Child[AssumeChild];//update the current child; return nextMove; }
public State EnemyMatch(State Current, State aState, int x, int y) { State Current0; bool WrongMove = false; if (aState.AvailablePosition[0].Count == 0) { MessageBox.Show("You do not have move!"); Current0 = aState.Child[0];//No chess to go; return Current0; } for (int i = 0; i < aState.AvailablePosition[0].Count; i++) { if (aState.AvailablePosition[0][i] == x && aState.AvailablePosition[1][i] == y) { Current0 = aState.Child[i + 1];//The current is updated to the enemy's finished state aState.DisposeAllButOne(i + 1); return Current0; } } if (WrongMove == false)//The enemy make wrong move; { MessageBox.Show("Wrong Move! Go next Available!"); if (aState.AvailablePosition[0].Count == 0) { Current0 = aState.Child[0];//No chess to go; return Current0; } else { aState.DisposeAllButOne(1); Current0 = aState.Child[1];//The current is updated to the enemy's finished state return Current0; } } Current0 = aState; return Current0; }