Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8678861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:49:43+00:00 2026-06-12T20:49:43+00:00

I am working on the alpha-beta pruning algorithm with Tic-Tac-Toe game (3×3). Currently for

  • 0

I am working on the alpha-beta pruning algorithm with Tic-Tac-Toe game (3×3). Currently for any given instance of the 3×3 grid, I was able to figure out the best case:

public Best chooseAlphaBetaMove(int whosMov, int alpha, int beta) {

    Best reply = new Best();  
    Best myBest = new Best();

    if ((scoreGrid()==COMPUTER_WIN) || (scoreGrid()==OPPONENT_WIN) || 
                                       (scoreGrid()==GAME_DRAW)) {
        int score = scoreGrid();
        return new Best(score,-3,-3,count);
    }

    if (whosMov==COMPUTER_MOVE) {
        myBest.score = alpha;
    } else {
        myBest.score = beta;
    }

    for (int i=0; i<3; i++) {
    for (int j=0; j<3; j++) {
        if (layOut[i][j]==0) {
            moveGrid(whosMov,i,j);
            reply = chooseAlphaBetaMove(-whosMov,alpha,beta); 
            unmoveGrid(i,j);

            if ((whosMov==COMPUTER_MOVE)&&(reply.score>myBest.score)) {
                myBest.score = reply.score;
                alpha = reply.score;
                myBest.row = i;
                myBest.column = j;
            }

            if  ((whosMov==OPPONENT_MOVE)&&(reply.score<myBest.score)) {
                myBest.score = reply.score;
                beta = reply.score;
                myBest.row = i;
                myBest.column = j;
            }
            if (beta <= alpha) return myBest;
        }
    }
    }

        return myBest;
}

Where the Best structure is:

public class Best {

    public int score;
    public int row;
    public int column;
    public int count
}

Given an initial grid and who will move next, I can know the best score and the best position for this next player to go. However, I can’t figure out how to print the whole path for this best move. (Note – I don’t want the whole search path. I only want to print out the single search path starting from this best move till the leaf). Any thoughts? thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T20:49:44+00:00Added an answer on June 12, 2026 at 8:49 pm

    As you go recursively down each path, you need to keep track of it, probably by passing a reference to a List/Stack into each chooseAlphaBetaMove call. When you find a better path than the current best path, you take a copy of the current path, and store it as the “best path so far”. Once you have finished, you can then print out the best path.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a Othello engine using minimax with alpha-beta pruning. It's working ok, but
I'm working on a simple application that draws an alpha-blended picture on the screen's
Working on a small game using an HTML5 canvas, and javascript. And it's working
Currently I am working on Weblogo . I need to generate weblogo image using
If I'm to integrate a function y = -((F+h) M^3 (cosh(h*M)+M*beta*sinh(h*M)))/(h*M*cosh(h*M)+(-1+h*M^2*beta)*sinh(h*M))- (alpha*(M^2*(F+h)*(-1+2*h^2*M^2+ cosh(2*h*M)-2*h*M*sinh(2*h*M)))/(8*(h*M*cosh(h*M)+(-1+h*M^2*beta)*sinh(h*M))^2)); with
I'm working on a simple game. The idea of the first round is that,
I just switched from jquery mobile alpha 2 to jquery mobile beta 1.0. I
I'm currently working on an application to validate and parse CSV-files. The CSV files
I am working for international clients who have all very different alphabets and so
Working with an undisclosed API, I found a function that can set the number

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.