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

Lua attribute player.ai_type #6001

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

SimonHeimberg
Copy link
Contributor

@SimonHeimberg SimonHeimberg commented Jul 7, 2023

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

SimonHeimberg and others added 2 commits July 13, 2023 08:01
Co-authored-by: Benedikt Straub <48293446+Noordfrees@users.noreply.github.com>
@Noordfrees Noordfrees added this to the v1.2 milestone Jul 13, 2023
@SimonHeimberg
Copy link
Contributor Author

Now the tests pass.
How can I verify that the netclient has this attribute correct?

@SimonHeimberg
Copy link
Contributor Author

I could not yet practically test if the attribute is set in the game.

The setting player.ai is received and saved in netclient (see below, probably writes in player from game_settings.cc). So it hopefully is also available in game (on the netclient). But maybe player.ai (of src/logic/player.cc) stays empty.

player.ai = packet.string();

The type of ai is visible in the new game dialogue for the netclient. I guess it is still available in game.

@SimonHeimberg
Copy link
Contributor Author

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.
In single player mode random players seem to get the value "" (empty string), which is used for human players normally. As it is known that there is only one human player, it is still obvious, but unhandy.

@bunnybot bunnybot modified the milestones: v1.2, v1.3 Dec 10, 2023
@SimonHeimberg
Copy link
Contributor Author

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.

@bunnybot bunnybot added the ci:success CI checks succeeded label Apr 2, 2024
@bunnybot bunnybot added ci:success CI checks succeeded and removed ci:success CI checks succeeded labels May 1, 2024
@bunnybot bunnybot added ci:success CI checks succeeded and removed ci:success CI checks succeeded labels May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:success CI checks succeeded
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants