Minimax algorithm in Develop

How do I implement the minimax algorithm in Gdevelop for games like Connect 4/four in row, Tic-Tac-Toe, Backgammon. Have searched but can’t find anything to start from. Or is there some other non-random way for the computer to play connect 4?

You can read about it here: Minimax Algorithm in Game Theory | Set 1 (Introduction) - GeeksforGeeks

1 Like

I always wondered how you create that form of logic. It’s very interesting. I bookmarked it. Maybe I’ll try something at some point.

I don’t know if you’ll find an example written for Gdevelop but there are examples in other languages. You could rewrite them to either GDevelop events or Javascript mixed with gdevelop Javascript methods. Or use a combination of Javascript as functions and gdevelop event .

It would require a good knowledge of each language. Although, it might require more knowledge of GDevelop bc without knowing how to write say python you could probably understand the purpose of the code. Most of it is probably variables and decision making. That could be done easier with Javascript although the UI might be easier in Gdevelop. Gdevelop doesn’t have some basic events like if then else but you can use a mix of conditions maybe with an added boolean. For things like for…next loops you can use a repeat or while event with a variable. It would depend on your knowledge of the languages.

There are people here who can help along the way.

This ia quite a good explanation, with some code in different languages

Oops sorry, only just noticed you had already linked to that article