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

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

Postby Katta » 22 Feb 2011, 20:50

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 !!
Last edited by Katta on 06 Mar 2011, 13:56, edited 3 times in total.
Katta
 
Posts: 8
Joined: 19 Feb 2011, 20:29

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

Postby Katta » 25 Feb 2011, 23:01

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
Katta
 
Posts: 8
Joined: 19 Feb 2011, 20:29

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

Postby hc » 26 Feb 2011, 02:18

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.
github.com/hackcraft-de
hackcraft.de
User avatar
hc
LW3D Moderator
 
Posts: 213
Joined: 07 Feb 2011, 10:00
Location: far away

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

Postby KroArtem » 26 Feb 2011, 17:37

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 ;)
KroArtem
 
Posts: 375
Joined: 26 Aug 2010, 19:04

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

Postby Katta » 27 Feb 2011, 20:14

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
Last edited by Katta on 27 Feb 2011, 20:20, edited 1 time in total.
Katta
 
Posts: 8
Joined: 19 Feb 2011, 20:29

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

Postby KroArtem » 27 Feb 2011, 20:17

Ok, will wait for the next version :)
KroArtem
 
Posts: 375
Joined: 26 Aug 2010, 19:04

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

Postby Katta » 27 Feb 2011, 20:26

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.
Katta
 
Posts: 8
Joined: 19 Feb 2011, 20:29

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

Postby oln » 27 Feb 2011, 20:39

I have only used gitorious and sourceforge, but should be easy to set up if you register.
User avatar
oln
 
Posts: 1020
Joined: 26 Oct 2010, 22:16
Location: Norway

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

Postby Katta » 28 Feb 2011, 21:23

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
Katta
 
Posts: 8
Joined: 19 Feb 2011, 20:29

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

Postby charlie » 28 Feb 2011, 21:35

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.
Free Gamer - it's the dogz
Vexi - web UI platform
User avatar
charlie
Global Moderator
 
Posts: 2131
Joined: 02 Dec 2009, 11:56
Location: Manchester, UK

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

Postby Katta » 06 Mar 2011, 13:54

Hia
i uploaded it to githib now see http://github.com/kattalunikes/Kurve
Katta
 
Posts: 8
Joined: 19 Feb 2011, 20:29

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

Postby ginkgo » 17 Mar 2011, 20:13

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. :)
ginkgo
 
Posts: 15
Joined: 14 Dec 2009, 17:10

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

Postby KroArtem » 17 Mar 2011, 21:07

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 :(
KroArtem
 
Posts: 375
Joined: 26 Aug 2010, 19:04

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

Postby Katta » 20 Mar 2011, 20:13

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
Katta
 
Posts: 8
Joined: 19 Feb 2011, 20:29

Who is online

Users browsing this forum: No registered users and 1 guest