Valhalla Legends Forums Archive | Battle.net Bot Development | How difficult would it be to make a bot that does this...

AuthorMessageTime
warz
I was just playing some chess online, thinking about a program that shows you the best move to make while playing. Then, I started wondering about SC, because a few people were wanting to play it. Then, I was thinking, well I really don't want to play, but I like SC, so you know, why not? Well, after this long process of thinking I thought, what if there was a bot that joined games and attempted to play? It'd take into account all the variable data being thrown its way, and calculate the best method of winning. Then, it'd try to play.

This would be a lot of work. Lots.. of.. work. But, how difficult would it really be? Is it even possible? Does the incomming data in BW give you enough information to actually know exactly whats going on in the game? I assume it does, because the client knows what's going on. I've seen Adron's programs that let you know exactly how much minerals etc, another play has, and where they are, etc. This is really one of the only tasks that truly interests me as far as SC and bnet goes.

I was just wondering what people thought about this program? Has anyone done it? I'm sure people have bots that join actual games.
April 21, 2006, 5:29 AM
l2k-Shadow
Well.. you'd have to take apart the whole starcraft protocol, and yeah you do get all the data the other player has because really all sc does is hide the map but the actual moves of the other player are transmitted. you could take apart the information being received and like hardcode stuff where.. ok if the other player is making dragoons, i'll go mass cracklings. etc.. i think the hardest part would be to actually take apart the protocol to know what every single thing does.. and if you have knowledge of assembly you could probably just disassemble sc and figure it out but it would take a lot of time. after that would be done then you'd have to figure out how to construct packets and make the characters move, make them micro, etc... it would be extremely time consuming.. and you'd probably figure out you have so many bugs in it that you'd just give up alltogether because people would find exploits on how to get around it all the time... it would be like 5-6 months or more project at least to pull off a good release... however if you actually accomplished it.. it would be pretty damn awesome i have to say.. i'm actually really interested in this project if you're willing to give it a shot, pm me or something.. i can't do much as far as assembly goes, but i can help research the protocol on my spare boredom time. gl :)

EDIT: also you could probably figure out what the Computer player does once in game.. but it doesn't really matter, they do the same thing every time, i'm assuming for your program you want it to have AI.. so yeah.
April 21, 2006, 6:01 AM
warz
Well, it's no doubt that I will attempt this. Might as well put effort into something I'm interested in. It's either this or Guild Wars, seeing as how Guild Wars is free.
April 21, 2006, 7:09 AM
Physaro
Hmm that would be very hard. Because you would need to reverse all the Field of View and Pathfinding algorithms. I don't know if there is s.th. similar in SC:BW but in WC3 there is a seed set in the beginning from which the players calculate the dmg etc so if that also true in SC:BW and you don't know the proper algorithm your bot might not be acceppted by the other player or at least one could see it in the replay. So there would be many challenges.

But of course a good bot would nearly be unbeatable, not so much because he can think of the best strategie, but because his mirco which is very important in SC.

If you really get this, go to Korea and sell it there. SC:BW is so popular there and I bet you could earn some thousand dollars for such a "training bot".
April 21, 2006, 8:44 AM
Yegg
warz, this is obviously going to be an insanely difficult project to develope, but success would be amazing. Like shadow said, you'll probably need some sort of Artificial Intelligence which in this case I'm guessing won't be too much trouble compared to breaking down Starcraft's game protocol. I've never actually thought about such a project because I lacked the information of knowing that such information was included in the packets that you could know where other players were moving, let alone the fact that I've never personally packet logged anything on Starcraft. You mentioning this task gave me this interesting mental image of an automated player versing multiple players and knowing exactly what to do and when, and sooner or later the rest of the players yelling out things such as "map hacker!".

