private void btnCalc_Click(object sender, RoutedEventArgs e) { int x = Convert.ToInt32(txt1.Text); int y = Convert.ToInt32(txt2.Text); StringBuilder sb = new StringBuilder(); if ((bool)chkRow.IsChecked) { int[] r = EvaluationFunctions.CommonProperties(EvaluationFunctions.EvaluationDirection.Row, board, x, y); sb.AppendLine("Row: " + string.Join("", r)); } if ((bool)chkColumn.IsChecked) { int[] r = EvaluationFunctions.CommonProperties(EvaluationFunctions.EvaluationDirection.Column, board, x, y); sb.AppendLine("Column: " + string.Join("", r)); } if ((bool)chkDiagonal.IsChecked) { int[] r = EvaluationFunctions.CommonProperties(EvaluationFunctions.EvaluationDirection.Diagonal, board, x, y); sb.AppendLine("Diagonal: " + string.Join("", r)); } MessageBox.Show(sb.ToString()); }
//Evaluation Function for placing a piece public double StaticPlayEvaluate(Board b, Piece p, int[] coordinates, AvailablePieces a) { double v1 = Coefficients[0] * EvaluationFunctions.BinarySum(EvaluationFunctions.CommonProperties(EvaluationFunctions.EvaluationDirection.Row, b, coordinates[0], coordinates[1])); double v2 = Coefficients[1] * EvaluationFunctions.BinarySum(EvaluationFunctions.CommonProperties(EvaluationFunctions.EvaluationDirection.Column, b, coordinates[0], coordinates[1])); double v3 = Coefficients[2] * EvaluationFunctions.BinarySum(EvaluationFunctions.CommonProperties(EvaluationFunctions.EvaluationDirection.Diagonal, b, coordinates[0], coordinates[1])); double v4 = Coefficients[3] * EvaluationFunctions.SpotsRemaining(EvaluationFunctions.EvaluationDirection.Row, b, coordinates[0], coordinates[1]); double v5 = Coefficients[4] * EvaluationFunctions.SpotsRemaining(EvaluationFunctions.EvaluationDirection.Column, b, coordinates[0], coordinates[1]); double v6 = Coefficients[5] * EvaluationFunctions.SpotsRemaining(EvaluationFunctions.EvaluationDirection.Diagonal, b, coordinates[0], coordinates[1]); double v7 = Coefficients[6] * a.GetRemainingCount(); double v8 = Coefficients[7] * EvaluationFunctions.CommonPiecesRemaining(EvaluationFunctions.EvaluationDirection.Row, b, a.RemainingPieces, coordinates[0], coordinates[1]); double v9 = Coefficients[8] * EvaluationFunctions.CommonPiecesRemaining(EvaluationFunctions.EvaluationDirection.Column, b, a.RemainingPieces, coordinates[0], coordinates[1]); double v10 = Coefficients[9] * EvaluationFunctions.CommonPiecesRemaining(EvaluationFunctions.EvaluationDirection.Diagonal, b, a.RemainingPieces, coordinates[0], coordinates[1]); int v11 = EvaluationFunctions.Winnable(EvaluationFunctions.EvaluationDirection.Diagonal, b, coordinates[0], coordinates[1]); int v12 = EvaluationFunctions.WinningMoveAvailable(p, b, coordinates); //return v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8 + v9 + v10; return((v1 * v4 * v8) + (v2 * v5 * v9) + (v3 * v6 * v10 * v11) + v12); //return (v1 * v8 - v4) + (v2 * v9 - v5) + (v3 * v10 * v11 - v6); }