Opened 8 years ago

Closed 7 years ago

Last modified 6 years 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 8 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 8 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)

by ixly, 8 years ago

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 by ixly, 8 years ago

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

comment:2 by Imarok, 8 years ago

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 8 years ago by Imarok (previous) (diff)

by ixly, 8 years ago

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 by ixly, 8 years ago

Thanks for that, patch should be OK now

comment:4 by ixly, 8 years ago

Keywords: review added; rfc removed

comment:5 by Stan, 8 years ago

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 by elexis, 8 years ago

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 by elexis, 8 years ago

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 by elexis, 7 years ago

Milestone: Alpha 22Work In Progress

Moving to the new WIP milestone.

comment:9 by Vladislav Belov, 7 years ago

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 reply to:  9 comment:10 by elexis, 7 years ago

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 by elexis, 7 years ago

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 by elexis, 7 years ago

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 by elexis, 7 years ago

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

comment:14 by elexis, 6 years ago

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.