Page 1 of 1

Kurve (dt: curve) - I'd like to make an AI

PostPosted: 22 Feb 2011, 20:50
by Katta
Hi
I have coded a snake-like game called "Kurve" (There is an original called "Zatacka - Achtung die Kurve" wich used to run on DOS). Now, as it runs fine on windows and linux platforms, I want to add an AI-player to it to create a singeplayer-mode. My problem is, I never have done any AI-programming, and my collision-detection is weak too.

FACTS (the way it works so far)
  • For 2 - 6 Players on one PC (no LAN does exist so far)
  • Controlled via Keyboard, 1 Player with the mouse-buttons
  • Coded in C++
  • Grapics, Input via SDL
  • Rendering via openGL
  • Minimum requirement: worked fine with my laptop set to 550Mhz singlecore

  • Collision-checks by openGL-select-buffer (this should improve)
  • imformation on the trail is stored in linked list of structs
  • a struct contains 2 points (one for the left and one for the right) and additional information
AI-IDEAS
My current idea is to allways check several possible ways if something is there and choose one possible (where nothing is in) at random

At this point I need your help. How can I check if someone is there in a fast and elegant way? The openGL select buffer does not seem to be made for that nor does it for collisions at all.

Thank you in advance
Katta

ps: excuse any bad spelling and any wrong use of words :)


Screenshots
[ # 1 ] Singleplayer with "dead" opponents is boring
[ # 2 ] Many AI controlled players
[ # 3 ] extra-point area & colors
[ # 4 ] the "light" where s.o. crashed

DOWNLOAD
Checkout github for the latest source & binaries (http://github.com/kattalunikes/Kurve). The game should work fine on any Linux, Mac or W32 system. It has been sucessfuly tested on: gentoo-64bit | gentoo-32bit | Ubuntu 11.04 alpha | Windows XP | Windows 7

Changes:
2011-02-27
-- download link -> v0.03
-- Added a screenshot
2011-02-28
-- 2 new screenshots
-- download link -> 0.03_2
2011-03-06
-- GitHub !!

Re: Kurve (dt: curve) - I'd like to make an AI

PostPosted: 25 Feb 2011, 23:01
by Katta
3 days passed and noone replys...

Okay.. I'll give you an update on the situation. Maybe that gets someone interested :)

Change log
- Collision detection is based on math now
- Gaps no more gray for everyone
- fixed some drawing issues

Download link
http://tjk-in.co.cc/Uploads/Bilder/dl.p ... e_0.02.zip

Re: Kurve (dt: curve) - I'd like to make an AI

PostPosted: 26 Feb 2011, 02:18
by hc
Just considering the local view point of a curve:

I would start by calculating distance (depth) values for a range of angles from left over front to the right [-90, .., 0, +90] as seen from the line's heading. This is basically the depthbuffer for the field of view of the kurve-worm if you set yourself into flatlands http://en.wikipedia.org/wiki/Flatland. To create a depth value you've got several ways you probably already know: raycast using bresham or the likes OR projecting curvepixels to the flatland-view of the worm-eye.

Now given that distance array you may either select the angle-entry with the largest distance value or any random of the largest ones - possibly after removing the worst (nearest). But randomness will lead to random seemingly undecided behavior.

An better option may be to weight the angles according to the distance. Where larger distance is preferred:

evasion_angle = (sum i = -FOV to +FOV : distance[i] * i) divided by (sum i = -FOV to +FOV : distance[i])
where FOV is (half) the field of view (eg 90°). The more steps you take - the more distance values you sample - the more precise it will get but it will cost more - then again it can work with very few samples.

This would be a beginning, then I would try different weighting functions, instead of distance[i] use f(distance[i]) and use the power function (pow(x, y) = x^y)

To switch between different behaviors you may use different weighting functions (or parameters for a single function).

One more note on the evasion_angle, you may take/understand it as a steering value (direction and strength) instead of an absolute angle. And you may want to apply some function to this value again (eg. the power-function again after normalization to a 0,1 interval) to make stearing appear somewhat more "human" with under- and over-steering.

This may be a bit much but you may just start and add more.

...and finally you may add some preference to some special point on the screen if you want to add global information.

Re: Kurve (dt: curve) - I'd like to make an AI

PostPosted: 26 Feb 2011, 17:37
by KroArtem
As for me, the problem is that it is too hard to control two players at the same time :) Also I cannot exit the game just by pressing 'Esc' key.
The necessity to control two players spoils the first impression though I hope you'll add ai.
Btw, it compiles and runs good under Ubuntu 11.04 alpha ;)

Re: Kurve (dt: curve) - I'd like to make an AI

PostPosted: 27 Feb 2011, 20:14
by Katta
Wooo I made an AI :D

It's not perfect, but it does not crash that fast into walls :)

Currently I cannot upload it, where I did before, as they are moving their servers and thus my account there. I might upload it somewhere else later. You'll see :)

So far
Katta

Edit:
Check this.. 6 AI-Players fought..
Image

Re: Kurve (dt: curve) - I'd like to make an AI

PostPosted: 27 Feb 2011, 20:17
by KroArtem
Ok, will wait for the next version :)

Re: Kurve (dt: curve) - I'd like to make an AI

PostPosted: 27 Feb 2011, 20:26
by Katta
Update:
I uploaded it at some free file hoster. I'll delete it when the other upload works again.
http://www.dateiupload.net/download.php ... 6fa1c06772
Katta

Ps: Does someone know how git+github works? I might try it then as I just started to use a local git reposerty for my game.

Re: Kurve (dt: curve) - I'd like to make an AI

PostPosted: 27 Feb 2011, 20:39
by oln
I have only used gitorious and sourceforge, but should be easy to set up if you register.

Re: Kurve (dt: curve) - I'd like to make an AI

PostPosted: 28 Feb 2011, 21:23
by Katta
Another Update :) And my webhost is online again :)

