NoAI Branch - An AI Framework

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

Locked
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: NoAI Branch - An AI Framework

Post by GeekToo »

Swallow,

I just tried your Apollo in the first zip you posted, but I did not see your problem. Lots of signs were build, and they all were correct. ( I am using a self compiled NoAI version, on Gentoo Linux)
Maybe there's a problem with your installation.
User avatar
saint
Engineer
Engineer
Posts: 45
Joined: 25 Dec 2005 23:01
Location: Australia

Re: NoAI Branch - An AI Framework

Post by saint »

Just had a look at Convoy - does perform quite well with all its buses. A couple of the times it attempted a route were abandoned in the last 10 tiles or so due to running out of funds.

It got confused by slopes once or twice too.
so close.png
so close.png (45.01 KiB) Viewed 3656 times
^ Seemed a pity it didn't make it :lol:
This is my sig
Mchl
Director
Director
Posts: 611
Joined: 05 Jan 2007 15:50
Location: Poland
Contact:

Re: NoAI Branch - An AI Framework

Post by Mchl »

It tried to do turn on slope, which is not possible... (well, it is, but in the other direction)
TrueBrain
OpenTTD Developer
OpenTTD Developer
Posts: 1370
Joined: 31 May 2004 09:21

Re: NoAI Branch - An AI Framework

Post by TrueBrain »

Swallow wrote:attached is a zip file containing a WIP info.nut and main.nut. The sign is placed at line ~57.

After some more testing the problem doesn't seem to occur always. In a small test 10 signs were placed. 7 of them showed the correct text, while 3 incorrectly displayed "Apollo". Kinda strange ?(
Tomorrow I will do some further testing....
Works flawless here and on any other computer I tried... make sure you have the most recent binaries.
The only thing necessary for the triumph of evil is for good men to do nothing.
Hirundo
Transport Coordinator
Transport Coordinator
Posts: 298
Joined: 27 Jan 2008 13:02

Re: NoAI Branch - An AI Framework

Post by Hirundo »

TrueLight wrote:make sure you have the most recent binaries.
I updated my scource to rev 13265. I had installed a program however that made itself the default program to open .vbs files, so the version detection failed. I changed some settings so MSVC++ 2008 opens them, but i'm not sure whether this is correct. Compiling succeeded, but it was labeled rev 13197-noai (my previous rev) instead of 13265. This should not affect the game though, I guess ?! (i'm far from experienced with this)

The sign problem still persists, but because a) I seem to be the only one experiencing it, b) it is not the most life-threatening thing and c) most of the signs are correct I decided to drop the issue. It may be better to stop focusing on signs and make an AI that builds something useful :)

(Note: this may be fixed in r13268, haven't had the time to recompile and test yet)
Also I'd like to report a bug. (As a side note, should I report them here or at bugs.openttd.org ?) I did the following:
- start a new random map game
- start my AI
- 'abandon game'
- start a new random map game again
- start my AI. <<Here the game crashes to desktop. Crash log attached
Attachments
bug report.txt
(6.73 KiB) Downloaded 152 times
Create your own NewGRF? Check out this tutorial!
xmart2k
Engineer
Engineer
Posts: 91
Joined: 04 May 2006 07:36
Contact:

Re: NoAI Branch - An AI Framework

Post by xmart2k »

i had the same problem...
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: NoAI Branch - An AI Framework

Post by GeekToo »

Swallow wrote:[
Also I'd like to report a bug. (As a side note, should I report them here or at bugs.openttd.org ?) I did the following:
- start a new random map game
- start my AI
- 'abandon game'
- start a new random map game again
- start my AI. <<Here the game crashes to desktop. Crash log attached
So did I, but since today it's solved (see details in the checkin log).
TrueBrain
OpenTTD Developer
OpenTTD Developer
Posts: 1370
Joined: 31 May 2004 09:21

Re: NoAI Branch - An AI Framework

Post by TrueBrain »

Both problems are indeed fixed. The sign-problem was because of some internals of Windows builds. That is fixed now. Strangely enough, it never appeared on the tests I did on the windows builds. Lucky for you, glx could reproduce is :) The sign-problem is fixed after the binaries were produced for today, so you have to wait an other 18 hours (from this post-time), or compile it yourself, to benefit from the fix :)

