project 3 cse 397/497 ai and computer games

14
Project 3 Project 3 CSE 397/497 CSE 397/497 AI and Computer Games AI and Computer Games

Upload: umeko

Post on 13-Feb-2016

44 views

Category:

Documents


0 download

DESCRIPTION

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 - PowerPoint PPT Presentation

TRANSCRIPT

  • Project 3CSE 397/497 AI and Computer Games

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

  • Project 3 ObjectivesWrite a LUA script (or modify custom_script) to control an army in WargusAll three rounds will take place on the default mapThere 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)

  • Getting StartedOnce youve downloaded Wargus, navigate to data.wargus\scripts\aiWhen youre ready to write your own bot, custom_script.lua offers a good starting pointFor now, were going to look at soldiers_rush.lua

  • Getting StartedAI 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).

  • More on ForcesThe 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 attacksForces 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.

  • soldiers_rush.lualocal 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,}

  • soldiers_rush in depthfunction() return AiNeed(AiCityCenter()) end, --we need a city centerfunction() return AiSet(AiWorker(), 1) end, --we need 1 worker for thisfunction() return AiWait(AiCityCenter()) end, --wait until we have a center before continuingfunction() return AiWait(AiWorker()) end, -- hangs if nothing availablefunction() return AiSet(AiWorker(), 10) end, --now we need 10 workersfunction() return AiNeed(AiBarracks()) end, --need a barracks, too

    AiNeed() always refers to one unitAiSet() can specify the number neededRemember, AiSset(AiWorker(), 10) will not necessarily build 10 Workers, it will build as many as it needs until we have 10

  • soldiers_rush in depthfunction() return AiForce(0, {AiSoldier(), 2}) end, --we need 2 soldiers for force 0function() return AiForce(1, {AiSoldier(), 10}) end, --we need 10 soldiers for force 1function() return AiWaitForce(1) end, --wait until force 1 is ready, thenfunction() return AiAttackWithForce(1) end, --attack!

    The AI automatically knows where to attackUnits in defense forces (0 is a defense force, by default) will automatically respond to buildings being attacked

  • soldiers_rush in depthfunction() return AiSet(AiWorker(), 15) end, --make sure we have 15 workers nowfunction() return AiNeed(AiBlacksmith()) end, --do we have a blacksmith?function() return AiWait(AiBlacksmith()) end, --wait until we have onefunction() return AiNeed(AiBarracks()) end, --make sure we still have a barracksfunction() return AiResearch(AiUpgradeWeapon1()) end, --upgrade our weaponsfunction() return AiResearch(AiUpgradeArmor1()) end, --and armorfunction() 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

  • soldiers_rush in depthfunction() return AiForce(0, {AiSoldier(), 4}) end, --build up some more defensesfunction() return AiForce(1, {AiSoldier(), 10}) end, --and another force to attack withfunction() return AiWaitForce(1) end, --wait for new attack forcefunction() return AiAttackWithForce(1) end, --then attackfunction() return AiSoldiersRushEndloop() end, --call end loop

  • Some Final NotesThe scripting documentation is not included with Wargus, because it is slightly out of dateIt will be available on the website, but not all commands will work as written

  • Some Final NotesProject 3 is due Friday, October 15Script must be emailed to me, jemj, by midnight the night beforeEmail presentations to Professor Munoz, hem4

  • Helpful linksWargus Home Pagehttp://wargus.sourceforge.net/Warcraft 2 Gameplay and Strategy FAQshttp://www.gamefaqs.com/computer/doswin/game/199259.htmlGeneral Purpose LUA tutorialhttp://lua-users.org/wiki/TutorialDirectory#stratagus on irc.freenode.net