Download presentation
Presentation is loading. Please wait.
Published byMarian Lynch Modified over 9 years ago
1
Presented by Yisheng Tang
2
Introduction Wargus is a Warcraft2 Mod that allows you to play Warcraft2 under GNU/Linux and other operating systems not supported by the original Warcraft2 engine The package is different from the official one: in addition to Wargus, it contains the java files which can be used to program a "player" to fight against the enemy AI. They were created by researchers using Wargus as testbed. Demo
3
Installation Choose File>New>Java Project. Choose "Create project from existing source", browse and choose directory \java\proxyBot_java. Edit file default.cfg to point to the directory in which you have Stratagus (i.e. if it's in C:\stratagus, write "C:\\stratagus\\", the two backslashes at the end are required). Test in different map: Change the code in method example.Example.loadMap() Run project and choose Example.java as the main class.
4
Interact with game engine Place your own code in the method: example.Example.runTest(ProxyBot) This method will be called repeatedly. FYI: In case your code will throw some exception which could halt the execution of this game, we place a try- catch statement in the while loop: ○ while (!m_static_stopSignal) { ○ try{…}catch{…} ○ } WargusStateImporter is a helper class which contains parameters and default values of this game. Since this software are not well coded, remember to apply defensive programming techniques.
5
Obtain game status Use this method to obtain a WargusMap object: WargusStateImporter.getGameStateMap(…); Further obtain the map array(char[][]): ○ base.WargusMap.get_map() Always use the following to method to obtain player and further obtain units information: WargusStateImporter.getGameStatePlayer(…); WargusStateImporter.getGameStateOpponents(…); DO NOT use base.ProxyBot.getMyUnits(), since the ArrayList returned is not thread safe.
6
Units All construction and movable units are WargusUnit object. Use the following method to retrieve units in this game: base.WargusPlayer.getUnits() base.WargusPlayer.getUnitsByType(String) base.WargusPlayer.getFlyingUnits() base.WargusPlayer.getLandUnits() base.WargusPlayer.getWaterUnits() base.WargusPlayer.getMobileUnits() base.WargusPlayer.getBuildings() base.WargusPlayer.getBombardingUnits() …
7
New Units If the unit you want to build is a building, then use: base.ProxyBot.build(int, int, int, boolean, int) Else use: base.ProxyBot.train(int, int)
8
Research Explore the following method to discover the type of available researches: base.WargusStateImporter.researchTypeToString(int) Exception: If you want to upgrade your town-hall, you actually use build proxyBot.upgrade(myHall.getUnitID(), 88); // upgrade to keep proxyBot.upgrade(myKeep.getUnitID(), 90); // upgrade to castle The size of town-hall, keep, castle are all 4.
9
Move and attack Move to location, attacking any enemies encountered on the way ProxyBot.attackMove(int unitID, int x, int y, boolean relative) Orders unit to attack given other unit ProxyBot.attack(int unitIDOfAttacker, int attackThisUnitID) Orders a unit to move to an x, y location. ignore enemies along the way base.ProxyBot.move(int unitID, int x, int y, boolean relative)
10
Other useful API wargusUnit.getStatus() Return a status array array[0] is the currently performing action WargusStateImporter.statusToString(wargu sUnit.getStatus()[0]) Translate the status code WargusStateImporter.unitCostGold(type) Return the cost of gold WargusStateImporter.unitCostWood(type) Return the cost of wood
11
Useful Solutions Keep building footmans Never stop collect sources Upgrade your technology in a proper time
12
Speed Up Running Wargus This is the command in Java to make Wargus run fastest as possible: proxyBot.setSpeed(-1);
13
Thank you! Enjoy this game!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.