Btw, the revision SVN indicates is rarely the revision OpenTTD displays for the NoAI branch. This is because for the revision OpenTTD displays, that revision is used which had the last change in the NoAI branch, and not the latest revision in SVN (which has many more commits ;)).
The only thing necessary for the triumph of evil is for good men to do nothing.
User avatar
Zutty
Director
Director
Posts: 565
Joined: 22 Jan 2008 16:33

Re: NoAI Branch - An AI Framework

Post by Zutty »

Just a quick one... the build of r13265 isn't saving my changes to game options, which makes it difficult to test the AI. Is this a bug or just me being dumb?! It worked fine in r13057.

There is also a crash if I open the "Configure Patches" window. I have logged a bug for that one (#2044).

Cheers.

Edit: Oh dear god, my productivity has been completely annihilated with r13265. It never saves my settings, so it takes 5 times as long to reload when changing the code (and no I can just use the AI Debug window as I rely heavy on signs for tile based debugging, which aren't removed).

Edit: ARGH! Sorry it was crashing when the AI started too, but because of my code! I think there might be a problem with the Squirrel engine. I'll make a post about that later.
PathZilla - A networking AI - Now with tram support.
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: NoAI Branch - An AI Framework

Post by Roujin »

Hi guys, I'm now hooked on NoAI aswell :lol:

Actually I haven't made any serious attempt to make a whole, complete AI yet, but rather a .nut file with various helper functions, like e.g. a wrapper function for functions like SetCompanyName, which may fail; the wrapper function will then try again with a number appended until it succeeds ;) (xy #2, xy #3, ...)

For now, I've got some feedback for the devs..

First I must say that the Framework until now is very clear and understandable, congrats on that! :) It's very easy to get into this :)
Now something I've noticed, a little inconsistent: AIRoad.BuildRoad(...) is supposed to build from the middle of the start tile to the middle of the end tile. But if one of them is a slope, it will be fully built on (of course, slopes don't have half road tiles). BUT - if I now use RemoveRoad, which is also only supposed to remove from the middle of the starttile to the middle of the endtile, I have some artifact on the upper part of the slope left.

I think that's not right.. BuildRoad(a, b) and then RemoveRoad(a, b) should result in the same state as it was before building.

Oh, and I'm really looking forward to the TransactionMode. ;) I wanted to try it out, only then noticed in the API that it's not finished yet ;(
Well for now I've written my own workaround function for that :lol:
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
corne
Engineer
Engineer
Posts: 17
Joined: 03 May 2008 11:17
Location: The Netherlands

Re: NoAI Branch - An AI Framework

Post by corne »

How do you guys use try/catch in squirrel?
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: NoAI Branch - An AI Framework

Post by Roujin »

* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
Mchl
Director
Director
Posts: 611
Joined: 05 Jan 2007 15:50
Location: Poland
Contact:

Re: NoAI Branch - An AI Framework

Post by Mchl »

Roujin wrote: like e.g. a wrapper function for functions like SetCompanyName, which may fail; the wrapper function will then try again with a number appended until it succeeds ;) (xy #2, xy #3, ...)

Mine uses two arrays, and randomly chooses words from them to form a two part company name. So no numbers attached, as there are far more possible combinantions, than possible players :)
corne
Engineer
Engineer
Posts: 17
Joined: 03 May 2008 11:17
Location: The Netherlands

Re: NoAI Branch - An AI Framework

Post by corne »

Woops, I didn't add an identifier :oops: Thanks.
User avatar
Ralph
Engineer
Engineer
Posts: 87
Joined: 21 Jun 2004 15:25

Re: NoAI Branch - An AI Framework

Post by Ralph »

Hey hey

