Opened 3 years ago

Closed 2 years ago

Last modified 22 months ago

#4078 closed defect (fixed)

[PATCH] Singleplayergame with only bots

Reported by: elexis Owned by: elexis
Priority: Nice to Have Milestone: Alpha 22
Component: UI & Simulation Keywords: patch
Cc: Patch:

Description (last modified by elexis)

It should be possible to start a game with only bots assigned (and without having to start a networked game for that).

Relevant code is all in gamesetup.js. The player should still be assigned to slot 1 by default, but if unassigned, don't reassign forcefully.

Attachments (2)

all_ai_in_sp.patch (2.4 KB) - added by ixly 3 years ago.
Do not forcefully reassign players and remove the check requiring at least one human player to start
all_ai_in_sp_v2.patch (3.2 KB) - added by ixly 3 years ago.
Do not forcefully reassign players and remove the check requiring at least one human player to start

Download all attachments as: .zip

Change History (16)

Changed 3 years ago by ixly

Attachment: all_ai_in_sp.patch added

Do not forcefully reassign players and remove the check requiring at least one human player to start

comment:1 Changed 3 years ago by ixly

Keywords: rfc patch added
Milestone: BacklogAlpha 21
Summary: Singleplayergame with only bots[PATCH] Singleplayergame with only bots

comment:2 Changed 3 years ago by Imarok

Your patch works. Style looks good.

Only remarks:

  • delete L1604-L1606 and enable the StartGame? button by default in gamesetup.xml
  • assignedCount is not used anymore, so remove it at all
  • Use if ( instead of if(
Last edited 3 years ago by Imarok (previous) (diff)

Changed 3 years ago by ixly

Attachment: all_ai_in_sp_v2.patch added

Do not forcefully reassign players and remove the check requiring at least one human player to start

comment:3 Changed 3 years ago by ixly

Thanks for that, patch should be OK now

comment:4 Changed 3 years ago by ixly

Keywords: review added; rfc removed

comment:5 Changed 3 years ago by stanislas69

Keywords: rfc added; review removed

Hey Ixly only devs are allowed to put patches in the review queue, so I'm bumping this back to rfc queue. Thanks for your work.

comment:6 Changed 3 years ago by elexis

Independent TODO:

It were great if we could fast forward AI only games with more than 2x speed. This can happen when setting g_GameSpeeds in session.js. game_speeds.json and settings.js would have to be extended. This can happen independently of the gamesetup patch.

comment:7 Changed 3 years ago by elexis

Milestone: Alpha 21Alpha 22

Sorry that we didn't have time to review this yet. Part of the fact is that it is very easy to break things in this file in non-obvious ways.

comment:8 Changed 3 years ago by elexis

Milestone: Alpha 22Work In Progress

Moving to the new WIP milestone.

comment:9 Changed 3 years ago by Vladislav Belov

Your patch allows to use unassigned players (gray "Unassigned"), it doesn't throw any error for me, but I think, it's not good to allow to the user do that.

comment:10 in reply to:  9 Changed 3 years ago by elexis

Keywords: simple rfc removed

Hello ixly! Sorry we had no time to further review your patch in the last 6 months :/ The patch still applies cleanly and is mostly correct. However it needs some polishing:

  • guid.substr(0, 3) == "ai:" can use startsWith
  • Merging of the unassigned and ai case is good, I'm surprised it wasn't done in svn yet (in one of my branches though :P)
  • enabled="true" is not needed, as that is the default
  • Notice that we can already start a networked game with only bots, as unassigning the previously replaced player in MP games is done via the Engine.AssignNetworkPlayer(playerID, ""); statement. So your addition is correct, but this one seems more straight-forward (and avoids a variable):
    else if (g_PlayerAssignments.local.player == idx+1)
        g_PlayerAssignments.local.player = -1;
    
    (Also this check is preferable as it doesn't rely on the selection variable which is constructed by the somewhat complicated but unneeded code in the same function. )
  • Removal of the Only enable start button if we have enough assigned players is correct, as that check was tautological in singleplayer and irrelevant in multiplayer.

Replying to vladislavbelov:

Your patch allows to use unassigned players (gray "Unassigned"), it doesn't throw any error for me, but I think, it's not good to allow to the user do that.

In that case we should remove the "Unassigned" option altogether, right?

About fast-forwarding (more than 2x) in singleplayer: that doesn't seem useful currently as the AI is too slow for that in the first place.

comment:11 Changed 3 years ago by elexis

Also the unassignInvalidPlayers function resets the player to slot 1 if it was assigned to a slot that was removed after reducing the number of players. Instead, the player could remain unassigned, so as not to overwrite AI setting.

comment:12 Changed 2 years ago by elexis

Owner: set to elexis
Resolution: fixed
Status: newclosed

In 19504:

Unify gamesetup option handling, fixes #3994, refs #3049.

Removes a lot of duplication and ugly GUI handling code with very similar, yet different code paths.
Move the setting specific logic to the functions of that setting and keep the universal logic in global atomic functions.
Make gamesetup.xml agnostic of all gamesetup settings.

Adding a new gamesetup option now only requires adding one hunk with the titles and values and one line in g_OptionOrderGUI.
Opens up the possibility to iterate over all settings, refs #3806, #3883.

Allow starting singleplayer games in observermode with only AIs assigned, fixes #4078.
Autocomplete translations of all setting titles and selected title values like playernames and victory conditions.

Transfer the AI difficulty when swapping with a player.
Move logic from onTick to the GUI handling functions.
Change some global consts to var, so that contributors become invited to change them from a different place.
Add missing startGameButton tooltip translation.

Differential Revision: https://code.wildfiregames.com/D322
Reviewed By: wraitii
Some strings reviewed By: leper

comment:13 Changed 2 years ago by elexis

Description: modified (diff)
Milestone: Work In ProgressAlpha 22

comment:14 Changed 22 months ago by elexis

In 20577:

Allow fast-forwarding of matches with only AI players.

Differential Revision: https://code.wildfiregames.com/D595
Refs #4078
Accepted By: Grugnas

Note: See TracTickets for help on using tickets.