bot drivers

bot drivers

Postby coffee » 19 Sep 2013, 14:47

Hi,

I discovered Stunt Rally this morning, it's really good !

I have an idea... 2 ideas, in fact.

First, I like a special kind of games called "programming" games. For example in the game TORCS, you can create programs that drive cars. Then, the challenge is to write the most efficient program. I'd like to do the same here, it would be quite challenging and fun. There are several ways to do it, hardware emulator, interpreted language... What do you think ? Would you be hostile to such a feature ? If you're ok, could i try and do it myself ? Would it deserve a fork ?

2nd idea : it could be fun to have some futuristic technologies in new cars. The game should keep being realistic, so new tools should have a plausible scientific description/explanation...

I hope my english is not too bad.

Anyway, once again : really great game, congratulations !
coffee
 
Posts: 10
Joined: 19 Sep 2013, 14:05

Re: bot drivers

Postby CryHam » 19 Sep 2013, 17:43

Cool.
I'd love to race with AI/bots even just for fun, I think we all would.
So if you know what to do, to implement it, go ahead. If it works, it will be in game.
I just think it's quite difficult to make it drive good (so it is competitive to drive with bots).
There is an issue here with some thoughts about AI.
Like I mentioned there, now we have track ghosts, this could be useful data for bot car's drive-line or steering method.
Visit us on IRC, so we can discuss what is better a branch or fork, depends on your skills, I don't want any accidents on master (beside mine :) ).
Hmm, which futuristic technologies do you mean ?
User avatar
CryHam
SR Moderator
 
Posts: 1047
Joined: 25 Nov 2012, 08:40

Re: bot drivers

Postby coffee » 20 Sep 2013, 08:27

I mean smoothly futuristic technologies that change the gameplay and make cars faster, like... What happens in the next 50 years, in the real world? How does WRC really look like in 2063? Just a few :
> combustion engine replaced by electricity
> batteries 8x smaller and twice as strong
> in-wheel motors (radically changes the design of the car)
> hubless wheels
> rear axle steering
> weight loss because of new alloys
> nanotechnologies in tires

About AI, yes I know what to do, but I want to say this :

What I won't do :
Perfect AI, driving alone and making unbeatable lap times. I mean, we could do it, as you said : take a good ghost, evolve it genetically during the night and you're done. Now, what's the point? Human driver can't beat it anyway, so no way. It's no fun.

What I suggest here is rather to give AI-junkies (like me) a simple way to create their own drivers. Bots are meant to race together, 4 cars at a time. As it was said in the issue, there's already 4 slots, it's enough. I want to watch em struggling hard...

You said that drawing a line for each track, or adjusting anything by hand, would be wasting time. I agree. I think the good approach is first to create a utility software that automatically calculates a "botmap" for each track. This map simply shows 3 things for each location or area :
- speed loss
- grip
- direction randomization
As input, bots will have this botmap (whatever we name it), the track itself, models of currently racing cars, and of course position + speed + direction + angular speed of all cars. As output, bots will have the same controls as a human driver.

What do you think?
coffee
 
Posts: 10
Joined: 19 Sep 2013, 14:05

Re: bot drivers

Postby CryHam » 20 Sep 2013, 10:41

Right, I agree. Sounds good.
It would be cool to have different drivers (and easy way to implement them), so e.g. and old grandpa driver, too fast guy and the patient rally driver, etc.
Only questions are: do you need a script language for it or can it be in C++ ? And secondly can you implement it or should I somehow provide it (script interface) ? If you know how to code all that I'm okay with any way.
If we have more than 4 cars I will have to think of some optimisations, e.g. in VDrift more cars caused slowdown because of sound processing.
Apropo utility software, I would just put this code, not as a separate program, but either in game (as a _Tool_, not started in Release) or in editor (a new tab with some options maybe).

About futuristic technologies.
Sounds cool. Maybe even a hovercraft someday.
Just a small remark, surface/gravel grip won't change (unless gravity would). So if car is lighter, it will also have less grip.
But yeah, if engine power efficiency is higher, it will accelerate faster.
User avatar
CryHam
SR Moderator
 
Posts: 1047
Joined: 25 Nov 2012, 08:40

Re: bot drivers

Postby coffee » 20 Sep 2013, 14:51

It would be cool to have some Design School students working on these cars for their homework :)

About AI, you won't need to provide anything, maybe just answer a few questions every once in a while. But we have to answer this question first : what are these AIs made of?