I found this today, far too much time and about 200 lines of code later, I had a bus finally make some money. Is there any kind of library around with extra helper functions? Things like returning the direction with GetNeighbourRoadCount and finding Adjacent/Offset tiles would be very helpful.

Can't wait to try my hand at railways.

-R
User avatar
paullb
Traffic Manager
Traffic Manager
Posts: 129
Joined: 19 May 2008 13:11

Re: NoAI Branch - An AI Framework

Post by paullb »

I have looked at the Squirrel manual and there is just about no information there. What is there is VERY difficult to understand.
Finaldeath
Engineer
Engineer
Posts: 72
Joined: 09 Apr 2006 23:49
Location: UK
Contact:

Re: NoAI Branch - An AI Framework

Post by Finaldeath »

I think it lacks some examples but it's pretty much core programming material which doesn't require much in the way of examples (try/catch, loops, statements, returns, functions, classes...).

Will be worth expanding on the wiki in time though.
Finaldeath
User avatar
Zutty
Director
Director
Posts: 565
Joined: 22 Jan 2008 16:33

Re: NoAI Branch - An AI Framework

Post by Zutty »

paullb wrote:
I have looked at the Squirrel manual and there is just about no information there. What is there is VERY difficult to understand.
Yeah the Squirrel documentation is sparse. I agree with Finaldeath that it would be to perhaps expand the Wiki with our observations about Squirrel, so we can help each other understand it.

I haven't tried exception handling yet, but it says "Any value can be thrown.". I'd imagine you can so something like this...

Code: Select all

/* THIS IS JUST A SUGGESTION - I HAVE NO IDEA IF THIS WILL EVEN WORK! */

// Integer constants for reference - These should ideally be class members
EXC_N_TOO_SMALL <- 1
EXC_N_TOO_BIG <- 2

function NastyFunction(n) {
    if(n < 0) throw ::EXC_N_TOO_SMALL;
    if(n > 5) throw ::EXC_N_TOO_BIG;
    return n/2;
}

function InnocentBystander(in) {
    try {
        NastyFunction(in);
    } catch(exc) {
        if(exc  == ::EXC_N_TOO_SMALL) {
            print("Please choose a bigger number");
        } else if(exc  == ::EXC_N_TOO_BIG) {
            print("Please choose a smaller number");
        }
    }
}
Can anyone try this and let us know if it works?
PathZilla - A networking AI - Now with tram support.
User avatar
Zutty
Director
Director
Posts: 565
Joined: 22 Jan 2008 16:33

Re: NoAI Branch - An AI Framework

Post by Zutty »

I have a separate, simple question about the API.

I finally have my AI running services and turning a small profit. There's a long way to go yet, but its looking good! I'd also like to say a huge thank you to the devs for the NoAI branch! It really is a pleasure to work with. :)

My question is about orders. When I want to create a fleet of N vehicles I start with a prototype and then just clone it N-1 times with shared orders. The trouble is that the vehicles all go to the same station, which leads to poor utilisation of resources on the service as a whole. I'd like to be able to balance the load to make the service more efficient, but still be able to use shared orders. The way I do this when playing is just just tell half the vehicles to skip the first station, that way they keep the exact same list of orders.

Is there some way to tell a vehicle to skip an order with the API, and if not do you think it would be possible to implement it (I'd put in a feature request)?

Thanks.
PathZilla - A networking AI - Now with tram support.
TrueBrain
OpenTTD Developer
OpenTTD Developer
Posts: 1370
Joined: 31 May 2004 09:21

Re: NoAI Branch - An AI Framework

Post by TrueBrain »

Zutty wrote: Is there some way to tell a vehicle to skip an order with the API, and if not do you think it would be possible to implement it (I'd put in a feature request)?
AIVehicle.SkipToVehicleOrder(vehicle_id, order_id);

Reading is challange ;) Hehe :) Okay, it is not in the place you might expect, but still ;)
The only thing necessary for the triumph of evil is for good men to do nothing.
Locked

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 3 guests