Need help for an AI in C++

Need help for an AI in C++

Here is where ideas can be collected for the skirmish AI in development

Moderators: hoijui, Moderators

Post Reply
leka
Posts: 9
Joined: 11 Oct 2012, 13:14

Need help for an AI in C++

Post by leka »

Hi all,

That is a project in progress I have to create an AI for KernelPanick in c++.
The first problem is that I have no knowledge of c++ and the second is that I have no idea where to start.

I tried to read the file "example" but they seem to be generated automatically whereas I really have to coding raw ... This is not really my strong point for once....

If one or more of you can give me advice ...
My goal is not specifically to successfully beat the machine but just to make my AI do some stuff ...

I really depressed and relies on your generosity;)

Thank you in advance.
User avatar
Licho
Zero-K Developer
Posts: 3803
Joined: 19 May 2006, 19:13

Re: Need help for an AI in C++

Post by Licho »

I would recommend doing AI in lua now.
Its simpler and the AI can be distributed more easily - in the game itself. (Zero-K lobby for example does not support C++ AI at all).

You can start by looking at existing AI - CAI from Zero-K

http://code.google.com/p/zero-k/source/ ... ai_CAI.lua
leka
Posts: 9
Joined: 11 Oct 2012, 13:14

Re: Need help for an AI in C++

Post by leka »

Thank you for your answer.

The problem for me is that I have to code in C++ and only on the game ByteBattle or KernelPanick ... so...

But I'll try to learn from this. Thank you again!

If someone else have a proposition ;)
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Need help for an AI in C++

Post by gajop »

You don't know C++ but you insist on writing it in C++? What's the catch here, is it for homework, competition or something like that?
If you also don't know C or any C-like language, I suggest you learn that first, or it's going to be a rough ride.

If you do know a bit of C at least, get the engine sources, and I suggest you just make a copy of the CppTestAI and base your work on that. Look at the other existing C/C++ AI for hints, and read the wiki.

Most importantly, if you need help, tell us what you tried so far, and exactly where you're having trouble.
leka
Posts: 9
Joined: 11 Oct 2012, 13:14

Re: Need help for an AI in C++

Post by leka »

Oh sorry, yeah it's for homework...

I don't know C++ at all ^^, i'll follow your advise, learn it first, then work on CppTestAI!

Thanks ;)
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Need help for an AI in C++

Post by knorke »

are you using this? http://www.irit.fr/ProgAndPlay/index_en.php
found it by googling bytebattle. Might matter in case it is a bit different to normal spring but Idk. Looks interessting though.
leka
Posts: 9
Joined: 11 Oct 2012, 13:14

Re: Need help for an AI in C++

Post by leka »

Oh great!
Thank you so much, there's a programmation guide!
http://www.irit.fr/ProgAndPlay/progAndP ... ion_en.php

thanks ;) i'll watch it :)
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Need help for an AI in C++

Post by hoijui »

i recommend quitting the C++ course, and take an other course.. prefferably... any language that is not C++.
we need to kill this language.. noobs learning it is not the right way to go!
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Need help for an AI in C++

Post by AF »

C++ isn't going away, even if no new C++ projects are started, and it does have its value, it explains a lot, the training of it could even spark Hoijui rivals ;D
leka
Posts: 9
Joined: 11 Oct 2012, 13:14

Re: Need help for an AI in C++

Post by leka »

The C++ can be cool, but it's complicated with all this pointers....
I can't take another language, this is why I need your help... :cry:
User avatar
SinbadEV
Posts: 6475
Joined: 02 May 2005, 03:56

Re: Need help for an AI in C++

Post by SinbadEV »

I'm confused as to how you would be required to program in a language you don't know for a course. Did you skip a prerequisite?

Do you know any programming languages?
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: Need help for an AI in C++

Post by PicassoCT »

c++ is quite a cool language. And.. well look around you.. everything were speed really matters.. what is it written in?

Right.

Now that this is solved.

http://springrts.com/wiki/AIWrapper:Cpp

And AF is your friend, he is the developer of Shard
leka
Posts: 9
Joined: 11 Oct 2012, 13:14

Re: Need help for an AI in C++

Post by leka »

Thank for the link, i'll watch it later.
In fact, i know java, but i have to code un c++, i change university this year, and here, they learned c++, not java =P
User avatar
SinbadEV
Posts: 6475
Joined: 02 May 2005, 03:56

Re: Need help for an AI in C++

Post by SinbadEV »

leka wrote:Thank for the link, i'll watch it later.
In fact, i know java, but i have to code un c++, i change university this year, and here, they learned c++, not java =P
LOL, My College switched the CS program from C++ to Java when I was two years in... one of the many many reasons I dropped out...

You should actually have a much better time of it going from Java to C++, there are going to be a lot of gotchas and weird glitches but the syntax, structure and logic is going to be mostly transferable... at least at the level you'll be using it... You might be better off finding a "Moving from Java to C++" type deal.

It's been years since I've done any "real" programming but this result that came up for me in google seems nominally useful:

http://www.horstmann.com/ccj2/ccjapp3.html
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Need help for an AI in C++

Post by gajop »

Honestly, I always saw it much easier to go from C++ to Java than the other way around, especially if you were ever taught OOP properly.

In fact, usually for C++ you need to have a good C understanding as an additional prerequisite and you end up dealing with a much more complicated including, declaring, compiling, linking, etc. process which C++ inherited to be backwards compatible with C, which doesn't really teach you anything about OOP.

@OP:
1) Learn C++
2) Write A* outside of Spring using C++
3) Compile Spring
4) Create the simplest AI that just spams units and sends them to the enemy
5) Improve your AI to fit the course requirements

PS: Were you assigned Kernel Panic AI as a project, or did you pick it yourself? Because I (am a TA starting with this semester) would never give my students a project using specific tools without giving the instructions how to setup those tools (if not obvious). If you were assigned that, you should at least ask your TAs to help you set it up.
leka
Posts: 9
Joined: 11 Oct 2012, 13:14

Re: Need help for an AI in C++

Post by leka »

Thanks all or you!

I "finished" learn base of c++, now i try gajop methods thanks :))
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Need help for an AI in C++

Post by hoijui »

it is juck norris!
leka
Posts: 9
Joined: 11 Oct 2012, 13:14

Re: Need help for an AI in C++

Post by leka »

I have a small question, I see there are two ways to attack an ennemy:

CMD.ATTACK
(->expect 1 parameters in return (unitid) or 3 parameters in return (mappos))
CMD.AREA_ATTACK
(->expect 4 parameters in return (mappos+radius))

If i understand, the first one only take the ID of the enemy or it's exact postition... The second take a map position and the radius...

The second seems much interesting, could you explein how to use the radius please :oops:
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Need help for an AI in C++

Post by gajop »

The area-attack one is what you use when holding the "A" key in game.
To use it, you should specify a map position with x, y and z coordinates, and radius, which specifies the area of the circle.
Wikipedia has a decent explanation of the radius, but you probably met with it when you were in elementary school: https://en.wikipedia.org/wiki/Radius

PS: I don't really think that command is of much use for an AI, you can easily implement it with a simple for loop, and you will almost always want to set targeting yourself.
PPS: Where are you from, i.e what is your native language?
leka
Posts: 9
Joined: 11 Oct 2012, 13:14

Re: Need help for an AI in C++

Post by leka »

Thanks for wiki link..

I'm french
Post Reply

Return to “AI”