Starcraft's probably best (BWAPI), but if you want open source, the other alternative is SpringRTS. The documentation isn't great, but it's often slightly better than "read the code", although that's oft-suggested, just like in any open source community.