Unnamed Race Game


joyrider

Member
Joined
Mar 29, 2006
Messages
590
Age
40
Website
www.willemssoft.Be
Hey guys,

I'm completly trying something new a little top down view race game :) check it out here (STILL VERY WIP) : http://www.youtube.com/watch?v=-CMPWrYSwPQ

I already got a ghost car implemented which isn't that hard, and i'm trying to create a cpu player (the blue car). but he's almost always doing the same thing. I think it's because i'm using a simple method to keep the car in the middle of the track. You see i take +45 & - 45 degrees angles from the current cars position and then count the steps it takes to reach the borders, if the left side has more steps, the car turns left and vice versa. It seems to work great but i'm having problems with the levels with sliding doors. but it doesn't seem to be a good approach because the car always drives the same line on the track.

Do any of you know of a better way to make a cpu player. It should work on any level i give it too. Because you'll be able to create your own levels just by using any image editor.

I think i'll start with a time trial only version, and make an option to save the ghost car so you can share ghost cars with each other and see how other people drove on that track and what their best time was :)


anyway if someone can shed some light on how to create "realistic" cpu players for this kind of race game let me know :)
 
Last edited by a moderator:

ruckage

Certified Guru
Joined
Oct 15, 2006
Messages
659
Looking good, and I think your CPU car is impressive, did you come up with that method yourself? I'm sure you could keep that basic centering method and just add to it to make the AI appear more realistic.
For example does the AI take into account the position of other cars around it (couldn't see in the video because the AI was always first) if so when you had several cars on the track they would then interact with one another and instantly appear more intelligent. Anyway, looking good so far, cant wait for a finished game :).
 

Iorgy77

emu parasite kid
Joined
Oct 17, 2003
Messages
2,068
Age
43
Location
Melbourne, Australia
Website
Visit site
I had a bit of fun creating a track earlier, really easy I think when this is released the community is going to go nuts creating tracks. :)

 

joyrider

Member
Joined
Mar 29, 2006
Messages
590
Age
40
Website
www.willemssoft.Be
Well the cpu car doesn't take into account other cars positions atm, i didn't came that far. But i got another problem you see for the direction the car should go to i can use that simple method of centering the car. but i don't know how i can throttle speed automaticly. now i just let it drive fullspeed always. and added a red color to the level mask on the spots where it has to slowdown. this works, but it would be cooler if i could figure out a way to do this without the red colors.

The only way i could think of is some brute force method, so basicly from any given point look X steps ahead and see if the car will touch the borders at it's current speed in those X Steps ahead. if so deaccelerate. I have yet to try this out but it could be that it uses to much cpu cycles just not sure yet.

Yeah creating levels for this game will be real easy all it will need (eventually) is a background which would be just for eye candy, a mask which defines the actual road,bridges,jumppads,speedboostpads etc and optionally a toplayer for graphics where the car should pass behind it (like tree's,finish lines, the tower in that level 4 etc). So you got all the graphical freedom you want :) because the mask defines the actual gameplay but you don't see it.
 

b._.o._.b

Very Active Member
Joined
Jul 6, 2006
Messages
1,159
The uncrowned king of puzzles is going into arcade action? Looks like a very nice attempt. :)
 

joyrider

Member
Joined
Mar 29, 2006
Messages
590
Age
40
Website
www.willemssoft.Be
WhiteFalcon said:
Hey, this looks really neat! I used to love Super Speed for DOS, after which your game takes a lot. Good luck! :)



Yeah i loved it also, i played it quite a lot on my first pc ever :) I took screenshots of those levels and edited them to create my own track and test everything out :)


b_o_b said:
The uncrowned king of puzzles is going into arcade action? Looks like a very nice attempt. :)
Haha yeah, i got enough of puzzlers and i had to try out what i learned from that pixelate magazine about sinus and cosinus :) it's actually quite simple once you know what it represents :)

I'm happy with the result already, i got bridge logic fixed, well it's almost pixel perfect there's just one situation which rarely happens where you can drive through a bridge but i'll leave it like that :)

now i need to check out the ai logic for the gate levels again. the trick for the cpu car doesn't work in it since it's not a normal level, there are gaps in it wich makes the cpu fail. Will have to think about this one especially level 2 is kinda hard to make him work on :)
 
Last edited by a moderator:

Alex.

Retired
Joined
Aug 24, 2005
Messages
4,617
That looks great, racing and sports games are among the most overlooked genres in GP2X homebrew :) Good luck completing it, and nice job on the AI car steering!
 
Joined
Dec 1, 2006
Messages
947
Location
Scotland
Website
Visit site
The way I did the CPU cars in Powerslide was to use a set of points and drive from point to point. That way you make it look like the CPU car is taking the racing line. As for throttle a possible solution might be to find the difference between the actual CPU direction and the intended direction and if its over a certain amount decrease the speed.

This game looks brilliant. Im really looking forward to this. :D
 

joyrider

Member
Joined
Mar 29, 2006
Messages
590
Age
40
Website
www.willemssoft.Be
Unfathomable Depths said:
The way I did the CPU cars in Powerslide was to use a set of points and drive from point to point. That way you make it look like the CPU car is taking the racing line. As for throttle a possible solution might be to find the difference between the actual CPU direction and the intended direction and if its over a certain amount decrease the speed.
I'm gonna try that out, it's basicly pathfinding then because my system works on certain tracks but not on others although i could still use the system to see if gates are open or not and trying to pass cars.

I tried adding 2 other lines but it misserable fails then, plus with my system the cpu car can get into an occasion where drives backwards all of a sudden on the track hehe :)

thanks
 
Last edited by a moderator:

