0 votes

So, let's just say I have a chess game. I want to create an analyzer that analyzes a series of possible moves, from different starting positions.

I've thought of two possible ways to do this:
1. Use an instance
2. Use multi-threading (which I'm not quite familiar with yet)

For the instanced method (which I'm not sure will work), I will create a separate scene, and in that separate scene create a script and a function called:

func _analyze_game(starting_pos):

Which, preferably, would calculate a series of possible moves starting from a specified chess board position.

Back to the main scene, I would instance a series of these analyzers, and give them each a starting position, and as they work out the probabilities I would sit back and enjoy my drink.

I'm not sure if this is an acceptable way to do this. I could also use multi-threading (which I don't quite understand), but this brings me to the question: If I use the instances like this, isn't this basically the concept of multi-threading (I think)?

Any better solutions to this analyzer problem would be welcomed.

Thanks for your time.

Godot version 3.3.2
in Engine by (204 points)

1 Answer

0 votes
Best answer

A thread can only process one thing at a time. Unless you instance() a Thread object and start() it, by default your game is single threaded.

An instance is more or less just a pointer to a spot in memory that contains all the stuff your scene has (variables) and can do (functions).

In your case you want to create a multi-threaded game. The concept of multi-threading is a bit too complex to explain in this small text box (but don't dissuade that from you learning it).

Here are the docs regarding multi-threading in godot:



Multi-threading is a universal programming concept so it may be helpful for you to go outside of the godot sphere to learn how to create a multi-threaded application then try to incorporate what you learned into gdscript.

by (3,882 points)
selected by

Thanks for the answer!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.