Zerg AI problem
- Archon_Wing
- Posts: 903
- Joined: Wed Jul 25, 2007 11:22 pm [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
- pandut
- Posts: 26
- Joined: Tue Jul 03, 2007 6:17 am [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Nerco FTW!
Hey guys. I'm back after a long period of hibernation. I've decided to finish this old project I started on a while ago.
Anyway, after studying this thread and other Zerg AI scripts, I have made some changes to the Zerg script used in my mod. It works now, building drones and attacking accordingly, however there is an unexpected crash somewhere that continues to elude me.
CODE# stat_txt.tbl entry 1344: Zerg Expansion Custom Level<0>
ZMCx(1344, 111, aiscript):
start_town()
transports_off()
farms_notiming()
define_max(20, Zerg Defiler)
define_max(70, Zerg Drone)
define_max(100, Zerg Zergling)
define_max(20, Zerg Overlord)
define_max(0, Zerg Hydralisk)
define_max(16, Zerg Ultralisk)
build(1, Zerg Hatchery, 80)
build(4, Zerg Drone, 40)
multirun(dronebuild)
wait(150)
multirun(moneyloop)
wait(300)
attack_add(4, Zerg Zergling)
attack_prepare()
attack_do()
attack_clear()
clear_combatdata()
defensebuild_gg(6, Zerg Zergling)
defenseuse_gg(6, Zerg Zergling)
build(1, Zerg Drone, 40)
build(2, Zerg Drone, 40)
build(3, Zerg Drone, 40)
train(4, Zerg Zergling)
build(1, Zerg Creep Colony, 80)
wait_build(1, Zerg Creep Colony)
build(1, Zerg Sunken Colony, 80)
wait_build(1, Zerg Sunken Colony)
build(2, Zerg Creep Colony, 80)
wait_build(2, Zerg Creep Colony)
build(2, Zerg Sunken Colony, 80)
wait_build(2, Zerg Sunken Colony)
wait(200)
build(2, Zerg Hatchery, 80)
wait_build(2, Zerg Hatchery)
build(1, Zerg Evolution Chamber, 80)
build(4, Zerg Drone, 40)
build(5, Zerg Drone, 40)
build(6, Zerg Drone, 40)
upgrade(1, Ventral Sacs, 70)
define_max(40, Zerg Hydralisk)
build(2, Zerg Evolution Chamber, 80)
expand(1, ZMCx 0000)
train(2, Zerg Zergling)
build(1, Zerg Overlord, 40)
train(1, Zerg Ultralisk)
multirun(ZMCx 0001)
build(3, Zerg Hatchery, 80)
attack_add(18, Zerg Zergling)
attack_add(6, Zerg Hydralisk)
attack_prepare()
attack_do()
attack_clear()
clear_combatdata()
build(3, Zerg Creep Colony, 80)
wait_build(3, Zerg Creep Colony)
build(3, Zerg Sunken Colony, 80)
wait_build(3, Zerg Sunken Colony)
build(4, Zerg Creep Colony, 80)
wait_build(4, Zerg Creep Colony)
build(4, Zerg Sunken Colony, 80)
wait_build(4, Zerg Sunken Colony)
expand(2, ZMCx 0000)
multirun(ZMCx 0002)
build(4, Zerg Hatchery, 80)
build(7, Zerg Drone, 40)
build(8, Zerg Drone, 40)
build(9, Zerg Drone, 40)
defensebuild_gg(4, Zerg Hydralisk)
defenseuse_gg(4, Zerg Hydralisk)
wait(400)
multirun(oviebuild)
wait(300)
attack_add(20, Zerg Zergling)
attack_add(2, Zerg Defiler)
attack_add(10, Zerg Hydralisk)
attack_add(2, Zerg Ultralisk)
attack_prepare()
attack_do()
attack_clear()
clear_combatdata()
train(1, Zerg Zergling)
train(1, Zerg Ultralisk)
multirun(ZMCx 0003)
build(5, Zerg Hatchery, 80)
build(10, Zerg Drone, 40)
build(11, Zerg Drone, 40)
build(12, Zerg Drone, 40)
wait(300)
attack_add(24, Zerg Zergling)
attack_add(2, Zerg Defiler)
attack_add(16, Zerg Hydralisk)
attack_add(4, Zerg Ultralisk)
attack_prepare()
attack_do()
attack_clear()
clear_combatdata()
build(13, Zerg Drone, 40)
build(14, Zerg Drone, 40)
build(15, Zerg Drone, 40)
train(1, Zerg Zergling)
train(1, Zerg Ultralisk)
multirun(ZMCx 0004)
expand(3, ZMCx 0000)
wait(100)
attack_add(28, Zerg Hydralisk)
attack_add(4, Zerg Ultralisk)
attack_prepare()
attack_do()
attack_clear()
clear_combatdata()
build(16, Zerg Drone, 40)
build(17, Zerg Drone, 40)
build(18, Zerg Drone, 40)
train(1, Zerg Zergling)
train(1, Zerg Hydralisk)
upgrade(2, Zerg Carapace, 70)
train(1, Zerg Zergling)
train(1, Zerg Ultralisk)
wait(300)
attack_add(38, Zerg Zergling)
attack_add(2, Zerg Defiler)
attack_add(22, Zerg Hydralisk)
attack_add(6, Zerg Ultralisk)
attack_prepare()
attack_do()
attack_clear()
clear_combatdata()
build(19, Zerg Drone, 40)
build(20, Zerg Drone, 40)
build(21, Zerg Drone, 40)
expand(4, ZMCx 0000)
wait(200)
attack_add(48, Zerg Zergling)
attack_add(8, Zerg Ultralisk)
attack_prepare()
attack_do()
attack_clear()
clear_combatdata()
train(1, Zerg Zergling)
train(1, Zerg Hydralisk)
train(1, Zerg Ultralisk)
wait(150)
attack_add(18, Zerg Zergling)
attack_add(16, Zerg Hydralisk)
attack_add(10, Zerg Ultralisk)
attack_prepare()
attack_do()
attack_clear()
clear_combatdata()
train(1, Zerg Zergling)
train(1, Zerg Zergling)
train(1, Zerg Ultralisk)
upgrade(3, Zerg Carapace, 70)
build(22, Zerg Drone, 40)
build(23, Zerg Drone, 40)
build(24, Zerg Drone, 40)
wait(200)
--block1--
attack_add(48, Zerg Zergling)
attack_add(4, Zerg Defiler)
attack_add(26, Zerg Hydralisk)
attack_add(8, Zerg Ultralisk)
attack_prepare()
attack_do()
attack_clear()
clear_combatdata()
expand(5, ZMCx 0000)
clear_combatdata()
defensebuild_gg(1, Zerg Zergling)
wait(500)
goto(block1)
--ZMCx 0000--
start_town()
build(1, Zerg Hatchery, 80)
wait_build(1, Zerg Hatchery)
build(1, Zerg Overlord, 40)
build(1, Zerg Drone, 40)
build(2, Zerg Drone, 40)
build(3, Zerg Drone, 40)
defensebuild_gg(2, Zerg Zergling)
build(4, Zerg Drone, 40)
build(5, Zerg Drone, 40)
build(6, Zerg Drone, 40)
place_guard(Zerg Ultralisk, 1)
wait(1000)
build(2, Zerg Hatchery, 80)
wait_build(2, Zerg Hatchery)
build(1, Zerg Creep Colony, 80)
wait_build(1, Zerg Creep Colony)
build(1, Zerg Sunken Colony, 80)
wait_build(1, Zerg Sunken Colony)
build(2, Zerg Creep Colony, 80)
wait_build(2, Zerg Creep Colony)
build(2, Zerg Sunken Colony, 80)
wait_build(2, Zerg Sunken Colony)
build(7, Zerg Drone, 40)
build(8, Zerg Drone, 40)
build(9, Zerg Drone, 40)
wait(500)
build(3, Zerg Creep Colony, 80)
wait_build(3, Zerg Creep Colony)
build(3, Zerg Sunken Colony, 80)
wait_build(3, Zerg Sunken Colony)
build(4, Zerg Creep Colony, 80)
wait_build(4, Zerg Creep Colony)
build(4, Zerg Sunken Colony, 80)
wait_build(4, Zerg Sunken Colony)
build(10, Zerg Drone, 40)
build(11, Zerg Drone, 40)
build(12, Zerg Drone, 40)
stop()
--ZMCx 0001--
upgrade(1, Zerg Missile Attacks, 70)
wait(900)
upgrade(1, Zerg Melee Attacks, 70)
stop()
--ZMCx 0002--
train(4, Zerg Zergling)
upgrade(2, Zerg Melee Attacks, 70)
wait(900)
upgrade(2, Zerg Missile Attacks, 70)
stop()
--ZMCx 0003--
train(1, Zerg Zergling)
train(1, Zerg Ultralisk)
upgrade(1, Chitinous Plating, 70)
wait(500)
upgrade(1, Anabolic Synthesis, 70)
upgrade(1, Zerg Carapace, 70)
stop()
--ZMCx 0004--
train(1, Zerg Hydralisk)
train(1, Zerg Defiler)
upgrade(3, Zerg Missile Attacks, 70)
upgrade(3, Zerg Melee Attacks, 70)
stop()
--moneyloop--
give_money()
wait(100)
goto(moneyloop)
--dronebuild--
build(1, Zerg Drone, 40)
wait_buildstart(1, Zerg Drone)
wait(600)
build(2, Zerg Drone, 40)
wait_buildstart(2, Zerg Drone)
wait(600)
build(3, Zerg Drone, 40)
wait_buildstart(3, Zerg Drone)
goto(dronebuild)
--oviebuild--
build(1, Zerg Overlord, 40)
wait_build(1, Zerg Overlord)
wait(600)
build(2, Zerg Overlord, 40)
wait_build(2, Zerg Overlord)
wait(600)
build(3, Zerg Overlord, 40)
wait_build(3, Zerg Overlord)
wait(600)
stop()
Yes, I've implemented 'build(1, Zerg Drone, 40)' scripts because quite frankly, that is the only way I can get the AI to build drones correctly.
The --dronebuild-- code works very usefully as well; the AI will construct a drone every now and then, or replace drones that were used to morph into structures.
Now, the crash occurs a few minutes after the AI builds their fifth and final hatchery (Save for hatchery's in expansions). I've studied the script along that closely, however my scripter-in-training eyes can't locate the error.
Other then the crash, the AI works flawlessly. It still spams Hydralisks, however not in the large quantity as it once did.
Hey guys. I'm back after a long period of hibernation. I've decided to finish this old project I started on a while ago.
Anyway, after studying this thread and other Zerg AI scripts, I have made some changes to the Zerg script used in my mod. It works now, building drones and attacking accordingly, however there is an unexpected crash somewhere that continues to elude me.
CODE# stat_txt.tbl entry 1344: Zerg Expansion Custom Level<0>
ZMCx(1344, 111, aiscript):
start_town()
transports_off()
farms_notiming()
define_max(20, Zerg Defiler)
define_max(70, Zerg Drone)
define_max(100, Zerg Zergling)
define_max(20, Zerg Overlord)
define_max(0, Zerg Hydralisk)
define_max(16, Zerg Ultralisk)
build(1, Zerg Hatchery, 80)
build(4, Zerg Drone, 40)
multirun(dronebuild)
wait(150)
multirun(moneyloop)
wait(300)
attack_add(4, Zerg Zergling)
attack_prepare()
attack_do()
attack_clear()
clear_combatdata()
defensebuild_gg(6, Zerg Zergling)
defenseuse_gg(6, Zerg Zergling)
build(1, Zerg Drone, 40)
build(2, Zerg Drone, 40)
build(3, Zerg Drone, 40)
train(4, Zerg Zergling)
build(1, Zerg Creep Colony, 80)
wait_build(1, Zerg Creep Colony)
build(1, Zerg Sunken Colony, 80)
wait_build(1, Zerg Sunken Colony)
build(2, Zerg Creep Colony, 80)
wait_build(2, Zerg Creep Colony)
build(2, Zerg Sunken Colony, 80)
wait_build(2, Zerg Sunken Colony)
wait(200)
build(2, Zerg Hatchery, 80)
wait_build(2, Zerg Hatchery)
build(1, Zerg Evolution Chamber, 80)
build(4, Zerg Drone, 40)
build(5, Zerg Drone, 40)
build(6, Zerg Drone, 40)
upgrade(1, Ventral Sacs, 70)
define_max(40, Zerg Hydralisk)
build(2, Zerg Evolution Chamber, 80)
expand(1, ZMCx 0000)
train(2, Zerg Zergling)
build(1, Zerg Overlord, 40)
train(1, Zerg Ultralisk)
multirun(ZMCx 0001)
build(3, Zerg Hatchery, 80)
attack_add(18, Zerg Zergling)
attack_add(6, Zerg Hydralisk)
attack_prepare()
attack_do()
attack_clear()
clear_combatdata()
build(3, Zerg Creep Colony, 80)
wait_build(3, Zerg Creep Colony)
build(3, Zerg Sunken Colony, 80)
wait_build(3, Zerg Sunken Colony)
build(4, Zerg Creep Colony, 80)
wait_build(4, Zerg Creep Colony)
build(4, Zerg Sunken Colony, 80)
wait_build(4, Zerg Sunken Colony)
expand(2, ZMCx 0000)
multirun(ZMCx 0002)
build(4, Zerg Hatchery, 80)
build(7, Zerg Drone, 40)
build(8, Zerg Drone, 40)
build(9, Zerg Drone, 40)
defensebuild_gg(4, Zerg Hydralisk)
defenseuse_gg(4, Zerg Hydralisk)
wait(400)
multirun(oviebuild)
wait(300)
attack_add(20, Zerg Zergling)
attack_add(2, Zerg Defiler)
attack_add(10, Zerg Hydralisk)
attack_add(2, Zerg Ultralisk)
attack_prepare()
attack_do()
attack_clear()
clear_combatdata()
train(1, Zerg Zergling)
train(1, Zerg Ultralisk)
multirun(ZMCx 0003)
build(5, Zerg Hatchery, 80)
build(10, Zerg Drone, 40)
build(11, Zerg Drone, 40)
build(12, Zerg Drone, 40)
wait(300)
attack_add(24, Zerg Zergling)
attack_add(2, Zerg Defiler)
attack_add(16, Zerg Hydralisk)
attack_add(4, Zerg Ultralisk)
attack_prepare()
attack_do()
attack_clear()
clear_combatdata()
build(13, Zerg Drone, 40)
build(14, Zerg Drone, 40)
build(15, Zerg Drone, 40)
train(1, Zerg Zergling)
train(1, Zerg Ultralisk)
multirun(ZMCx 0004)
expand(3, ZMCx 0000)
wait(100)
attack_add(28, Zerg Hydralisk)
attack_add(4, Zerg Ultralisk)
attack_prepare()
attack_do()
attack_clear()
clear_combatdata()
build(16, Zerg Drone, 40)
build(17, Zerg Drone, 40)
build(18, Zerg Drone, 40)
train(1, Zerg Zergling)
train(1, Zerg Hydralisk)
upgrade(2, Zerg Carapace, 70)
train(1, Zerg Zergling)
train(1, Zerg Ultralisk)
wait(300)
attack_add(38, Zerg Zergling)
attack_add(2, Zerg Defiler)
attack_add(22, Zerg Hydralisk)
attack_add(6, Zerg Ultralisk)
attack_prepare()
attack_do()
attack_clear()
clear_combatdata()
build(19, Zerg Drone, 40)
build(20, Zerg Drone, 40)
build(21, Zerg Drone, 40)
expand(4, ZMCx 0000)
wait(200)
attack_add(48, Zerg Zergling)
attack_add(8, Zerg Ultralisk)
attack_prepare()
attack_do()
attack_clear()
clear_combatdata()
train(1, Zerg Zergling)
train(1, Zerg Hydralisk)
train(1, Zerg Ultralisk)
wait(150)
attack_add(18, Zerg Zergling)
attack_add(16, Zerg Hydralisk)
attack_add(10, Zerg Ultralisk)
attack_prepare()
attack_do()
attack_clear()
clear_combatdata()
train(1, Zerg Zergling)
train(1, Zerg Zergling)
train(1, Zerg Ultralisk)
upgrade(3, Zerg Carapace, 70)
build(22, Zerg Drone, 40)
build(23, Zerg Drone, 40)
build(24, Zerg Drone, 40)
wait(200)
--block1--
attack_add(48, Zerg Zergling)
attack_add(4, Zerg Defiler)
attack_add(26, Zerg Hydralisk)
attack_add(8, Zerg Ultralisk)
attack_prepare()
attack_do()
attack_clear()
clear_combatdata()
expand(5, ZMCx 0000)
clear_combatdata()
defensebuild_gg(1, Zerg Zergling)
wait(500)
goto(block1)
--ZMCx 0000--
start_town()
build(1, Zerg Hatchery, 80)
wait_build(1, Zerg Hatchery)
build(1, Zerg Overlord, 40)
build(1, Zerg Drone, 40)
build(2, Zerg Drone, 40)
build(3, Zerg Drone, 40)
defensebuild_gg(2, Zerg Zergling)
build(4, Zerg Drone, 40)
build(5, Zerg Drone, 40)
build(6, Zerg Drone, 40)
place_guard(Zerg Ultralisk, 1)
wait(1000)
build(2, Zerg Hatchery, 80)
wait_build(2, Zerg Hatchery)
build(1, Zerg Creep Colony, 80)
wait_build(1, Zerg Creep Colony)
build(1, Zerg Sunken Colony, 80)
wait_build(1, Zerg Sunken Colony)
build(2, Zerg Creep Colony, 80)
wait_build(2, Zerg Creep Colony)
build(2, Zerg Sunken Colony, 80)
wait_build(2, Zerg Sunken Colony)
build(7, Zerg Drone, 40)
build(8, Zerg Drone, 40)
build(9, Zerg Drone, 40)
wait(500)
build(3, Zerg Creep Colony, 80)
wait_build(3, Zerg Creep Colony)
build(3, Zerg Sunken Colony, 80)
wait_build(3, Zerg Sunken Colony)
build(4, Zerg Creep Colony, 80)
wait_build(4, Zerg Creep Colony)
build(4, Zerg Sunken Colony, 80)
wait_build(4, Zerg Sunken Colony)
build(10, Zerg Drone, 40)
build(11, Zerg Drone, 40)
build(12, Zerg Drone, 40)
stop()
--ZMCx 0001--
upgrade(1, Zerg Missile Attacks, 70)
wait(900)
upgrade(1, Zerg Melee Attacks, 70)
stop()
--ZMCx 0002--
train(4, Zerg Zergling)
upgrade(2, Zerg Melee Attacks, 70)
wait(900)
upgrade(2, Zerg Missile Attacks, 70)
stop()
--ZMCx 0003--
train(1, Zerg Zergling)
train(1, Zerg Ultralisk)
upgrade(1, Chitinous Plating, 70)
wait(500)
upgrade(1, Anabolic Synthesis, 70)
upgrade(1, Zerg Carapace, 70)
stop()
--ZMCx 0004--
train(1, Zerg Hydralisk)
train(1, Zerg Defiler)
upgrade(3, Zerg Missile Attacks, 70)
upgrade(3, Zerg Melee Attacks, 70)
stop()
--moneyloop--
give_money()
wait(100)
goto(moneyloop)
--dronebuild--
build(1, Zerg Drone, 40)
wait_buildstart(1, Zerg Drone)
wait(600)
build(2, Zerg Drone, 40)
wait_buildstart(2, Zerg Drone)
wait(600)
build(3, Zerg Drone, 40)
wait_buildstart(3, Zerg Drone)
goto(dronebuild)
--oviebuild--
build(1, Zerg Overlord, 40)
wait_build(1, Zerg Overlord)
wait(600)
build(2, Zerg Overlord, 40)
wait_build(2, Zerg Overlord)
wait(600)
build(3, Zerg Overlord, 40)
wait_build(3, Zerg Overlord)
wait(600)
stop()
Yes, I've implemented 'build(1, Zerg Drone, 40)' scripts because quite frankly, that is the only way I can get the AI to build drones correctly.
The --dronebuild-- code works very usefully as well; the AI will construct a drone every now and then, or replace drones that were used to morph into structures.
Now, the crash occurs a few minutes after the AI builds their fifth and final hatchery (Save for hatchery's in expansions). I've studied the script along that closely, however my scripter-in-training eyes can't locate the error.
Other then the crash, the AI works flawlessly. It still spams Hydralisks, however not in the large quantity as it once did.
-
- Posts: 83
- Joined: Wed Sep 23, 2009 3:49 am [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Hmm well I've had a look and here are some things to consider checking,
-defensebuild_gg(2, Zerg Zergling) in --ZMCx 0000-- this command to my knowledge wasn't designed for repeated calls, could cause isses however is untested.
-evolution chamber upgrades look funny, 3 multiruns + upgrade calls in main, though I believe it shouldn't be an issue its hard to see what it will do just looking at the script.
-in block1 should consider replacing "expand(5, ZMCx 0000)" with "expand(99, ZMCx 0000)". To my knowledge only the 99 version of expand was really designed to be called multiple times. (The other ones can be called multiple times as well but they don't produce more expands, just maintain that number. Also their behaviour is questionable, particularly for numbers >3)
-defensebuild_gg(1, Zerg Zergling) in block1 same concern as first point.
-defensebuild_gg(2, Zerg Zergling) in --ZMCx 0000-- this command to my knowledge wasn't designed for repeated calls, could cause isses however is untested.
-evolution chamber upgrades look funny, 3 multiruns + upgrade calls in main, though I believe it shouldn't be an issue its hard to see what it will do just looking at the script.
-in block1 should consider replacing "expand(5, ZMCx 0000)" with "expand(99, ZMCx 0000)". To my knowledge only the 99 version of expand was really designed to be called multiple times. (The other ones can be called multiple times as well but they don't produce more expands, just maintain that number. Also their behaviour is questionable, particularly for numbers >3)
-defensebuild_gg(1, Zerg Zergling) in block1 same concern as first point.
-
- Posts: 83
- Joined: Wed Sep 23, 2009 3:49 am [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
I added in build statements for tech buildings so I could run the script in a normal game using the BWAILauncher.
I found that a crash resulted on the replay AIvsAI ZvZ Tenago.rep at 15:32 game time.
It generates an "Instruction referenced memory that could not be read" terminal error.
This crash was found to be generated by the multirun block --dronebuild--.
By disabling the repetition of this block by replacing "goto(dronebuild)" with "stop()" the script no longer crashed and the two zerg battle it out till about 27:37 game time at which point one of them wins.
These are the files used in this test,
[spoiler]Original script with tech buildings added:
(found to crash on AIvsAI ZvZ Tenago.rep)
[attachment=2691:originalWithTech.txt]
Modified script
(same as originalWithTech.txt except "goto(dronebuild)" replaced with "stop()" and no longer crashes)
[attachment=2692:modifiedWithTech.txt]
Replay used for test:
[attachment=2693:AIvsAI_ZvZ_Tenago.rep][/spoiler]
I found that a crash resulted on the replay AIvsAI ZvZ Tenago.rep at 15:32 game time.
It generates an "Instruction referenced memory that could not be read" terminal error.
This crash was found to be generated by the multirun block --dronebuild--.
By disabling the repetition of this block by replacing "goto(dronebuild)" with "stop()" the script no longer crashed and the two zerg battle it out till about 27:37 game time at which point one of them wins.
These are the files used in this test,
[spoiler]Original script with tech buildings added:
(found to crash on AIvsAI ZvZ Tenago.rep)
[attachment=2691:originalWithTech.txt]
Modified script
(same as originalWithTech.txt except "goto(dronebuild)" replaced with "stop()" and no longer crashes)
[attachment=2692:modifiedWithTech.txt]
Replay used for test:
[attachment=2693:AIvsAI_ZvZ_Tenago.rep][/spoiler]
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Who is online
Users browsing this forum: No registered users and 2 guests