AI code generator

Scripting help, tricks, and tips. How to use the editor.
Post Reply
MD
Site Admin
Posts: 195
Joined: Sun Aug 12, 2007 2:06 pm

AI code generator

Post by MD »

Hi everyone,

I created a quick python script to help generate AI code for your levels. It's not fully functional, but I'm hoping it one day will be. I put up the source code on GitHub, so that perhaps others will contribute and expand it!

As an example of how to use it, I've included the AI code and raw parts list of my level, "Checkers", in checkersLevel-aiCode.py and checkersLevel-parts.txt.
Just run "python checkersLevel-aiCode.py"

It would be awesome if others would add to it!

Go to the GitHub repository now.

Cheers,
~MD
asdasdg
Posts: 240
Joined: Sun Dec 28, 2008 11:27 am
Contact:

Re: AI code generator

Post by asdasdg »

Well....this is rather unexpected. Thanks.
MD
Site Admin
Posts: 195
Joined: Sun Aug 12, 2007 2:06 pm

Re: AI code generator

Post by MD »

Yup! I wrote it over a year ago, and figured since I probably won't have time to polish it and make better I may as well just post it as-is and see if someone finds it useful.

~MD

p.s. I'll move this thread to Editor Help - just realized I posted this in the wrong section.
zxzx89002
Posts: 14
Joined: Wed Oct 15, 2014 11:55 am

Re: AI code generator

Post by zxzx89002 »

MD I Cant understand how u make the rocket make explode..can u write me he code here ?
i checked the Github code i didnt understand it..same as machine guns
MD
Site Admin
Posts: 195
Joined: Sun Aug 12, 2007 2:06 pm

Re: AI code generator

Post by MD »

The "exploding" rocket consists of two parts:
1. The body of the rocket moves linearly away from its parent object (the mothership), then disappears by moving off screen (distance = 9999).
(see macro_linearMove in zfai.py)
2. At the same time that the rocket disappears, a timer is set to do the following 3 things:
- enable the singularity guns (which cause the "explosion" - the guns themselves are hidden).
- set each gun's timer to play the firing sequence ("explode")
- then disable the singularity guns (until it's enabled again in the next explosion)
(see macro_singularityFire in zfai.py)

Also, you can try out the level within the level editor yourself by:
- copying the part list from checkersLevel-parts.txt into the "text edit" window
- execute checkersLevel-aiCode.py using the typical Python command:
> python checkersLevel-aiCode.py
which will generate a long list of text, which are AI commands - copy these into the AI code window in the editor.
- now run the level, and tinker with it as much as you like :)
MD
Site Admin
Posts: 195
Joined: Sun Aug 12, 2007 2:06 pm

Re: AI code generator

Post by MD »

I have updated this library. Go to https://github.com/skylogic004/zetaflow-levels to check it out.
Post Reply