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
Lua attribute player.ai_type #6001
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: Benedikt Straub <48293446+Noordfrees@users.noreply.github.com>
Now the tests pass. |
I could not yet practically test if the attribute is set in the game. The setting widelands/src/network/gameclient.cc Line 643 in 6ba442a
The type of ai is visible in the new game dialogue for the netclient. I guess it is still available in game. |
I finally managed to compile and have everything so I can start the executable. The ai_type works as expected in multiplayer mode. Random ai players get a valid value in the game. |
This could be included in 1.2 as is. It already adds helpful functionality. And it warns about what is not reliable. The fixing of single player must be in a complete different place, probably in single player startup code. It could be investigated later. |
Type of change
New feature
Before
In a multiplayer game, it is not possible to to detect reliably if a player is controlled by an ai.
The property
wl.Game().interactive_player
only shows the human player on the current game instance.Computer players are named "Computer N", but this is not a reliable source as it is translated in the hosts locale (#5991) and human players can choose such a name (partially prevented, see #5985).
New behavior
With the property
player.ai_type
, determining ai players is reliable. Making the exact type available to a script should not be a problem.Additional context
Be aware the type of the ai player can change, probably only when a human player looses the connection and is replaced by an ai.
It is possible that a player is controlled by a human and an ai (by using
playerX.switchplayer()
). This can not be detected.A use case is in forum post ..48