Friday, July 23, 2010

BWAPI Beta 3.0 has been released

BWAPI Beta 3.0 has been released. This release fixes a number of bugs, improves the performance and functionality of the client-server architecture, adds several new functions, merges several Orders together, and more. Here is the full list of changes.

Saturday, July 17, 2010

Unit Command Test Cases Complete

After pulling an all-nighter, I'm happy to say that I've completed test cases for every unit command and they all pass on the server and client without a single failed assert. Perhaps the hardest test cases of the 43 unit commands were cancelTrain(slot), cancelMorph, and cancelConstruction, as different attributes of the unit had to be latency-compensated for different lengths of time, making them rather tricky puzzle pieces.

An off-by-one mistake in the latency compensation code would over-compensate or under-compensate the unit or player attributes (i.e. giving the player the appearance of having more or less resources than he actually has), leading to a failed assert that would only pop up for one or two frames at a time and then vanish in a game that's being run at 180 frames per second. Nonetheless, I have determined the shape of these puzzle pieces and now the latency compensation code is a perfect match for even these three unit commands, allowing for a seamless transition from latency-compensated values to actual values read from Starcraft memory.

As explained in my last post, my next main goal is to make test cases for events and callbacks, and more importantly start making the internal adjustments in GameImpl.cpp that will be necessary to make those new test cases run successfully on the client.

Monday, July 12, 2010

Test Framework Update

As planned, I've added test cases for the following unit commands:
  • siege
  • unsiege
  • cloak
  • decloak
  • burrow
  • unburrow
  • lift
  • land
  • load
  • unload
  • unloadAll
  • unloadAll(Position)
I've also added test cases for the following unit commands:
  • setRallyPosition
  • setRallyUnit
  • rightClick(Position)
  • patrol
  • holdPosition
  • stop
All test cases run without error as a DLL in Broodwar memory and as a separate client process. Now only the following unit commands are left to be tested:

  • attackMove
  • attackUnit
  • rightClick(Unit)
  • follow
  • repair
  • returnCargo
  • cancelConstruction
  • haltConstruction
  • cancelTrain
  • cancelTrain(Slot)
  • cancelAddon
Once I add test cases for these last 11 functions, I plan to add a test map that specifically deals with unit destruction and AI module call backs. For example, when a unit dies it should generate an onUnitDestroy callback. I also plan to re-write the way BWAPI generates events and callbacks to facilitate the process of making them behave the same way on the client as on the server. To do this, I'll make BWAPI just generate Events in the appropriate places, rather than both Events and perform the callbacks immediately. Then, right before AIModule::onFrame() is called I'll translate the events into callbacks and perform them. This will make the AIModule callback behavior virtually identical to the Client Events since they'll both be called at the same point of execution in GameImpl::update() for the most part. I'll also need to make some modifications to the way units get destroyed or become invisible so that their last frame of valid unit information is still available at the time of the callback or Event. For example, right now when an enemy unit dies, the client doesn't have access to the last frame of valid unit information because it is erased in GameImpl::onUnitDestroy(). I plan to make this function just set a flag in the UnitImpl class to indicate that the unit is dying, and only add UnitDestroy events. The UnitData struct for the recently destroyed unit would then be cleared after the AIModule::onFrame() and Client update functions have been called.

Tuesday, July 6, 2010

Testing Framework Runs Successfully on the Client!

Since my last blog post almost a week ago I've re-written the latency code so that it is all nicely written in a single template class which is then used both in the BWAPI dll (server) and on the client-side of the client-server connection. I've also recently fixed a few other bugs in the client.

As a result, I have now successfully ran the testing framework through all the test cases on all three major test maps (TerranTest, ProtossTest, and ZergTest) without error. This is a major milestone toward completing the client-server architecture.

My long-term goals now are to make the testing framework comprehensive as well as make sure all test cases continue to succeed both server-side as a normal AI module DLL and client-side. My next immediate goal will be to add test cases for siege/unsiege, cloak/decloak, burrow/unburrow, lift/land, and load/unload/unloadAll/unloadAllPosition.