GUI for a C++ bot

https://github.com/bwapi/bwapi
SimonC
Posts: 3
Joined: Mon Jul 04, 2011 9:47 pm

GUI for a C++ bot

Postby SimonC » Mon Jul 04, 2011 10:13 pm

Hi everyone,

We would like to create a graphical interface for our bot so that we can monitor stuff and keep track of what's going on (and maybe encourage other people to contribute!)

We're using native C++ code (not the bwapi-mono-bridge) in a Visual C++ project. If possible, we would like the GUI to be loaded alongside the AI module DLL, in the same process space. That would allow us to manipulate the data structures directly instead of network or messages based communication. I'm not particularly knowledgeable in the subject, but here are the alternatives I came up with:

- native C++: use Microsoft libraries MFC/ATL, or Qt

- managed code: WPF/Windows Forms using C++/CLI or C#

The advantage of using native C++ is that (I think), there would be no need to marshall/unmarshall stuff and no need to import/export functions from DLLs (if both the GUI and its dependencies take the form of static libraries). The disadvantage is, well, that I don't want to use MFC/ATL and I don't know Qt very well.

The advantage of managed code would be the possibility of using cool .Net components and drag/dropping them to create graphical interfaces quickly. However I'm not even sure how (or if) the native AIModule DLL could load the GUI's managed DLL.

So... if anyone already thought about this or created graphical interfaces for their bots, please share your insights! ;-)

Thanks,
Simon
snippyhollow
Posts: 3
Joined: Thu Jun 23, 2011 8:17 am

Postby snippyhollow » Wed Jul 06, 2011 7:37 am

I had a GUI for debugging purposes in C++/Qt (my bot is in C++). I removed it. If it's for outputing only, it's ok, if you also want to make inputs to your bot (change speed, switch strategy, etc.), it's a pain because you'll have to synchronize everything. (you GUI will obviously be at least in another thread).
SimonC
Posts: 3
Joined: Mon Jul 04, 2011 9:47 pm

Postby SimonC » Thu Jul 07, 2011 6:39 pm

Yeah I built a quick prototype in Qt and had some problems with threading, namely the fact that GUI updates have to take place on the GUI thread (via postEvent() or cross-thread signals). Also, to anyone interested in trying, the GUI thread can't be join()'ed in the DLL entry point DllMain() (no clue why), so it has to take place beforehand.

Indeed inputs to the bot would have to be synchronized, but as a first step they can be sent during a onFrame() callback to avoid synchronization.

By the way, it's surprisingly easy to use Qt since there's an IDE that lets you drag/drop controls around and an Add-in for Visual Studio is available. Struggling with managed code does seem like overkill.

Return to “BWAPI (wrappers in other languages / questions and announcements related to BWAPI itself)”

Who is online

Users browsing this forum: No registered users and 1 guest