joyrider

Member
Joined
Mar 29, 2006
Messages
590
Age
40
Website
www.willemssoft.Be
I have been trying many things with cpu cars now (am having a blast).

I was trying to get the cpu to follow waypoints by going from -45 to +45 car's angle and seeing which blue square in the mask was closest by looking at the steps again and take that angle as the desired angle. this works but the cpu messed up a little. Then i got the ingenious idea to instead of taking the closest square the furtest possible square he has seen. (with seen i mean those green lines it's basicly his point of view, like when you drive a real car you also have certain angles to which you can see the road). So with this he cuts corners like hell !! he's become unbeatable now lol :) The placement of the blue squares is rather important.

I'm now goana experiment a bit with this. basicly trying to limit the amount of steps the car can see. in real life you can't see the end of the road either lol :)

http://users.pandora.be/IMS/misc/devmovies/newcpu.swf.html see it in action :) i reduced the number of squares.

I still have no idea how to make the car not go backwards on the track though and the gates give me problems as well :/
 
Joined
Dec 1, 2006
Messages
947
Location
Scotland
Website
Visit site
Thats really nice, I like that a lot :)

I was just using atan to calculate the angle to the next point and turning the car till the angles match.

As for the gates would it be possible to just check if a gate is open once the CPU car is in a certain 'zone' and make the next point the one that takes him thrrough the gate? Did that make sense?
 

joyrider

Member
Joined
Mar 29, 2006
Messages
590
Age
40
Website
www.willemssoft.Be
Unfathomable Depths said:
Thats really nice, I like that a lot :)

I was just using atan to calculate the angle to the next point and turning the car till the angles match.

As for the gates would it be possible to just check if a gate is open once the CPU car is in a certain 'zone' and make the next point the one that takes him thrrough the gate? Did that make sense?
i'm actually using atan2, like this : atan2(Dest.Y - Car.Y, Dest.X - Car.X) i found this with googleing a bit :)
however it gave me rather weird results so i had to multiply it with 180 and divide it with PI, that seems to work great. (I found it weird because for my sin / cos lookup table i had to multiply by PI and divide by 180 to get the results.) Maybe i'm doing something wrong :) but hey it works and i aint too good with trigometry. I'm trying to understand it all but it's kinda hard coming from zero experiance with it ;)

I have played a bit with my latest modification on the new cpu car, i think i'm going to go with this approach.
I have limited the steps the cpu car can see in front of it. so it doesn't like cheat and go straight to the last point at the end of the road. This is how it looks like now : http://users.pandora.be/IMS/misc/devmovies/newcpu2.swf.html

About the gates, i'm still struggling with that, i'm trying the approach you said at least thats what i'm aiming for, if the cars in a certain range check if the gate is open and take the point with the least steps as the angle until it passes the gate. But implementing this is not that easy hehe well i haven't really tried it yet was gonna do that next :)

If i got the gates working i'm gonna try a brute force method to calculate the cars speed. basicly what i'm going to do is create another invisible car at the same point where the current cpu car is and let him say take 50 game steps in advance to see if he will make a turn or not. If not deaccelerate and try again, until he can make the corner :) that should work in theory but its rather cpu intensive and might not be good for the gp2x but hey i can try can't i :)
 
Last edited by a moderator:
Joined
Dec 1, 2006
Messages
947
Location
Scotland
Website
Visit site
I think Im missing the point regarding your problem with the CPU cars speed.

I had a top speed which gradually increased as the game went on, ie the CPU cars got increasingly quicker with each track. I cheated by making the CPU cars top speed faster if the player was in the lead.


*edit* I just looked at your vid and I see your problem. Easy solution though, I think.

Some pcode:
CODE
function anglediff(a1, a2)

a3 = abs(a1 - a2)
if a3 > 180 then a3 = 360 - a3

return a3


a1=current CPU angle, a2=intended CPU angle
if the angle difference (a3) is greater than some amount, dont accelerate.
 

joyrider

Member
Joined
Mar 29, 2006
Messages
590
Age
40
Website
www.willemssoft.Be
that's it ! it works great ! Thanks a lot !
and such a simple solution. Now i just have to find the optimum value or add steps like deacclerate to half speed if the angle diffrence is greater than a certain amount, same for quarter of a speed & 3 quarters.

It does fail on certain maps though but that's because i was messing around with the waypoint system and had changed the viewing angle a little (I removed the way point when it was scanned/Seen, but i should add it back if the car has passed it or say has scanned 5 new waypoints). I just have to tweak it all a little now. thanks again.

btw this is how it looks like now :
http://users.pandora.be/IMS/misc/devmovies/newcpu3.swf.html
 

kevcal

Coding " Abduction;Retrieval "
Joined
Jun 14, 2006
Messages
836
Age
54
Location
Southern England
Website
homepage.ntlworld.com
joyrider said:
i'm actually using atan2, like this : atan2(Dest.Y - Car.Y, Dest.X - Car.X) i found this with googleing a bit :)
however it gave me rather weird results so i had to multiply it with 180 and divide it with PI, that seems to work great. (I found it weird because for my sin / cos lookup table i had to multiply by PI and divide by 180 to get the results.) Maybe i'm doing something wrong :) but hey it works and i aint too good with trigometry. I'm trying to understand it all but it's kinda hard coming from zero experiance with it ;)

Because you use radians for C trig functions...

Looks really good - may be worth (when it's close to complete) adding both skidding as necessary and also a small amount of randomness to the AI cars - gives the impression to the player there's more to the logic and you attribute vindictiveness if you're shunted off by a CPU car.. :)).
 
Last edited by a moderator:
Top