[MODCOMP] AIAutoPlay

I have a basic set of source files including 3.13, Bhruic 1.21 and AIAutoplay. This is great for testing out new SDK stuff - sort of a "clean slate", ready to fuse anything new into.
 
It has in the version of AIAutoPlay in Revolution, it's been a while since I updated this version. I intend to put out a 3.17 version of this and would certainly include the latest AIAutoPlay Python code but I'm not sure whether to include Solver's unofficial patch or not ... probably not since it's constantly evolving.

There are pieces (or maybe even all of it) in Better BtS AI. Is that the latest version of AIAutoPlay (and also the complete version) ?
 
Hey man, been messin with this comp again. :lol:

I found it isn't MP compatable. I narrowed it down to the setAIAutoPlay function in CvGame.cpp.
Code:
/********************************************************************************/
		/**		AI_AUTO_PLAY_MOD						1/1/08				jdog5000	*/
		/**																				*/
		/**																				*/
		/********************************************************************************/
		GET_PLAYER(getActivePlayer()).setDisableHuman((getAIAutoPlay() != 0));

This runs into the common getActivePlayer MP glitch where it returns different ePlayerIDs on the different computers.

I replaced it with a simple loop through all the players and set all the humans to be disabled. I have tested this and the SDK change makes it MP compatable, but only the CTRL + SHIFT + X command will work in MP. If you set up events, like you did for the Abdicate, for the End Abdicate and Single Turn Abdicate Key Events and it will totally work for MP games. Me and my buddy have already played a few games against each other, totally on auto. :cool:

Note I named my new AIAutoPlay function different, but it should be pretty self explanitory.
Code:
		// ---------------- AI_AUTO_PLAY_MOD start --------------------

		//GET_PLAYER(getActivePlayer()).setHumanDisabled((getAIAutoPlay() != 0));
		for (int i = 0; i < MAX_PLAYERS; ++i)
        {
            CvPlayer& kPlayer = GET_PLAYER((PlayerTypes)i);
            if (getAIAutoPlay() == 0 && kPlayer.isHumanDisabled())
            {
                kPlayer.setHumanDisabled(false);
            }
            else if (getAIAutoPlay() > 0 && kPlayer.isHuman() && !kPlayer.isHumanDisabled())
            {
                kPlayer.setHumanDisabled(true);
            }
        }

I also noticed that also plassing the code in changeAIAutoPlay is unnessassary as that function calls setAIAutoPlay witch will handle it for you.

Just some things I noticed and thought I should mention. :band:
 
Version 2.0 for BTS 3.17 is up!

Thanks to Jeckel's suggestions it is now multiplayer compatible, though automation applies to all players(!). This is most useful either for finishing a game that's already in hand or basically setting up a random mutliplayer scenario ... automate the first few hundred turns and then really take over in the middle of history.

The other main new feature is that automation will stop at the end of the game (even if you entered 1000 turns) so you can see the game end screens, generate the replay, etc. This requires a minor SDK change for the timing of notifying Python of the victory (before ending the game instead of after ...) so the SDK sources have been updated to reflect this for you mergers.

Note that this does not include any unofficial patches or anything like that ... if you're looking for that, this mod is DLL compatible with the Better BTS AI mod. It should be very easy to merge the two, replace the AIAutoPlay DLL with the one from Better BTS AI and simply move the other files over from BBA to the same places in the AIAutoPlay folder. Note that the stopping automation on victories feature will only work for versions of Better BTS AI released after this post (ie versions after 0.21), all other features will work.

Enjoy!
 
I've use my own cut-down modified to hell version of AIAutoplay, but the original came from you. Thanks it's saved me months in playtesting my mods. :)
 
I didn't import it, but FfH uses the DLL portion of this (wouldn't mind adding the Python, might someday), but I also must express a hearty THANKS for your work. Found quite a few glitches in my mod-mod work which wouldn't have shown up any other way than playing (and who has time for that?!)
 
I don't want to use DrElmerGiggles custom event manager, so I only copied over the SDK changes. If I understand correctly, Autoplay should work with only the SDK changes, no?

Unfortunately I can't get it to work. When I type the required command in the python console, it says it's invalid syntax. It's not just the AIAutoplay. Trying to toggle debug mode gives the same result, so I might be unable to use the python console at all for some reason.

Do you know what might be the problem? :(
(I forgot the dot on my first try, but I don't see the problem with the other attempts)

I've set the cheat code in the BtS ini to chipotle.

Edit: Game.AIPlay x works. But then I don't understand what the advice on the download page is about, re CyGame() etc. :confused:
 
That screenshot is from the regular console (called by " ` "), not the Python console (called by " ~ "); you can tell because there's no initial first line describing the python version. If your keyboard is like mine, both characters are on the same key and you need to be holding down shift to get the " ~ " which enters the Python console; it's pretty easy to let it go too soon.
 
Hmm, I have an Azerty (and laptop) keyboard. This seems to screw up lots of keys while in the console. Some are Azerty; some are Qwerty. :hmm:

When I switch to Dvorak layout (trying to learn that now), I can press ~, and that brings up the console on the screenie. Pressing ` however doesn't bring up any console. :(

Anyway, does Game.AIPlay x on the 'regular' console do exactly the same thing as CyGame().setAIAutoPlay(x) on the python console?
 
You know you have the right console if it show you a prompt:

>>

instead of:

>




So press random things till you get that. And make sure you have chipotle activated.



Never heard of the normal console command, so can't comment.
 
I managed to get the python console showing up.

AI Autoplay seems to have some problems though. :hmm: Sometimes the game crashes during autoplay. When I replay the turn 'manually', or when I reload the latest autosave and restart Autoplay, the crash no longer occurs.
 
Sorry, don't know what Game.AIPlay in the regular console does ... it very well may do the same thing.

It doesn't make any sense to me why you'd be seeing crashes in auto play ... the SDK changes are incredibly simple since the turn automation functionality was implemented by Firaxis, I just changed it so it overrode the isHuman setting instead of killing off your civ. The AIAutoPlay changes can't cause a crash on their own, there must be something else going on.
 
I've autoplayed the game with just the AIAutoPlay changes for literally thousands and thousands of turns and there is no CTD. If you are getting one, then it must be somthing else.
 
I've downloaded this and haven't the foggiest how to install and get it up and running. Where does it go and how do I get it to work? And will it work with mods running, such as the FfH2 mod?
 
I added installation instructions to the download page, check those out.

This mod can be added to many other mods easily, but for something with a custom DLL it's much more complicated. The good news is that I believe FfH2 has the AIAutoPlay SDK portion already in it. You can test it out to check by using the instructions here.
 
Back
Top Bottom