• Welcome to Valhalla Legends Archive.
 

[C++] Quality bot design / 'practices'

Started by Okee, July 13, 2005, 10:50 AM

Previous topic - Next topic

Okee

Hey guys, I saw the thread about visual basic related practices and design, and was wondering what some good things to keep in mind while making a C++ bot would be?

What's the main thing most C++ bots should be centered around - a class containing all account settings, etc, or some other element?

What's a good way to keep your bots organized and simple?

Just anything that people might find useful while writting C++ bots, or applications.

MyndFyre

I think that most people would tell you that, since C++ is object-oriented, the best thing to go for is modularity.

My bot (if you want to call it that, in C#, although C++ has just as much capability to do the same thing, if not more) is centered around an abstract design that involves plugins and system-level contracts.  Essentially, the main program has any number of plugin DLLs in its folder.  It knows enough about the plugin to load it.  Then it enumerates a registry path (I use GUIDs to identify a plugin type in both the DLL and the registry) and determines which plugins to load objects for.  This lets me make a generic, base Settings class that essentially encapsulates a registry key.  Classes can extend it and provide more detailed properties.

Part of the plugin contract is that each DLL provides an object factory class (that is determined by metadata, although you can require a DLL provide a global, exported C function to return one).  I defined an interface that tells me what the object factory class can do, and that way I don't need to worry about late binding -- something similar could work for you.

But it shouldn't be the "settings" that your bot is centered around, per se -- it should be the extensibility contracts (plugin system).  If you center it around your settings, you won't be able to adapt it as easily to other kinds of systems later.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Sorc.Polgara

#2
Quote from: MyndFyre on July 13, 2005, 11:32 AM
I think that most people would tell you that, since C++ is object-oriented, the best thing to go for is modularity.

My bot (if you want to call it that, in C#, although C++ has just as much capability to do the same thing, if not more) is centered around an abstract design that involves plugins and system-level contracts.  Essentially, the main program has any number of plugin DLLs in its folder.  It knows enough about the plugin to load it.  Then it enumerates a registry path (I use GUIDs to identify a plugin type in both the DLL and the registry) and determines which plugins to load objects for.  This lets me make a generic, base Settings class that essentially encapsulates a registry key.  Classes can extend it and provide more detailed properties.

Part of the plugin contract is that each DLL provides an object factory class (that is determined by metadata, although you can require a DLL provide a global, exported C function to return one).  I defined an interface that tells me what the object factory class can do, and that way I don't need to worry about late binding -- something similar could work for you.

But it shouldn't be the "settings" that your bot is centered around, per se -- it should be the extensibility contracts (plugin system).  If you center it around your settings, you won't be able to adapt it as easily to other kinds of systems later.

Do you know of any good tutorials or examples for making and using a DLL in C++?  I've tried making my own but it doesn't work >_< probably cuz I'm doing something wrong T_T.

I tried using BnetAuth.dll just to see and I couldn't figure out how to even use it because my code must of been wrong or something... I've searched google but I haven't found anything really useful.

Any links or something that might provide a good resource on making and using DLLs?

I really want to make my bot so I can make it more portable.