I don't plan to re-create the whole thing. Instead I want to use an already existing solution.

Raw C++ the way TORCS does it, I don't like it. Back in time, when i was glad with 400Mhz, it would have been ok. Nowadays, we have good sandboxed interpreted languages and VMs. After all, we're talking about untrusted code. Infinite loops should not freeze the entire game, and since it's a race, scheduling should be fair.

I don't know yet. If anyone has suggestions... Now is the right time !
coffee
 
Posts: 10
Joined: 19 Sep 2013, 14:05

Re: bot drivers

Postby CryHam » 20 Sep 2013, 15:19

Hmm. I don't know much about scripting (yet).
I've only heard of these:
http://www.lua.org/about.html
http://www.angelcode.com/angelscript/features.html
I think a script for AI would be enought, right ?
User avatar
CryHam
SR Moderator
 
Posts: 1047
Joined: 25 Nov 2012, 08:40

Re: bot drivers

Postby coffee » 20 Sep 2013, 17:17

Absolutely.

About Lua, no. When the VM is running, it's out of control : you just can't stop it from the outside.
Unless you play with debug hooks or hack into the VM.

Angelscripts meets our needs, so it's a green light !

I'm on my way :)
coffee
 
Posts: 10
Joined: 19 Sep 2013, 14:05

Re: bot drivers

Postby coffee » 22 Sep 2013, 10:42

Are you ok with Angelscript ?

I've begun swimming in the code... I can work on it approximatively 2 hours per week, so don't expect anything before Xmas.

I have another idea.
Writing bots is cool, but most players simply want to play the game. When the player wants to race against an AI, he expects a list of available bots to choose from. Using the Bittorrent protocol, AIs could be automatically shared between players. There's a good library called Libtorrent, it includes trackerless torrents, and it can work quietly in the background. I think it would be a good idea to include it in the game, so the list of available AIs is always up-to-date.
What do you think ?
coffee
 
Posts: 10
Joined: 19 Sep 2013, 14:05

Re: bot drivers

Postby CryHam » 22 Sep 2013, 12:25

Sure, I'm okay with Angelscript.
About code, please use latest master, there were some serious changes in how the code looks, mostly Gui.

I guess we will include the best (most popular) bots in game anyway.
But sounds very interesting. Where is the data then located, on user PCs ? Sounds a bit too few for me to be available, no idea.
Could it even be used for user tracks ? Is about 1-2 up to 5 MB per track.
User avatar
CryHam
SR Moderator
 
Posts: 1047
Joined: 25 Nov 2012, 08:40

Re: bot drivers

Postby coffee » 22 Sep 2013, 13:46

About code, I did :
- git clone git://github.com/stuntrally/stuntrally.git stuntrally
- cd stuntrally/data
- git clone git://github.com/stuntrally/tracks.git tracks
I guess it's the latest master, right ?

About Libtorrent, yes the data is downloaded and then it's located on user's PC, it's P2P.

Yes good idea, we can use it for sharing :
> bots
> user tracks
> ghosts
> calendars for multiplayer games (like "I'm online every sunday between 10:00 and 12:00")

edit: There would be a switch option :
- enable file sharing
- not during races
- disable file sharing
coffee
 
Posts: 10
Joined: 19 Sep 2013, 14:05

Re: bot drivers

Postby CryHam » 22 Sep 2013, 14:28

Sounds cool.
I wonder how will it be in practice. For anything to be available, there had to be users playing SR at the moment right ? IMO is a bit impossible right now. Or at least some server edition of game always on.
User avatar
CryHam
SR Moderator
 
Posts: 1047
Joined: 25 Nov 2012, 08:40

Re: bot drivers

Postby coffee » 22 Sep 2013, 15:54

Yep, when 2 users are playing at the same time, they share files.

Or...

At install, you ask the user whether or not he wants to install the "SR-Community" daemon/service.
When you launch "SR-Community", it runs in the background, and it has a "run at startup" option.
coffee
 
Posts: 10
Joined: 19 Sep 2013, 14:05

Re: bot drivers

Postby CryHam » 22 Sep 2013, 16:39

Sounds interesting. But IDK. We don't seem to have enough people to even test such implementation both on Linux and windows.
I'm guessing people would like to just download everything at any time, for which we won't ever have paid servers.
But if p2p works it will be cool.
User avatar
CryHam
SR Moderator
 
Posts: 1047
Joined: 25 Nov 2012, 08:40

