Opened 5 years ago

Closed 5 years ago

Last modified 3 years ago

#2755 closed defect (fixed)

Allow bots to quit game for testing

Reported by: agentx Owned by: ben
Priority: Should Have Milestone: Alpha 17
Component: AI Keywords:
Cc: Patch:

Description

http://trac.wildfiregames.com/browser/ps/trunk/binaries/data/mods/public/gui/session/messages.js

90	    "quit": function(notification, player)
91	    {
92	        exit(); // TODO this doesn't work anymore
93	    },

Would be very useful to launch multiple games one after the other for overnight testing.

Change History (22)

comment:1 Changed 5 years ago by Itms

Keywords: AI Testing removed
Milestone: Alpha 17Alpha 18

This is a bit too complex to be fixed before release IMO.

comment:2 Changed 5 years ago by stanislas69

Made some research it's broken since : http://trac.wildfiregames.com/changeset/15394/

It's because of the cleanup the way argument are passed changed, and that maybe broke quickstart too.

comment:3 Changed 5 years ago by stanislas69

You could restore it as a temporary hack but I'm not sure that's a good idea :)

comment:4 Changed 5 years ago by agentx

Milestone: Alpha 18Alpha 17

Looks like there is unfinished and untested work, doesn't look complex at all.

comment:5 in reply to:  4 Changed 5 years ago by Itms

Replying to agentx:

Looks like there is unfinished and untested work, doesn't look complex at all.

What I meant is that it's not a trivial fix (otherwise a TODO wouldn't have been added), and nobody is taking care of that, so I guess this won't be fixed before release. I may be wrong though, if you think it's easily fixable you can submit a patch and prove I am :)

comment:6 Changed 5 years ago by agentx

if you think it's easily fixable you can submit a patch and prove I am

Interesting logic. We can make a deal: You finish Hannibal and I commit the fix. So it is shown work is done faster if swapped mid term. Has some potential, think about!

Last edited 5 years ago by agentx (previous) (diff)

comment:7 Changed 5 years ago by Itms

Hmm, I probably lacked some diplomacy here and I'm sorry about it, but you have to understand that if we postpone the feature to a18 it's because we don't think we are capable to do it in time, so the only other alternative is that someone else does it...

comment:8 Changed 5 years ago by agentx

Well, I'm not asking for a _new_ feature, I'm asking for a functionality that already worked and got lost recently as indicated by the word: 'anymore' in the comment. Whether code work for releases should be finished or not is not part of my responsibility. What I can offer is to check whether the other ~50 commands are still accepted by the engine.

comment:9 Changed 5 years ago by historic_bruno

Milestone: Alpha 17Alpha 18

If someone fixes this for A17, they can move the milestone back.

comment:10 Changed 5 years ago by agentx

It would help to know if there is/ever was any documentation or useful comments. I'm quite sure exit did work once, at least as I started to dev with A15. What has to be taken care of while closing the game properly and is there an option to close it a la "don't care"? Is there an entry point for the latter?

Fixing a feature without any words on how it was meant to work is not realistic to happen.

comment:11 Changed 5 years ago by historic_bruno

Try changing exit() to Engine.Exit(). I don't even know how this would be used - without a simple test case, I can't easily know if it's fixed or not.

comment:12 Changed 5 years ago by agentx

I'd build a quick test bot, but autostart doesn't work, so choose Petra as bot and copy these lines into _petrabot.js

m.PetraBot.prototype.OnUpdate = function(sharedScript)
{
// test start

if (this.playedTurn > 5) {
  Engine.PostCommand(PlayerID, { type: "quit"});
} else {
  Engine.PostCommand(PlayerID, {type: "chat", message: this.playedTurn});
}

// test end
	if (this.gameFinished)

Expected behaviour is some chat messages and no trace of pyrogenesis left in task manager or htop.

comment:13 in reply to:  12 Changed 5 years ago by Josh

Replying to agentx:

I'd build a quick test bot, but autostart doesn't work, so choose Petra as bot and copy these lines into _petrabot.js

m.PetraBot.prototype.OnUpdate = function(sharedScript)
{
// test start

if (this.playedTurn > 5) {
  Engine.PostCommand(PlayerID, { type: "quit"});
} else {
  Engine.PostCommand(PlayerID, {type: "chat", message: this.playedTurn});
}

// test end
	if (this.gameFinished)

Expected behaviour is some chat messages and no trace of pyrogenesis left in task manager or htop.

When did autostart stop working? It worked fine for me just a couple months ago.

comment:14 Changed 5 years ago by stanislas69

It did ;) now I ´m getting errors and can use agentx python script see yesterdays conv for the link

comment:15 Changed 5 years ago by agentx

When did autostart stop working?

forum: http://www.wildfiregames.com/forum/index.php?showtopic=19105 ticket: #2798

Last edited 5 years ago by historic_bruno (previous) (diff)

comment:16 in reply to:  11 Changed 5 years ago by leper

Replying to historic_bruno:

Try changing exit() to Engine.Exit(). I don't even know how this would be used - without a simple test case, I can't easily know if it's fixed or not.

agentx: Have you tried that?

comment:17 Changed 5 years ago by agentx

TIMER| common/global.xml: 4.51868 ms
GAME STARTED, ALL INIT COMPLETE
ERROR: notification without players found.
({type:"quit"})

That's all. Let me know if you have a fix.

comment:18 in reply to:  15 Changed 5 years ago by mimo

Replying to agentx:

When did autostart stop working?

forum: http://www.wildfiregames.com/forum/index.php?showtopic=19105 ticket: #2798

Mixing everything is not the best way to solve problems. The problem you quote here is that civs are not properly transmitted when running on scenarios. I don't see how this would prevent you from testing the exit function (for which you don't care about civs, and anyway you could always test it in skirmishes where autostart do work as expected).

comment:19 Changed 5 years ago by ben

Owner: set to ben
Resolution: fixed
Status: newclosed

In 15758:

Fixes "quit" command and GUI notification for AI debugging, fixes #2755

comment:20 Changed 5 years ago by historic_bruno

Milestone: Alpha 18Alpha 17

comment:21 Changed 5 years ago by agentx

Works. Thanks.

comment:22 Changed 3 years ago by elexis

In 19155:

Remove the "quit" simulation command and restrict the "set-shading-color" simulation command to AIs,
since they are only useful for AI debugging and counterproductive in multiplayer mode, refs #3551.

Instead, enable AI developers to exit the game from a new AI API command,
allowing to batch simulate matches. Refs #2755.

Differential Revision: D65
Reviewed By: leper
Consulted: mimo

Note: See TracTickets for help on using tickets.