Writing testAI code: general C++ question

Writing testAI code: general C++ question

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
alik83
Posts: 82
Joined: 08 Sep 2004, 15:32

Writing testAI code: general C++ question

Post by alik83 »

BTW Thanks Zaphod for answering my metal map question :)

Writing testAI code: general C++ question:
1)Suppose I add additional functions in file GlobalAI.cpp, what's the difference in the way to put them:

Code: Select all

 void CGlobalAI::ChatMsgPrintf(IGlobalAICallback *cb, const char *fmt, ...)
or just

Code: Select all

ChatMsgPrintf(IGlobalAICallback *cb, const char *fmt, ...)
What is CGlobalAI::function() construction used for?

2)Do I need to put all function prototypes in .h file?
If I don't, functions don't recognize other functions that are ahead of them in the source file...
Should I put them in .h file as "void CGlobalAI::function()" or just "void function()"

Thanks for some help
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

Are you sure you have the necessary C++ skills to build an AI? It's not exactly an easy job. Anyway, you don't seem to know how basic classes work, so maybe you should just get a C++ book and make a few small applications with C++ features in them so you can test it out...
I can explain this to you but I wonder if that solves it all...
Sorry but I'm just being honest...
alik83
Posts: 82
Joined: 08 Sep 2004, 15:32

Well..

Post by alik83 »

Well, you're right , I know C++ only on quite a basic level,
I analized the tasks and ideas I want to implement, and looked at your code and figured out I need some more studying on C++ and structure of big applications such as spring AI (Although I do understand the AI interface).
Actually I'm a little more interested in creating a helper for human player, still it's not such an easy task and I hope SJ will implement helper functionality and functions like AI reading human's markers...
One of the ideas of my AI is that it would allocate say 1/3 of resources for building more resourses; 1/3 for units/factories; 1/3 for defence, and a human player can change that ratio in game.
Than AI should find optimal methods of getting more res for ex. : after your res. income is X big start building mobile fusions, 3X big- start building fusions. (Just roughly illustrating my thought)
So it shouldn't depend so much on the scripts of what to build, and I do realise it would be not so easy to implement...
Well, thanks anyway, and if you know a good book on building big C++ apps on the internet a link would be welcome
User avatar
Maelstrom
Posts: 1950
Joined: 23 Jul 2005, 14:52

Post by Maelstrom »

Well Im also interested in learning C++. I wont be good enough to help any time soon, but im guessing you people must know at least ONE good tutorial out there. But I guess I could always go get a book...
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

Best thing you can do is get a C++ book from the local library, every library with a computer section has one or more... Watch out though that you're not getting one of those "Teach yourself C++ in 24 lessons" that actually just about MFC windows programming. You should have one that is really about the C++ programming language and teaches things like pointers, classes, types and functions. And after that, go to http://www.allegro.cc, download the allegro game library and make yourself a little game, in my opinion the most exciting way to learn C/C++ programming and just as important: debugging :)

alik83:

You could try and build a group AI, that way you shouldn't need markers since you can use the command interface
Well, thanks anyway, and if you know a good book on building big C++ apps on the internet a link would be welcome
There are a lot of expensive books about application design and techniques but imho, you just have to write big C++ apps to learn making them :)
User avatar
Michilus_nimbus
Posts: 634
Joined: 19 Nov 2004, 20:38

Post by Michilus_nimbus »

Well, Spring got me learning c++ to. These tutorialsare helping me quite a bit, but I'm still unable to read most of Springs code, and I can't modify it because Dev Cpp can't compile it (gives like 170 errors).
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Post by FLOZi »

cain
AI Developer
Posts: 124
Joined: 09 Aug 2005, 10:04

Post by cain »

for c++ learning I

suggest Thinking in C++

from Bruce Eckel

in two volumes:
vol 1 basics
vol 2 c++ standard library explanation

I like them because:
completness
indexed
free

I dislike them for being soo verbose.

But it's still the best manual (IMHO) I've come across.
I still look at it when in doubt, as the std lib could
be very confusing sometimes
(as I also program in Java wich, apart from a ton of
problems, as the BEST API I've come across so far,
complete and very very clear)


also you need: visual studio (not so free..) for using spring project
without pain and a modelling tool (PoseidonCE is free) to keep trak of
everithing.
Post Reply

Return to “Engine”