1 / 14

Project 3 CSE 397/497 AI and Computer Games

Project 3 CSE 397/497 AI and Computer Games. What is Wargus?. An open source clone of Warcraft 2 Supports the LUA scripting language. Project 3 Objectives. Write a LUA script (or modify custom_script) to control an army in Wargus All three rounds will take place on the “default” map

umeko
Download Presentation

Project 3 CSE 397/497 AI and Computer Games

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Project 3 CSE 397/497 AI and Computer Games

  2. What is Wargus? • An open source clone of Warcraft 2 • Supports the LUA scripting language

  3. Project 3 Objectives • Write a LUA script (or modify custom_script) to control an army in Wargus • All three rounds will take place on the “default” map • There will be three rounds: • Defeat an early rush opponent (soldiers_rush) • Defeat a delayed rush opponent (knights_rush) • Defeat a well-balanced attack (land_attack)

  4. Getting Started • Once you’ve downloaded Wargus, navigate to data.wargus\scripts\ai • When you’re ready to write your own bot, custom_script.lua offers a good starting point • For now, we’re going to look at soldiers_rush.lua…

  5. Getting Started • AI in Stratagus is script based. Each AI player keeps executing scripts. There are two kinds of scripts : • The main script. It starts buildings, upgrades, ... • The action/reaction scripts. They are started by the AI engine, under certain condition. • Scripts can arrange and control units using forces : A script can ask for some type of unit in a force (using AiForce), and then wait for them to be ready (using AiWaitForce).

  6. More on Forces • The force 0 is a special case : it holds all the unassigned units, and is used to fill other forces. ( when needed, units are transfered from force 0 to others ). • Attacker units in force 0 won't be used for attacks • Forces from 1 to 3 are also special : They are used as the attack reserve. Attack forces will only be created using units available in those forces.

  7. soldiers_rush.lua local soldiers_funcs = { function() return AiSleep(AiGetSleepCycles()) end, function() return AiNeed(AiCityCenter()) end, function() return AiSet(AiWorker(), 1) end, function() return AiWait(AiCityCenter()) end, function() return AiWait(AiWorker()) end, -- start hangs if nothing available function() return AiSet(AiWorker(), 10) end, function() return AiNeed(AiBarracks()) end, function() return AiForce(0, {AiSoldier(), 2}) end, function() return AiForce(1, {AiSoldier(), 10}) end, function() return AiWaitForce(1) end, function() return AiAttackWithForce(1) end, function() return AiSet(AiWorker(), 15) end, function() return AiNeed(AiBlacksmith()) end, function() return AiWait(AiBlacksmith()) end, function() return AiNeed(AiBarracks()) end, function() return AiResearch(AiUpgradeWeapon1()) end, function() return AiResearch(AiUpgradeArmor1()) end, function() return AiResearch(AiUpgradeWeapon2()) end, function() return AiResearch(AiUpgradeArmor2()) end, function() return AiSleep(500) end, function() return AiForce(0, {AiSoldier(), 4}) end, function() return AiForce(1, {AiSoldier(), 10}) end, function() return AiWaitForce(1) end, function() return AiAttackWithForce(1) end, function() return AiSoldiersRushEndloop() end, }

  8. soldiers_rush in depth function() return AiNeed(AiCityCenter()) end, --we need a city center function() return AiSet(AiWorker(), 1) end, --we need 1 worker for this function() return AiWait(AiCityCenter()) end, --wait until we have a center before continuing function() return AiWait(AiWorker()) end, -- hangs if nothing available function() return AiSet(AiWorker(), 10) end, --now we need 10 workers function() return AiNeed(AiBarracks()) end, --need a barracks, too • AiNeed() always refers to one unit • AiSet() can specify the number needed • Remember, AiSset(AiWorker(), 10) will not necessarily build 10 Workers, it will build as many as it needs until we have 10

  9. soldiers_rush in depth function() return AiForce(0, {AiSoldier(), 2}) end, --we need 2 soldiers for force 0 function() return AiForce(1, {AiSoldier(), 10}) end, --we need 10 soldiers for force 1 function() return AiWaitForce(1) end, --wait until force 1 is ready, then… function() return AiAttackWithForce(1) end, --attack! • The AI automatically knows where to attack • Units in defense forces (0 is a defense force, by default) will automatically respond to buildings being attacked

  10. soldiers_rush in depth function() return AiSet(AiWorker(), 15) end, --make sure we have 15 workers now function() return AiNeed(AiBlacksmith()) end, --do we have a blacksmith? function() return AiWait(AiBlacksmith()) end, --wait until we have one function() return AiNeed(AiBarracks()) end, --make sure we still have a barracks function() return AiResearch(AiUpgradeWeapon1()) end, --upgrade our weapons function() return AiResearch(AiUpgradeArmor1()) end, --and armor function() return AiResearch(AiUpgradeWeapon2()) end, function() return AiResearch(AiUpgradeArmor2()) end, function() return AiSleep(500) end, --wait, since this is going to take a while • Workers will automatically harvest resources and build farms, however you can build extra farms, if you want

  11. soldiers_rush in depth function() return AiForce(0, {AiSoldier(), 4}) end, --build up some more defenses function() return AiForce(1, {AiSoldier(), 10}) end, --and another force to attack with function() return AiWaitForce(1) end, --wait for new attack force function() return AiAttackWithForce(1) end, --then attack function() return AiSoldiersRushEndloop() end, --call end loop

  12. Some Final Notes • The scripting documentation is not included with Wargus, because it is slightly out of date • It will be available on the website, but not all commands will work as written

  13. Some Final Notes • Project 3 is due Friday, October 15 • Script must be emailed to me, jemj, by midnight the night before • Email presentations to Professor Munoz, hem4

  14. Helpful links • Wargus Home Page • http://wargus.sourceforge.net/ • Warcraft 2 Gameplay and Strategy FAQ’s • http://www.gamefaqs.com/computer/doswin/game/199259.html • General Purpose LUA tutorial • http://lua-users.org/wiki/TutorialDirectory • #stratagus on irc.freenode.net

More Related