public void AddChild(BoardTree node, int row, int column, int plays) { this.Children.Add(node); node.CheckWin(row, column); node.plays = plays + 1; node.parent = this; if (node.winner != 0) { node.numChild = 1; node.winValue = node.winner; node.SetWinStats(); } if (node.plays == 9) { node.endState = true; node.SetWinStats(); } }
private void SetWinStats() { if (this.parent != null) { BoardTree parent = this.parent; if (this.winner != 0) { parent.nextMoveWin = true; } /* * else * { * parent.nextMoveWin = false; * } */ parent.winValue = (((parent.winValue * parent.Children.Count)) + this.winValue) / (parent.Children.Count + 1); //parent.numChild += 1; parent.SetWinStats(); } }