So anyways, I wish you the best of luck on this. I would love to see something like this exist with relatively well success some day.
April 21, 2006, 6:59 PM
warz
[quote author=Yegg link=topic=14815.msg150994#msg150994 date=1145645951]
warz, this is obviously going to be an insanely difficult project to develope, but success would be amazing. Like shadow said, you'll probably need some sort of Artificial Intelligence which in this case I'm guessing won't be too much trouble compared to breaking down Starcraft's game protocol. I've never actually thought about such a project because I lacked the information of knowing that such information was included in the packets that you could know where other players were moving, let alone the fact that I've never personally packet logged anything on Starcraft. You mentioning this task gave me this interesting mental image of an automated player versing multiple players and knowing exactly what to do and when, and sooner or later the rest of the players yelling out things such as "map hacker!".

So anyways, I wish you the best of luck on this. I would love to see something like this exist with relatively well success some day.
[/quote]

Just have to take it step by step. Eventually, keeping at it, a final product can be made. I'm confident enough in my C++ skills that the only problems will be what Starcraft has to offer. Really, it's just a matter of packets and relative meaning, plus anything that needs to be done as far as disassembling starcraft, and such.

Who knows, we'll see. I'll start on it this afternoon.
April 21, 2006, 7:52 PM
l2k-Shadow
[quote author=warz link=topic=14815.msg150972#msg150972 date=1145603383]
Well, it's no doubt that I will attempt this. Might as well put effort into something I'm interested in. It's either this or Guild Wars, seeing as how Guild Wars is free.
[/quote]

lol GW has been cutting into my programming time but getting the pms when we take halls with blood spike is pretty cool... Black Crescent (Wasted Ftw's team) represent :D

good luck on the project.
April 22, 2006, 12:47 AM
warz
I didn't realize how in-depth the UDP protocol was. Intense, this is what I like. This will take some time. ;-)
April 22, 2006, 6:31 AM
MesiaH
Interesting idea, warz. This is actually one of the better idea's I've seen in a while. This is what I check in here from time to time for. Something large, useful to an entire community, a pure show of complete mastery of the starcraft game protocol. I would be all for donating whatever I can to a project like this, But only if their are a fair amount of people involved. There are going to have to be at least a handful.. If your serious about undergoing a project of this stature, see if you can't gather a few handy people. PM me if you get going with this. gg.
April 22, 2006, 4:24 PM
Myndfyr
If I may suggest, get it going far enough for you to get the bot in there and doing nothing (kind of like what happens when a zerg spawns at 3 o'clock and 9 o'clock on BGH).
April 22, 2006, 6:55 PM
Lord_Vegito
I've dreamed about making a bot like this for years, I just don't have the time or energy to do it. I wish you the best of luck on this man.
April 22, 2006, 11:26 PM
warz
A possible reason this project is so often strayed away from is because of functions like this rather trivial one...

large function

Not to mention this isn't even the full, correct function. I believe a much, much larger function in storm calls this battle.snp function. The storm one is several thousand lines of code. :-p
:o
April 24, 2006, 9:21 PM
UserLoser
Should be looking more in Storm.dll rather than Battle.snp
April 25, 2006, 5:18 AM
warz
Yeah. I've found a function in storm that looks like it's checking to see if there's any more packets to be assembled, or something.. note, this is the function that calls the function that calls sendto :-p

[code]
15022b90 51              push    ecx
15022b91 a108a90415 mov eax,[Storm!Ordinal459+0x14328 (1504a908)] ds:0023:1504a908=0265009c
15022b96 85c0            test    eax,eax
15022b98 53              push    ebx
15022b99 55              push    ebp
15022b9a 56              push    esi
15022b9b 57              push    edi
15022b9c 89542410        mov    [esp+0x10],edx
15022ba0 8bf9            mov    edi,ecx
15022ba2 750a            jnz    Storm!Ordinal106+0x46e (15022bae)
15022ba4 5f              pop    edi
15022ba5 5e              pop    esi
15022ba6 5d              pop    ebp
15022ba7 33c0            xor    eax,eax
15022ba9 5b              pop    ebx
15022baa 59              pop    ecx
15022bab c20800          ret    0x8
15022bae ff1580810315    call dword ptr [Storm!Ordinal459+0x1ba0 (15038180)]
15022bb4 8b3510a90415    mov    esi,[Storm!Ordinal459+0x14330 (1504a910)]
15022bba 8bc8            mov    ecx,eax
15022bbc 2bce            sub    ecx,esi
15022bbe 81f9ffffff7f    cmp    ecx,0x7fffffff
15022bc4 7305            jnb    Storm!Ordinal106+0x48b (15022bcb)
15022bc6 a310a90415      mov    [Storm!Ordinal459+0x14330 (1504a910)],eax
15022bcb 8b6c241c        mov    ebp,[esp+0x1c]
15022bcf 8b0d14a90415    mov    ecx,[Storm!Ordinal459+0x14334 (1504a914)]
15022bd5 8d4540          lea    eax,[ebp+0x40]
15022bd8 0fafc7          imul    eax,edi
15022bdb 69c0e8030000    imul    eax,eax,0x3e8
15022be1 33d2            xor    edx,edx
15022be3 f7b128020000    div    dword ptr [ecx+0x228]
15022be9 8b1510a90415    mov    edx,[Storm!Ordinal459+0x14330 (1504a910)]
15022bef 03d0            add    edx,eax
15022bf1 a11ca90415      mov    eax,[Storm!Ordinal459+0x1433c (1504a91c)]
15022bf6 85c0            test    eax,eax
15022bf8 891510a90415    mov    [Storm!Ordinal459+0x14330 (1504a910)],edx
15022bfe 7471            jz      Storm!Ordinal106+0x531 (15022c71)
15022c00 83ff10          cmp    edi,0x10
15022c03 779f            ja      Storm!Ordinal106+0x464 (15022ba4)
15022c05 81fd001f0000    cmp    ebp,0x1f00
15022c0b 7797            ja      Storm!Ordinal106+0x464 (15022ba4)
15022c0d 33c9            xor    ecx,ecx
15022c0f 85ff            test    edi,edi
15022c11 7616            jbe    Storm!Ordinal106+0x4e9 (15022c29)
15022c13 33d2            xor    edx,edx
15022c15 8d740240        lea    esi,[edx+eax+0x40]
15022c19 893488          mov    [eax+ecx*4],esi
15022c1c a11ca90415      mov    eax,[Storm!Ordinal459+0x1433c (1504a91c)]
15022c21 41              inc    ecx
...
[/code]

that's not the whole thing, but once it reaches the bottom it ret's back to the beginning and does it all over again until the data at Storm!Ordinal106[...] is 0 it looks like. Once that's 0, the function breaks, pops the operands off the stack and returns

Edit: .. which is very rare it appears. i set a break point there and played several games without it breaking.

Anyone know if this is even the correct function?
April 25, 2006, 8:43 AM
Physaro
Hi,
it's great that you still want to accomplish this. But why do you want to look into the Storm.dll? Network and MPQ files are already very good documencted.

On another note, I am currently doing (among other things) a replay parser. The parser itself is finnished, but it doesn't show much information because in replays there is not documented how much dmg one unit deals to another. And also it does not say when a unit gets killed. This gets all calculated during runtime with a SeedValue that is saved in the replay.
I think that would be a great start point to reverse engineer the algorithm that calculates the dmg from the seed and maybe some other data (the time the game is running??) and of course you would help me alot :D

Wfg
Physaro
April 25, 2006, 12:44 PM
Ringo
[quote author=warz link=topic=14815.msg151248#msg151248 date=1145954588]
Anyone know if this is even the correct function?
[/quote]
What function are you trying to find?
Im guessing you mean the function to check for missing packets, or function to buffer sent packets?
If so, what packet command? because all 3 work differntly, both ways.
If i was you, i would worry more about disassembling algorithm's for "everything", becuase almost everything has a algorithm in sc, thats how every client keeps in perfect sequance.
for example if i selected a marine, sc would send that command to all other players, then if i were to attack move that marine across the map, that would also get sent, but thats pritty much where it ends.
Everyones SC will know exacly what path that marine will take and exacly where it will come into contact with another unit, and exacly what unit will get the first hit, and exacly when a unit will "miss hit" due to differnt levels of terrains, and exacly when that unit will heal +1 life, and exacly when and what unit will die 1st.
Thats the same for peons gathering minerals, everyone will know exacly what X/Y a peon is every millisecond, and what mineral it will goto if the one it was going to is inuse, and exacly how long it will take it to get there, working out the total minerals of a player all the time.
Another example would be setting a rally point for a gateway at somones eles base, then build 5 zealots, 5 commands would be sent in the next beat. But them zealots could finish building, walk to that players base, kill all his units and buildings, and finaly eliminate them, with no more than the packets to say i set rally point and built 5 zealots being sent.
The closest iv been to being able to play agame of SC on-bot, is to build units and attack other players with them, but thats about it.
Things like path finding and stuff like that, have always been a no-go area, due to knowing nothing about disassembly at all, nore time or interest to work them out (other than defalt unit build times). :(

Would it not be easyer to just grab this infomation from SC its self and make a macro?

Physaro: You can get the defalt unit dammages and stuff, from campain editor, and use them settings, unless its UMS, then use the maps settings in teh scenario.chk in the Map file mpq.
April 25, 2006, 6:40 PM
warz
i'll get there everntually. you see, after reverse engineering certain functions ill know what theyre doing and then what to look for based on what that function does. i'll know why it was called, what it calls, etc. i understand this seems like a never ending project, and it might be hard to grasp that concept, but that's what i'm looking for.

why create another bot that just does the exact same thing as any other bot? besides, i like projects that are kind of like 'work at your own pace'. reverse a function here, reverse a function there.. take a break, come back do some more. maybe the actual finished product isn't my real goal. maybe i'm more interested in the reverse engineering aspect of this, which is why i actually enjoy staring at a debugger all day. i don't know, but it's not a big deal. progress will be made, and that's all.
April 25, 2006, 7:53 PM
Ringo
[quote author=warz link=topic=14815.msg151273#msg151273 date=1145994832]
i'll get there everntually. you see, after reverse engineering certain functions ill know what theyre doing and then what to look for based on what that function does. i'll know why it was called, what it calls, etc. i understand this seems like a never ending project, and it might be hard to grasp that concept, but that's what i'm looking for.
[/quote]
But i dont think you have said what function it is your looking for :p

[quote author=warz link=topic=14815.msg151273#msg151273 date=1145994832]
why create another bot that just does the exact same thing as any other bot? besides, i like projects that are kind of like 'work at your own pace'. reverse a function here, reverse a function there.. take a break, come back do some more. maybe the actual finished product isn't my real goal. maybe i'm more interested in the reverse engineering aspect of this, which is why i actually enjoy staring at a debugger all day. i don't know, but it's not a big deal. progress will be made, and that's all.
[/quote]
Hm, i think you missed my points, i was just pointing out "How difficult it would be to make a bot that does this...", not trying to talk you out of it in anyway :P

But in my opinion, I think your going about it a painfull way to start out :P
Anyway i got some logs if there any use, there logs of traffic from ALL directions between all players, like A<>B/A<>C/A<>D/B<>C/B<>D/C<>D (game room only)
Full Log
Command 0 Log
Command 1 Log
Command 2 Log

Best of luck anyway.
April 25, 2006, 9:56 PM
warz
[quote author=Ringo link=topic=14815.msg151278#msg151278 date=1146002183]
[quote author=warz link=topic=14815.msg151273#msg151273 date=1145994832]
i'll get there everntually. you see, after reverse engineering certain functions ill know what theyre doing and then what to look for based on what that function does. i'll know why it was called, what it calls, etc. i understand this seems like a never ending project, and it might be hard to grasp that concept, but that's what i'm looking for.
[/quote]
But i dont think you have said what function it is your looking for :p

[quote author=warz link=topic=14815.msg151273#msg151273 date=1145994832]
why create another bot that just does the exact same thing as any other bot? besides, i like projects that are kind of like 'work at your own pace'. reverse a function here, reverse a function there.. take a break, come back do some more. maybe the actual finished product isn't my real goal. maybe i'm more interested in the reverse engineering aspect of this, which is why i actually enjoy staring at a debugger all day. i don't know, but it's not a big deal. progress will be made, and that's all.
[/quote]
Hm, i think you missed my points, i was just pointing out "How difficult it would be to make a bot that does this...", not trying to talk you out of it in anyway :P

But in my opinion, I think your going about it a painfull way to start out :P
Anyway i got some logs if there any use, there logs of traffic from ALL directions between all players, like A<>B/A<>C/A<>D/B<>C/B<>D/C<>D (game room only)
Full Log
Command 0 Log
Command 1 Log
Command 2 Log

Best of luck anyway.
[/quote]

Well think about starcraft from a C programming point of view. How do you suppose it handles sending its packets? Do you think it's similar to methods you'd see in most bnet bots - a ping pong style method? Receive one packet from bnet, pong back with the correct reply? A simple function for each packet, then sent directly to where it's going?

No, apparantly starcraft formulates its packets and then adds them to a linked list if its a data packet, and then loops. Theres a battle.snp function that returns the next packet to be sent and then removes it from the linked list. That's what I meant when asking if thats what that function looks like it was doing.

Anyways, the method I'm going about this with, yes, is difficult in the beginning. I feel though that taking this route will lead to a better understand of how starcraft manages its UDP data and will help to create a much better emulation of the client. It's easy enough to document all the class 0, 1 and 2 packets. I've already got tons of them documented to my best ability. I could most likely get a client into the game room as of right now by simply using my logs.

What about all those unknown values? What about packets that nobody knows what they're there for, but you could just simply reply to and probably get a client into the game room? What if it IS important.

Thank you for those logs, they'll be helpful I'm sure
April 26, 2006, 12:41 AM
Myndfyr
You know what you should do?  Get BWChart's source code (which is available) and it should have all the info you need for the algorithms Brood War uses for pathing.

You'd better be fucking thankful.  I was inspired to remember the program, and it seriously took me a half hour to find the damn site.
April 26, 2006, 1:30 AM
Myndfyr
Actually, now I'm looking at BWChart, and it doesn't emulate all of those things.  Just the location-clicks and things like that.  Sorry man.
April 26, 2006, 7:37 AM
warz
:-P
April 26, 2006, 10:20 AM
bethra
omg mindfire's sig is pro... liberal bashing ftw.
April 28, 2006, 12:26 AM

Search