Tuesday, April 17, 2012

Is it possible to modify AI platoons before load?

Bear with me as I'm just starting to dig into modding the AI.



My main question revolves around modding the AI after the game has loaded.



Is it possible to run a script, say via Mod_blueprints() that modifies the ai's platoons and brains and so on?



From what I understand, the reason why Sorian's AI pack is a scd in gamedata is so that he can add the AI's to the multiplayer screen. I'm wondering - what if I just modify the currently enabled AI, and insert the logic for being 'smart' with my mod? Essentially hooking the existing brain and rewriting it on the fly.



Possible?|||i support this question



looking a little into the lua i d like some expert 's hints on the best way to include 'on the fly storing and reading of data'



is there a way to handle a datbase from the lua instructions that can play an active role in the platoons behaviour and creation.



is it possible to write these datas to the disk for long term storage during game runtime.



for example a good start for learning Ai could be an Ai that can modify platoons priority on the fly during the game.



Another thing i wonder is : 'Is it possible to dismantle a platoon and affect the components to other ones. or is a platoon doomed to accomplish the set behaviours it was built for until it is destroyed ?



is it possible to modify the composition of a platoon acording to the change of behaviour.



is the only practical source of random affecting the same priority to platoons and setting up the 'random when same priority option' ?



i am currently working on a very limited objective NN, of which the task would simply be to find a good Build order by itself. not that there is a real point to it since this is one part of the game predictable enough for statistical data to be used instead. but i needed a simple challenge to do with and this one seemed suitable enough for a start.

Easy to evaluate , easy feedback,short runtime.|||Well, I know you can assign / remove the platoon 'brain' at any time, so you could disband and reform your platoons at will via script.|||thanks a lot pawz



another problem if you know, i ve been trying to initialise a table to store data at the beginning of the archetype file

with the other variable declaration



basically a table of the style



table[string][index] containing aither strings or numbers



but for some reason it kind of crashes the Ai using this archetype as well as any other AI in game even those not using the archetype containing the code.



secundo i look for a gimmick to store this table at the end of the game in a text file and load it from the file at the beginning into the above said table, so that the table datas are not lost.



the ideal would be to store the table in a readable text form so that one could mess with the data and control or nudge this and that with a text editor.|||I... don't think you CAN write to a file. The only thing I can think of is writing stuff to the log file and parsing through that with the /log switch (which saves the log to a text file) but other than that, I thought they'd removed the whole write to disk ability from the engine.



As for your table in the archetype file.. you're probably better off just storing a table of your own data in a lua file of your own... If you post an example of how you're making the table I can help point out what's wrong.







As for the original topic.. Sorian, maybe you read this - what do you guys think of making a generic little AI-picker panel that pops up at the start of the game, which lets you pick the AI? It would remove the requirement to make the AI packs an un-selectable SCD mod.|||Are you talking about when the game first loads?



It would have to be selectable before the lobby loads because that is when the available AIs are loaded, if not sooner. If there are AIs listed in the aitypes.lua that aren't actually installed the AI crashes. If there are AIs installed that aren't listed in the aitypes.lua file they aren't selectable.



Can the main menu screen be modified?



I have tried to make the AI mod Mod Manager compatible, but have failed in all attempts. Either I am missing something or it isn't possible at the moment. Every time I have tried only the default GPG AIs show up in the lobby.



*marking thread*|||I'm thinking bypass that whole bit entirely.



No mod is able to modify the main screen and still be a 'mod' in the true sense of the word, since it modifies things that are loaded way before the built in Mod Manager kicks in. Which is why AI mods are going to be stuck in limbo for a while until (if) they change the way the selectable AIs are created in the lobby.



What I'm thinking is that perhaps we can bypass the lobby entirely and create an ai-selector in-game. This would mean the game loads the default AI as selected in the lobby, and then WE load our own AI and swap it with the default AI's brain.



If this is possible, it would be dead easy to make a little UI that pops up when you start the game that would allow you to 'load' a new brain into the AI, opening up the possibility of making AIs truly Mod-Manager capable.





The first thing to look at would the the creation of the AI brain itself - can we create a new brain and assign it units, and a plan? Failing that, we should be able to hook the AIBrain.lua file and override the OnCreateAI(self, planName) with calls to create a dialog that asks for the plan name.|||I am not sure if that would really suit you needs pawz

and what i am about to say probably came to your mind already provided you seem way more comfortable with the AI architecture already than i am.



maybee you discarded that idea for rescources consumption reasons that to be honest i have not taken the time to assess.



the idea would be to copy the platoons and include inside a build condition of a platoon that refers to a function that returns true if a variable is set to the desired 'AI' that could be included as a parameter and false if the AIinuse and the parameter are different.



it would not work for a brain change though since the brain is a default parameter for most function and is not a value in the archetypes tables so i am not sure we could switch between 2 brains that easily.



maybee for the brain part a similar gimmick is possible, i mean basically copying all the brain AI and forking each function or procedure depending on the value of the 'AIinuse' variable.





to achieve the result we would change in game on the fly the variable 'AIinuse'

which would in turn cause the Archetype to build platoons that fits that Ai and ignore the platoons related to other Ai.

on the brain side every function called would use the part of its code related to the Ai in use.



now i dont know if it is possible to install a 'nea' checkbox thingy or any other graphic module to switch between AIs on the fly.



or if it would be possible to monitor chat for key inputs that would achieve the same results.

I now sorian's AI are capable of using the chat to send messages to allies maybee they can monitor the chat and read it too. but that looks more like a gettho way of switching for initiate than a real enduser utility.



i am not sure if sorian reads this thread but on a lower level if an AI can monitor the chat maybee they could decypher allies messages and respond to it accordingly sending a platoon or too for help or things in that taste, i am sure it would add immersion to playing teamed with AI.|||Ok, I'm working on this solution at the moment.



One thing we know for a fact is that we can't change the lobby without making the mod a gamedata SCD, and mod-manager incompatible.



What if we completely replace the *default* AIs with our new AI code though?



Since the AI brains aren't loaded until after the game is loaded and the mod is applied, it should be possible to overwrite the default AI's codebase with the mod.



The obvious drawback of course is that you are limited in the number of different AIs that you can have playing at the same time - but, I'm not really sure how many people would really match up more than 4 different AIs together...|||Interesting idea.



The most I have ever had was 6 different AIs. Sorian, Sorian Rush, and Jaws2002 vs 3 other AIs. :)

No comments:

Post a Comment