Help with creating an AI using JS

For AI and campaign script related discussions and questions
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Help with creating an AI using JS

Post by NoQ »

aubergine wrote:How do I find out if a given droid object is a VTOL or not? I know it will be defined in the .droidType property, but can't find a list of possible values for that property :s
I'm also looking for a way to find out how many modules a structure has.
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Help with creating an AI using JS

Post by NoQ »

Anyhow, here's my current progress.

I wasn't yet able to figure out how to make modules properly (so don't read module building code plz :oops: ), and i was too lazy to add VTOL code, but here's a hopefully-working non-cheating javascript AI that is able to defeat a medium Nexus bot in certain cases (:
Attachments
nullbot-0-1.wz
Works with latest git, install to mods/multiplay
(4.59 KiB) Downloaded 219 times
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: Help with creating an AI using JS

Post by aubergine »

Do you know if there's any way to get information about the map - eg. it's size? -- Just spotted the mapWidth and mapHeight globals in the JS API docs.

Also is there any way to set the factory properties - eg. when you right click a factory you can set it so that all units it makes are "fire at long range", etc. And on units you can set them to patrol, etc.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Help with creating an AI using JS

Post by Per »

aubergine wrote:How do I find out if a given droid object is a VTOL or not? I know it will be defined in the .droidType property, but can't find a list of possible values for that property :s
The function isVTOL(droid). It is not set in .droidType. The .droidType values are now defined in the documentation.
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Help with creating an AI using JS

Post by Per »

NoQ wrote:I'm also looking for a way to find out how many modules a structure has.
I just added that to relevant structures as the 'modules' property.
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: Help with creating an AI using JS

Post by aubergine »

Would it be worth doing something similar to droid objects - eg. someDroid.isVTOL ?
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: Help with creating an AI using JS

Post by aubergine »

@NoQ: Found an issue with Nullbot - if there is a turret near an uncaptured oil resource, nullbot churns out endless numbers of trucks and sends them to their death rather than building an army to attack with - it might make a few tanks, but doesn't reach MIN_ATTACKERS because it's too busy churning out truck lemmings.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Help with creating an AI using JS

Post by NoQ »

Agreed, it needs to check for threats before building derricks.
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Help with creating an AI using JS

Post by NoQ »

After a git pull, nullbot-0-1.wz has started to crash with the following Floating Point Exception at the moment it is just about to complete its first lab (or maybe rather when it was just completed). What am i missing? :oops: What has changed? :o
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Help with creating an AI using JS

Post by Per »

NoQ wrote:After a git pull, nullbot-0-1.wz has started to crash with the following Floating Point Exception at the moment it is just about to complete its first lab (or maybe rather when it was just completed). What am i missing? :oops: What has changed? :o
Not exactly sure why, but for some reason a feature has zero health when it is presented to the script. Don't have time to investigate much, but I have fixed the symptom, so it should no longer crash.
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Help with creating an AI using JS

Post by NoQ »

This must have been an oil derrick ... Ok (:
upd: working now, yeah.
Post Reply