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. However, the package provided to you 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.
Installation
- Open eclipse IDE. 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.
Interact with game engine
Place your own code in the method: example.Example.runTest(ProxyBot pb). This method will be called repeatedly. You can send command and receive game information through ProxyBot object. Be aware that this game is a real-time game, your algorithm must have quick response, if not you will make outdated decisions.
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. It will help you better understand this game.
Since this software are not well coded, remember to apply defensive programming techniques.
Obtain game status
Because everything is visible in this map, you can obtain the current map information though API. First use WargusStateImporter.getGameStateMap(…) to obtain a WargusMap object and further use WargusMap.get_map() to obtain the map array(char[][]).
Always use the following two methods to obtain player information:
- WargusStateImporter.getGameStatePlayer(…);
- WargusStateImporter.getGameStateOpponents(…);
Units
All construction and movable units are WargusUnit object.
Use the following methods 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()
…If the unit you want to build is a building, then use ProxyBot.build(int, int, int, boolean, int), Else use base.ProxyBot.train(int, int).
Upgrade your units
Explore the following method to discover the type of available researches: WargusStateImporter.researchTypeToString(int)
Upgrade your town-hall:
- proxyBot.upgrade(myHall.getUnitID(), 88); // upgrade to keep
- proxyBot.upgrade(myKeep.getUnitID(), 90); // upgrade to castle
Move and attack
Move to location, attacking any enemies encountered on the way:
- ProxyBot.attackMove(int unitID, int x, int y, boolean relative)
Order unit to attack a given unit:
- ProxyBot.attack(int unitIDOfAttacker, int attackThisUnitID)
Orders a unit to move to an x, y location and ignore enemies along the way:
- base.ProxyBot.move(int unitID, int x, int y, boolean relative)
Other useful API
- WargusUnit.getStatus(); // Return a status array, while array[0] is the currently performing action.
- WargusStateImporter.statusToString(wargusUnit.getStatus()[0]); // Translate the status code
- WargusStateImporter.unitCostGold(type); // Return the gold cost to build a unit of specific type
- WargusStateImporter.unitCostWood(type); // Return the wood cost to build a unit of specific type
Evaluation
Your submissions will be tested in two unknown maps:
- One where there is a path connecting one's own hall to the enemy's hall.(For example: maps/GoW-small1.pud.gz)
- Another one where there is no initial path because the base is surrounded by trees (For example: maps/GoW-lite2_tree.pud.gz)