Re: bot drivers

Postby coffee » 22 Sep 2013, 17:59

:) someday maybe...
coffee
 
Posts: 10
Joined: 19 Sep 2013, 14:05

Re: bot drivers

Postby coffee » 27 Sep 2013, 17:13

Ok, I have a dirty build and 15 fps. I'm starting playing around.
coffee
 
Posts: 10
Joined: 19 Sep 2013, 14:05

Re: bot drivers

Postby CryHam » 27 Sep 2013, 17:35

Cool. I'm on IRC now too, if you need real time help.
User avatar
CryHam
SR Moderator
 
Posts: 1047
Joined: 25 Nov 2012, 08:40

Re: bot drivers

Postby Wuzzy » 29 Sep 2013, 16:24

Scriptable bots would be a nice addition to the game.

I did not hear of AngelScript before, but when I read “Statically typed” I was immediately convinced that this is the better choice. Lua is dynamically typed and I know from experience how much of a pain of a ass it can be for debugging. Especially when you can’t trust your input, this results in tons of basic type checking … :x

Not that I really plan to write a bot btw, just my fourty-two cents. :p

I am a bit skeptical of futuristic stuff. But as long as it doesn’t make the game drift too far away from the “Rally” part in StuntRally, I’m okay. But I don’t consider it very important.
User avatar
Wuzzy
 
Posts: 989
Joined: 28 May 2012, 23:13

Re: bot drivers

Postby CryHam » 29 Sep 2013, 17:26

Right. Thanks for info, I didn't catch that difference.
AI is also low priority for me. But would be cool to see it someday.
User avatar
CryHam
SR Moderator
 
Posts: 1047
Joined: 25 Nov 2012, 08:40

Re: bot drivers

Postby dimproject » 30 Sep 2013, 17:58

Bot driver(s) could prevent player from take good time to win.
For game mode "Battle" (maybe in future) bot driver(s) very need.
dimproject
 
Posts: 212
Joined: 18 Jul 2013, 13:51

Re: bot drivers

Postby coffee » 09 Oct 2013, 08:31

Bot-drivers will be made of two parts : Head and Hand.

The Head is Angelscript. Execution speed is limited to... say 100 lines per second. Because we don't want to lose more than 5 fps with 4 bots racing together. The Head part controls the Hand part. The Hand part can keep the car on the track while the Head part is analysing the next hot spot.

The Hand part is a formula of 40 characters, written in a simple stack-based language (not turing-complete), that is executed when the game demands "cars input". The stack is an array of 40 floats, with a pointer indicating the topmost element. So execution of the formula is very fast. Here is the language :

{l Code}: {l Select All Code}

$   duplicate
#   flush
!   pop
\   swap
@   rotate third to top
^   yank

0..9   constant
a..z   variables

:   assign
?   condition
]   jump

+   add
-   sub
*   mul
/   div
%   mod

<   lesser
>   greater
=   equal
&   and
|   or
~   not

A   object = my car
B   object = beacon
C   object = next checkpoint
D   object = opponent's car

E   distance to object
F   direction to object

G   horizontal orientation of object
H   horizontal direction of object
I   altitude of object
J   speed of object
K   relative speed of object
L   vertical speed of object

M   max
N   min
O   abs
P   pow
Q   decompose into integer and fractionnal
R   random
S   sign

T   time
U   undo value
V   send value
W   RPM
X   lateral speed of my car
Y   axial speed of my car
Z   altitude of my car



Any other character is ignored.

There must be 4 "V" in the formula. When "V" (send value) is executed, the value on top of the stack is assigned to :
- handbrake
- accelerate/brake
- gears
- steering

0 zero means "false", any other value means true.

When "?" is executed, if the top value is zero, the next character is ignored.

When "]" is executed, if the top value is 25 for example, then 25 characters are ignored.

When a variable is executed, its value is pushed on top of the stack.

The Head can also pilot the Hand by modifying the 26 variables "a".."z"
coffee
 
Posts: 10
Joined: 19 Sep 2013, 14:05

Re: bot drivers

Postby CryHam » 09 Oct 2013, 11:44

Sounds interesting.
I just find it quite cryptic. But if it works that's ok. Probably reduces cpu time needed, this is good.
User avatar
CryHam
SR Moderator
 
Posts: 1047
Joined: 25 Nov 2012, 08:40

Who is online

Users browsing this forum: No registered users and 1 guest