Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: AutoPlay needs to be made concurrent #11269

Closed
tuvus opened this issue Mar 6, 2024 · 6 comments
Closed

Feature request: AutoPlay needs to be made concurrent #11269

tuvus opened this issue Mar 6, 2024 · 6 comments
Labels

Comments

@tuvus
Copy link
Collaborator

tuvus commented Mar 6, 2024

Problem Description

Using AutoPlay in the later game causes the game to freeze since the AI play is being done on the same thread.

Related Issue Links

#10315

Desired Solution

The solution to the problem is to move the AutoPlay to another thread. However I believe this will cause a problem if we allow the player to continue making clicks and movements to the game. Therefore, I am led to believe a more elaborate movement-locking feature would need to be implemented.

@tuvus tuvus added the feature label Mar 6, 2024
@SomeTroglodyte
Copy link
Collaborator

Opening a can of worms..

v1: Show blocking popup with our rotationg arrow animation and a cancel button while it does its job
v2: Break it into small, fast (<250ms) steps, drive from WorldScreen.update - if there's autoplay work to do, launch coroutine that does a step and finishes with worldScreen.shouldUpdate = true, possibly some launchOnGLThread stuff to show where something happened

@yairm210
Copy link
Owner

yairm210 commented Mar 7, 2024

Let's talk about next turn, since it had the same problem

How does next turn work?

  • clone game state
  • change worldscreen to be "read only" state - players can explore the current world but cannot take action
  • process next turn for clone in another thread
  • when other thread finishes, replace the world screen

Sounds like you want something similar - only in your case you can replace the world screen on every turn, but keep it "read only"

@yairm210
Copy link
Owner

yairm210 commented Mar 7, 2024

That is to say - add a onTurnComplete callback parameter to next turn
NextTurn should not be aware of UI directly, it just clones the game state on every turn end and calls the function - which can be on another thread
The latency cost of cloning the game state every turn is the major cost here

@tuvus
Copy link
Collaborator Author

tuvus commented Mar 8, 2024

The way we made it "read only" in the past was by changing the viewing civ... Could we set the viewing civ to none and set the selected civ to the original civ like in Spectator?
The spectator needs to view each civ as if they were them without being able to modify them. We might be able to reuse this to apply the locking mechanism.

@yairm210
Copy link
Owner

yairm210 commented Mar 8, 2024

No, we just set isPlayersTurn to false

@tuvus
Copy link
Collaborator Author

tuvus commented Mar 17, 2024

Why did I not realize this? AutoPlay already does that in order to lock the screen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants