Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Program Announcements / [Dark AI Compo Entry] - Railrider

Author
Message
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 30th Aug 2006 19:10 Edited at: 31st Aug 2006 19:30
*** Latest Version - Download Here! ***
(Don't use download button on this post)



Well, I have run out of time, so this is my entry into the Dark AI competition. There's stuff I would have liked to have added - High Scores, better menu, shaders and more animations and effects - but I also have a life!

There's loads of information here on techniques, so if you haven't finished your entry, have a look and see if you can steal something useful!!!





Attachments

Login to view attachments
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 30th Aug 2006 19:11
How to Play


Railrider’s objective is simple. On each level, you must collect 5 tokens before the computer opponent. First to 5 wins the round. Lose, and it’s game over.

Controls


You use only the left and right arrow keys to control your carriage. It will accelerate automatically, and you can only travel forwards. It will even turn by itself around corners. The only choice you have to make is which way to turn at junctions. The arrow keys will manoeuvre your carriage right and left.

Consequences


If you do not turn at a T-junction, you will crash. Your speed will be reduced to zero, and the carriage will turn back and carry on in the opposite direction. It will automatically accelerate back up to full speed.

If you hit the opponent carriage, again you will crash. Your speed will be reduced to zero, and the carriage will turn back and carry on in the opposite direction. It will automatically accelerate back up to full speed.
If you hit the opponent head-on, he too will stop and turn. If you hit him from behind, he will simply continue onwards.
When you hit your opponent, you will both lose a token.

Tactics


You can use a T-junction to double-back on yourself by crashing. You will need to work out whether the loss in speed is a worthwhile trade-off.

You can intentionally crash into your opponent to change direction of both you and the opponent. This may knock him off the best track to the next token, and he’ll have to find another way. If you have no tokens, or if he is dangerously close to winning, it’s also an opportunity to gain the upper hand again.

The most direct route is not always the best. Remember you cannot reverse, so look ahead and check where your opponent is going to be after you collect your treasure.

Collisions on corners are unpredictable. It’s possible to spin more than 180 degrees, and even end up off-track, struggling to find your way back on.



BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 30th Aug 2006 19:12
Use of Dark AI
============================

Dark AI is implemented in the following areas:

Path finding for the opponent
Tracking of opponent positions
Adjusting the intelligence of the computer-controlled player
Defining the valid track routes using waypoints

AI FAQ


How does the computer find it’s way around?
Whenever the situation changes, a new AI path is created from the player to the token. This happens when the game starts, whenever a token is collected by either player, or when a collision occurs.

How is the path used?
The path is a series of waypoints. Each one is used in turn to get the opponent from where he is to the token. Whenever the player idles, he is assigned the next waypoint to travel to.

Why do you never see the player idle?
The idle time for the opponent is set to –1. That simply means that he doesn’t get chance to do anything for himself. As soon as the idle state is detected, he is given his next instruction.

Why don’t you just assign the entire path and let the carriage get on with it?
We could, but working out where it was at crucial moments would be difficult and time-consuming. By doing it the way it is, you always know which track part the carriage has come from and is going to. This is a grid-based system, so it’s important to know where on the grid you are.

How is the carriage kept on the track?
The carriage simply travels between waypoints. Every area that is not track is defined as an obstacle.

But each obstacle creates many waypoints, how does that work?
The waypoints created by obstacles are removed. The waypoints are recreated in a memblock, one in the centre of each track tile. Thus just one waypoint, not 2, 3 or 4 that the obstacles create, represent each tile.

The carriage never cuts corners, why not?
The obstacle radius is set to 45% of the size of a tile, and thus protrudes way beyond the visibly inaccessible areas.. This basically makes the space available to the AI system very narrow, or “Track-like”, you could say!

And why doesn’t the carriage always face the direction of the next waypoint?
The AI object is actually a hidden cube. What you see is a model which is set to follow the AI cube exactly, but turn more slowly.



BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 30th Aug 2006 19:14 Edited at: 30th Aug 2006 19:14
Use of Dark AI (Continued)
============================


How do you get the Carriage to always go forward? Wouldn’t the AI reverse it when necessary?
Yes, the AI would take the shortest route. Every time a path is recreated, a barrier is placed behind the carriage, to make the reverse direction inaccessible.

But updating obstacles is slow, it’s just not possible mid-game
That is very true, and tests showed that the game stuttered very visibly. So instead of updating the obstacles, we do a little memblock magic. Earlier, it was noted that we always know where in the grid-based system the carriage is. The array that holds this information also holds the identity of the waypoint in the tile. So the waypoint can be quickly located in the memblock, it’s weight can be set to 100,000, effectively making it impossible to use, and then the memblock is moved back out into the AI system again. When the path is made, this waypoint will add too much cost to any path travelling through it to be considered.



BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 30th Aug 2006 19:15 Edited at: 30th Aug 2006 19:22
**** The 64 million dollar question…The carriage very rarely takes the perfect path to the token. Why does the AI get it wrong?!?! ****
The implementation of AI is designed to get it wrong! How boring would the game be if the opponent always took the best path? It would be an unfair advantage, and it would also mean you could work out how to avoid him.

So how is it done? Again, it’s some very simple memblock magic. Random waypoints are selected across the grid, and their weighting is changed to be much greater than the others, making them less desirable when making paths.

So there you are, Railrider in a nutshell!



Uncle Sam
18
Years of Service
User Offline
Joined: 23rd Jul 2005
Location: West Coast, USA
Posted: 31st Aug 2006 02:47 Edited at: 31st Aug 2006 03:03
Nice job.

I'm downloading. This must be good if it can capture my interest, becasue I rarely download anything from the forums.

EDIT:

very nice AI!
Only thing is at level two, right when it was starting, I got "object does not exist at line 3013"...I think that was the line. And it seems to take to long to delete the track, I mean, isn't it just "delet object"?

Other than that, good job. If you can fix that bug I'd say you havea good chance.

Uncle Sam
Nvidia Geforce 7600 GS 256MB PCIEx, 2.66 GHZ Pentium 4 proccessor, 768MB RAM
Need particles? Click here!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 31st Aug 2006 10:04
Quote: "I got "object does not exist at line 3013"

Fixed. Will upload again about 2 hours from the time of this post. My kids also found that one.

Quote: "it seems to take to long to delete the track, I mean, isn't it just "delet object"? "

This is an odd one, I'd love to know what your system specs are. I have...

a laptop running XP Pro, Intel processor and Radeon mobile graphics card, and it works beautifully.

a desktop running Windows 2000, AMD Athlon processor and a Geforce FX 5200 graphics card, and it takes forever to remove the track

I'd like to narrow it down, because you often see people complaining about the Delete Object command being slow. This is simply a loop that says if an object exists, then delete it. It also deletes the texture. There are about 220 plains in the track, of which half of them are hidden.



BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 31st Aug 2006 11:27
OK...next version will be later today. I'm going to rewrite the level end routine because of the speed problem when deleting objects.



BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 31st Aug 2006 12:37
New version here. Fixes "Object Not Found Error" and slow deletions bewteen levels.



Attachments

Login to view attachments
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 31st Aug 2006 16:40
Another Update. Sparky found a memblock bug when updating the waypoints for the pathfinding.



Attachments

Login to view attachments
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 31st Aug 2006 19:28 Edited at: 31st Aug 2006 19:31
Final touches just added, after solving my ultimate issue. Carriages and Tokens are now gloriously cube mapped using a shader mapped, making them look sexy!!!



Attachments

Login to view attachments
Uncle Sam
18
Years of Service
User Offline
Joined: 23rd Jul 2005
Location: West Coast, USA
Posted: 31st Aug 2006 21:38
My specs are in my sig.

I'm not trying to bash the delete object command, I used it in my game and it works good! I was just wonering why, that's.

Uncle Sam
Nvidia Geforce 7600 GS 256MB PCIEx, 2.66 GHZ Pentium 4 proccessor, 768MB RAM
Need particles? Click here!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 1st Sep 2006 02:09
I don't know what the problem is..are you on Win XP or Win2K? I've changed the program now anyway, so deleting is no longer an issue.



Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 1st Sep 2006 10:09 Edited at: 1st Sep 2006 10:35
Nice game BatVink but each time I run it, it refuses to exit. I am forced to ctrl+alt+delete to get rid.
[Edit] I take that back, the latest version seems fine[/edit]

It may be too late for the compo but may I offer a couple of suggestions where I beleive it could be improved?

1. Smoother camera rotation. When there are a lot of turns, like on the 'zig zag zig' level, it can really hurt the eyes the way the view is rapidly switched but smoothing the camera would help that a lot.

2. Less random positioning of the money bags. I had a similar problem with 'Kiss My Asp!', the player could be doing really well and then suddenly the target appears right in front of the CPU player three times in succession and the game is lost. It's great when it works in your favour but intensely frustrating when it goes against you. Calculating a more central point between players removes the frustration.

Other that those minor points it is a fun game ... good luck with the compo!


BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 1st Sep 2006 11:28
Quote: "Smoother camera rotation"

Agreed. I had problems on my Win 2K machine, with something somewhere else causing a stuttering effect. So I built the game to compensate. Originally, the camera was much better, but I couldn't test it because of my own problems!!!

Quote: "Less random positioning of the money bags"

Again, I agree. I have a method written down for ensuring the computer/player is at least 25% of the track area away from the goal, but didn't have time to add it.



Login to post a reply

Server time is: 2024-04-25 13:37:03
Your offset time is: 2024-04-25 13:37:03