Changes
- The area where you can get an extra point when someone crashes into changed ( i lack words to describe properly :) )
- Added a white "light" at the place someone crashed in someone else
- All colors changed slightly

Fixes
- Players order is from 1 to 6 again
- Fixed display when resizing while playing
- Fixed a segmentation-fault crash (a friend helped me)
- Fixed a freeze in staticwait. SDL_Delay sometimes got passed -1 as SDL_GetTicks() raised within the function

New screenshots
[ # 3 ] extra-point area & colors
[ # 4 ] the "light" where s.o. crashed

Downloadlink 0.03_2

Re: Kurve (dt: curve) - I'd like to make an AI

PostPosted: 28 Feb 2011, 21:35
by charlie
I would still encourage you to set up a github account and get the git repo online for this. Then, should you go elsewhere in life (or the afterlife!) then your efforts will always* still be accessible to all regardless of the status of your web host.

* Well, more like to be always with github than your web host, it seems.

Re: Kurve (dt: curve) - I'd like to make an AI

PostPosted: 06 Mar 2011, 13:54
by Katta
Hia
i uploaded it to githib now see http://github.com/kattalunikes/Kurve

Re: Kurve (dt: curve) - I'd like to make an AI

PostPosted: 17 Mar 2011, 20:13
by ginkgo
Hello am I correct in assuming, that your game is like Tron, but with curved paths instead of 90 degree turns?

You might want to take a look at my game pink pony which does essentially the same thing, but uses 3D graphics to visualize the 2D gameplay. You can also find it on github.

MCMic created a very simple AI system for the game. Maybe you can get some inspiration from this.

If you find a way to improve it, please let me know. I'd love to have less predictable computer enemies for my game. :)

Re: Kurve (dt: curve) - I'd like to make an AI

PostPosted: 17 Mar 2011, 21:07
by KroArtem
There _is_ an AI in Kurve, though it is very simple, very easy to win, especially if you play with 1-2 players ;)
ginkgo, looking at github's commits, I think you're not developing Pink Pony for almost 2 years :(

Re: Kurve (dt: curve) - I'd like to make an AI

PostPosted: 20 Mar 2011, 20:13
by Katta
Hehe
I am learning for some test at this time (Abitur). I hope I have written the English 'Grundkurs' Abitur last friday. Math, physics and a colloquium will be in the next three weeks. After that I guess I will have some time to take a look at that :-)
Katta

Ps: I added a fullscreen-mode more than a week ago