Transcript Slide

Presented by Yisheng Tang
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

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.
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 trycatch 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.

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.
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()
…
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)
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.
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)
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
Useful Solutions
Keep building footmans
 Never stop collect sources
 Upgrade your technology in a proper
time

Speed Up Running Wargus
This is the command in Java to make
Wargus run fastest as possible:

proxyBot.setSpeed(-1);

Thank you!
Enjoy this game!