ChatGPT

Discussion about development of draughts in the time of computer and Internet.
Post Reply
BertTuyt
Posts: 1573
Joined: Wed Sep 01, 2004 19:42

ChatGPT

Post by BertTuyt » Fri Dec 16, 2022 01:04

I asked ChatGPT:

can you write c code for the alpha beta algorithm

And here the code + answer:

Code: Select all

#include <limits.h>

int alpha_beta(int depth, int alpha, int beta, int maximizingPlayer)
{
    if (depth == 0 || game_over())
    {
        return evaluate_position();
    }

    if (maximizingPlayer)
    {
        int bestValue = INT_MIN;
        for (int i = 0; i < number_of_children(); ++i)
        {
            int value = alpha_beta(depth - 1, alpha, beta, false);
            bestValue = max(bestValue, value);
            alpha = max(alpha, value);
            if (beta <= alpha)
            {
                break;
            }
        }
        return bestValue;
    }
    else
    {
        int bestValue = INT_MAX;
        for (int i = 0; i < number_of_children(); ++i)
        {
            int value = alpha_beta(depth - 1, alpha, beta, true);
            bestValue = min(bestValue, value);
            beta = min(beta, value);
            if (beta <= alpha)
            {
                break;
            }
        }
        return bestValue;
    }
}
This implementation of alpha-beta uses a recursive function to explore the game tree, starting at the given depth and working its way down to the leaf nodes. At each node, it evaluates the current position using the evaluate_position() function and returns the result if the maximum depth has been reached or the game is over. If the node is a maximizing player, it selects the maximum value of its children, while if it is a minimizing player, it selects the minimum value of its children. The alpha and beta values are used to prune the search tree, allowing the algorithm to terminate early when it is no longer possible to find a better value.

Joost Buijs
Posts: 460
Joined: Wed May 04, 2016 11:45
Real name: Joost Buijs

Re: ChatGPT

Post by Joost Buijs » Fri Dec 16, 2022 11:38

Maybe you can ask ChatGPT to give the optimal weights for a draughts neural network, but that would probably be too much. For translations and help by writing articles it could come in very handy.

Wieger Wesselink
Posts: 1149
Joined: Sat Jun 28, 2003 13:22
Location: Eindhoven, The Netherlands
Contact:

Re: ChatGPT

Post by Wieger Wesselink » Fri Dec 16, 2022 13:28

ChatGPT is impressive and can be useful for simple programming tasks like writing scripts. Its output is well-structured and includes helpful comments. However, it is not yet able to help me solve more complex problems. ChatGPT is also very effective at revising English text. Its suggestions significantly improve the quality of the text, including this one :-)

Post Reply