Well, it should work, so the most logic reason I can think up: are you using the latest binaries? As that function is added not too long ago, so please make sure you have the latest binary (r13418, http://nightly.openttd.org/noai/files/).reylas wrote:Another question about IsWithinTownInfluence. If I use AIStation.IsWithinTownInfluence, it works. But If I use AITile.IsWithinTownInfluence, I get an index IsWithinTownInfluence does not exist.
Is that a bug or am I using it wrong.
Area.Validate(AITile.IsWithinTownInfluence,current_town);
Thanks,
MarkS
NoAI Branch - An AI Framework
Moderator: OpenTTD Developers
Re: NoAI Branch - An AI Framework
The only thing necessary for the triumph of evil is for good men to do nothing.
-
- Engineer
- Posts: 72
- Joined: 09 Apr 2006 23:49
- Location: UK
- Contact:
Re: NoAI Branch - An AI Framework
Worked on my AI, I suspect outdated binaries - it's assuming it's a variable name (with the dot, it looks like a list identifier of sorts).
Finaldeath
Re: NoAI Branch - An AI Framework
Question about AIOrder.AppendOrder. I want to have two order flags like below (which has the wrong syntax;
What is the correct syntax for more than one order flag? (like below, non-stop and full-load
AIOrder.AppendOrder(new_bus, this.stationOne.tile, [ AIOrder.AIOF_FULL_LOAD , AIOrder.AIOF_NON_STOP_INTERMEDIATE ] );
What is the correct syntax for more than one order flag? (like below, non-stop and full-load
AIOrder.AppendOrder(new_bus, this.stationOne.tile, [ AIOrder.AIOF_FULL_LOAD , AIOrder.AIOF_NON_STOP_INTERMEDIATE ] );
Re: NoAI Branch - An AI Framework
Well, if it works how flags normally work, you should be able to combine them with a binary or.
edit: yes, confirmed. so in your case
Code: Select all
FLAG1 | FLAG2
Code: Select all
AIOrder.AppendOrder(new_bus, this.stationOne.tile, AIOrder.AIOF_FULL_LOAD | AIOrder.AIOF_NON_STOP_INTERMEDIATE );
Re: NoAI Branch - An AI Framework
I thought I had tried that, but I guess I must have made a mistake, thanks for confirming.Roujin wrote:Well, if it works how flags normally work, you should be able to combine them with a binary or.
edit: yes, confirmed. so in your caseCode: Select all
FLAG1 | FLAG2
Code: Select all
AIOrder.AppendOrder(new_bus, this.stationOne.tile, AIOrder.AIOF_FULL_LOAD | AIOrder.AIOF_NON_STOP_INTERMEDIATE );
Re: NoAI Branch - An AI Framework
Ok, that was it. I was using an old binary. I know where to check now, so I will check that first.TrueLight wrote:Well, it should work, so the most logic reason I can think up: are you using the latest binaries? As that function is added not too long ago, so please make sure you have the latest binary (r13418, http://nightly.openttd.org/noai/files/).reylas wrote:Another question about IsWithinTownInfluence. If I use AIStation.IsWithinTownInfluence, it works. But If I use AITile.IsWithinTownInfluence, I get an index IsWithinTownInfluence does not exist.
Is that a bug or am I using it wrong.
Area.Validate(AITile.IsWithinTownInfluence,current_town);
Thanks,
MarkS
Next question. Is it possible to copy a List from one variable to another? I am building two TownLists then running some Valuators on them. I noticed that except for one Valuator, they are the same. In order not to run my custom function more than once, I would like to run it on one list, then copy that list to another variable like this:
local Town1 = AITownList();
local Town2 = AITownList();
(some Valuators on Town1)
Town2 = Town1;
This fails with no error (openTTD just goes into la la land). I have tried both with and without the declaration of Town2. What am I doing wrong?
Thanks,
MarkS.
Re: NoAI Branch - An AI Framework
Ok, here she is, RalphAI v1.0. At the moment it builds a bus network between towns, then sits there and rakes in the cash when they are all connected. Developed with NoAI r13326.
I am releasing this now mostly to force me to tidy up some bugs, and give a nice starting point for building further. I don't think there are any bugs that will crash the script, but you never know.
All code here is GPL, so feel free to poke/prod or add it to the wiki (though my binary heap/pathfinder are slooooow).
Known bugs:
-Will sometimes not complete a route when it encounters its own road, not sure why.
Todo:
-Think of an awesome name for my computerised transport overlord .
-Improve road pathfinding to favour existing roads and avoid unnecessary slopes/corners, add bridge/tunnel support.
-Adjust route selection to get a faster start, also play better with itself/other AIs/humans.
-Check for vehicles not making any money.
-Check for lots of passengers waiting at a station.
-Repay loan.
I am releasing this now mostly to force me to tidy up some bugs, and give a nice starting point for building further. I don't think there are any bugs that will crash the script, but you never know.
All code here is GPL, so feel free to poke/prod or add it to the wiki (though my binary heap/pathfinder are slooooow).
Known bugs:
-Will sometimes not complete a route when it encounters its own road, not sure why.
Todo:
-Think of an awesome name for my computerised transport overlord .
-Improve road pathfinding to favour existing roads and avoid unnecessary slopes/corners, add bridge/tunnel support.
-Adjust route selection to get a faster start, also play better with itself/other AIs/humans.
-Check for vehicles not making any money.
-Check for lots of passengers waiting at a station.
-Repay loan.
- Attachments
-
- RalphsAI.zip
- RalphsAI v1.0
- (16.57 KiB) Downloaded 201 times
Re: NoAI Branch - An AI Framework
This may work (not tested)reylas wrote:
Next question. Is it possible to copy a List from one variable to another? I am building two TownLists then running some Valuators on them. I noticed that except for one Valuator, they are the same. In order not to run my custom function more than once, I would like to run it on one list, then copy that list to another variable like this:
local Town1 = AITownList();
local Town2 = AITownList();
(some Valuators on Town1)
Town2 = Town1;
This fails with no error (openTTD just goes into la la land). I have tried both with and without the declaration of Town2. What am I doing wrong?
Thanks,
MarkS.
Code: Select all
local oldlist = AITownList();
oldlist.Valuate(blah blah blah);
oldlist.keepValue(blah);
local newlist = AIList();
newlist.AddList(oldlist);
-
- Engineer
- Posts: 70
- Joined: 05 Jun 2008 15:51
Re: NoAI Branch - An AI Framework
Hi, I am trying to create an AI for the TJIP contest, and I was wondering whether the NOAI framework allows writing to/reading from files? And if so, if someone could give me a short example?
Nunc dimittis servum tuum Domine secundum verbum tuum in pace
Re: NoAI Branch - An AI Framework
It doesn't allow that. The only thing you can write text to is de console (and the ingame ai debug panel). You can do that by using AILog.Info/Warning/Error.
-
- Engineer
- Posts: 70
- Joined: 05 Jun 2008 15:51
Re: NoAI Branch - An AI Framework
thanks for the reply. I guess I'll just have to use the script mechanism to output the console to a file, and copy-paste from there to my code.Yexo wrote:It doesn't allow that. The only thing you can write text to is de console (and the ingame ai debug panel). You can do that by using AILog.Info/Warning/Error.
In case you were wondering: I want to tune my AI by learning values for some of the decisions, and it would have been nice if I could just write them to some file and load them when needed.
Nunc dimittis servum tuum Domine secundum verbum tuum in pace
Re: NoAI Branch - An AI Framework
As of today (and in the nightly binary which is compiled in 2 hours), we proudly introduce to you: a library system. To give a bit insight information:
2 days ago we had a long talk how we should introduce a pathfinder in an 'extra' package, as I described in a few posts earlier. After some debating we came to the conclusion that there is absolutely no fair way to do that in C++. Although a pathfinder would operate faster in C++, the difference isn't big enough. So we decided to make a library framework in Squirrel, where people can put their general libraries, and an easy way to access them. I just committed exactly that. In the coming days / weeks / months, we will be adding some things we think is useful, under which some queues, but also a basic pathfinder, and more of such tools all AIs will want to use.
Some positive things about this library system: it doesn't force you to use any of them. You can always write your own. It allows multiple implementations of the same thing, like more than one pathfinder. It is portable. It is secure.
Now how does it work? I will write a wiki page about it soon. Basically:
in bin/ai/library there are dirs, 'categories'. In a category there is a dir, the library itself. In that dir is a file called 'library.nut', similar to 'info.nut'. It gives some basic information about the library, and is loaded on OpenTTD startup. The idea is equal to 'info.nut' in all ways, but you don't do: RegisterAI, you do: RegisterLibrary. Easy as pie
Now from your AI you can run:
Mind that it is 'import', not 'require'. You use 'require' to load your own local files.
The LocalName is how you want to class to be called in your script. This is useful, as there will be multiple implementation of the same thing. By changing one line, you can switch between those implementations, without changing everything in your AI. Also, it avoids a lot of name collision, and other problems of that order.
The version part makes sure you talk to library you expect. Say you made your AI for sets.priority_queue version 1, but in the library-dir of a user is version 2. Your AI will now fail to load on his machine, as there might be a mismatch in operations. This is an early problem detection, which hopefully avoids a lot of problems. So, make sure to fill in the right version
I think that sums it up pretty well.. any questions, feel free to ask. Sorry that I had to post this in this topic again, as it is becoming unreadable, but we are trying to get our own NoAI subforum, which hopefully makes this easier on all of us
(http://www.tt-forums.net/viewtopic.php?f=21&t=37891)
Ps: if any of you have a library you think should be included as official library (in SVN), please send it to me. Sending in any library for inclusion means you give up the rights of the library, and it becomes GPL copyrighted to OpenTTD.
2 days ago we had a long talk how we should introduce a pathfinder in an 'extra' package, as I described in a few posts earlier. After some debating we came to the conclusion that there is absolutely no fair way to do that in C++. Although a pathfinder would operate faster in C++, the difference isn't big enough. So we decided to make a library framework in Squirrel, where people can put their general libraries, and an easy way to access them. I just committed exactly that. In the coming days / weeks / months, we will be adding some things we think is useful, under which some queues, but also a basic pathfinder, and more of such tools all AIs will want to use.
Some positive things about this library system: it doesn't force you to use any of them. You can always write your own. It allows multiple implementations of the same thing, like more than one pathfinder. It is portable. It is secure.
Now how does it work? I will write a wiki page about it soon. Basically:
in bin/ai/library there are dirs, 'categories'. In a category there is a dir, the library itself. In that dir is a file called 'library.nut', similar to 'info.nut'. It gives some basic information about the library, and is loaded on OpenTTD startup. The idea is equal to 'info.nut' in all ways, but you don't do: RegisterAI, you do: RegisterLibrary. Easy as pie

Now from your AI you can run:
Code: Select all
import("categorie.name", "LocalName", version);
The LocalName is how you want to class to be called in your script. This is useful, as there will be multiple implementation of the same thing. By changing one line, you can switch between those implementations, without changing everything in your AI. Also, it avoids a lot of name collision, and other problems of that order.
The version part makes sure you talk to library you expect. Say you made your AI for sets.priority_queue version 1, but in the library-dir of a user is version 2. Your AI will now fail to load on his machine, as there might be a mismatch in operations. This is an early problem detection, which hopefully avoids a lot of problems. So, make sure to fill in the right version

I think that sums it up pretty well.. any questions, feel free to ask. Sorry that I had to post this in this topic again, as it is becoming unreadable, but we are trying to get our own NoAI subforum, which hopefully makes this easier on all of us

Ps: if any of you have a library you think should be included as official library (in SVN), please send it to me. Sending in any library for inclusion means you give up the rights of the library, and it becomes GPL copyrighted to OpenTTD.
The only thing necessary for the triumph of evil is for good men to do nothing.
Re: NoAI Branch - An AI Framework
Nice! I'm glad I never got around to actully posting the code now!! I'm going to need a little time to re-work the stuff I had planned to out in there then.TrueLight wrote:As of today (and in the nightly binary which is compiled in 2 hours), we proudly introduce to you: a library system. To give a bit insight information:
2 days ago we had a long talk how we should introduce a pathfinder in an 'extra' package, as I described in a few posts earlier. After some debating we came to the conclusion that there is absolutely no fair way to do that in C++. Although a pathfinder would operate faster in C++, the difference isn't big enough. So we decided to make a library framework in Squirrel, where people can put their general libraries, and an easy way to access them. I just committed exactly that. In the coming days / weeks / months, we will be adding some things we think is useful, under which some queues, but also a basic pathfinder, and more of such tools all AIs will want to use.
Some positive things about this library system: it doesn't force you to use any of them. You can always write your own. It allows multiple implementations of the same thing, like more than one pathfinder. It is portable. It is secure.
Now how does it work? I will write a wiki page about it soon. Basically:
in bin/ai/library there are dirs, 'categories'. In a category there is a dir, the library itself. In that dir is a file called 'library.nut', similar to 'info.nut'. It gives some basic information about the library, and is loaded on OpenTTD startup. The idea is equal to 'info.nut' in all ways, but you don't do: RegisterAI, you do: RegisterLibrary. Easy as pie
Now from your AI you can run:
Mind that it is 'import', not 'require'. You use 'require' to load your own local files.Code: Select all
import("categorie.name", "LocalName", version);
The LocalName is how you want to class to be called in your script. This is useful, as there will be multiple implementation of the same thing. By changing one line, you can switch between those implementations, without changing everything in your AI. Also, it avoids a lot of name collision, and other problems of that order.
The version part makes sure you talk to library you expect. Say you made your AI for sets.priority_queue version 1, but in the library-dir of a user is version 2. Your AI will now fail to load on his machine, as there might be a mismatch in operations. This is an early problem detection, which hopefully avoids a lot of problems. So, make sure to fill in the right version
I think that sums it up pretty well.. any questions, feel free to ask. Sorry that I had to post this in this topic again, as it is becoming unreadable, but we are trying to get our own NoAI subforum, which hopefully makes this easier on all of us(http://www.tt-forums.net/viewtopic.php?f=21&t=37891)
Ps: if any of you have a library you think should be included as official library (in SVN), please send it to me. Sending in any library for inclusion means you give up the rights of the library, and it becomes GPL copyrighted to OpenTTD.
PathZilla - A networking AI - Now with tram support.
Re: NoAI Branch - An AI Framework
Just a quick one for the devs... I'm getting inconsistent results from AITile.IsBuildable() on coast tiles. This really feels like a bug to me, as the result is unpredictable. Mostly it returns false for any land tile that borders with water, but sometimes it returns true for no apparent reason. There can be a long stretch of coast tiles in a line, and one out of twenty will be buildable at random!
Ideally I'd like IsBuildable() to return true for coast tiles with nothing on them (it would be helpful for bridge building), but just having consistent results will be a start!
Is this a bug? Can we have it fixed? Is it already fixed?! (I'm still using r13326)
Thanks.
As for libraries, I've only just noticed that there are standard libs already. To be perfectly honest I don't know what the value will be in having 20 separate binary heap implementations made available, so I probably won't bother posting my own code anymore! Plus I'm not going to re-engineer my pathfinder to use the library code at this stage, so there wouldn't be much point in me posting my pathfinder either (and frankly, A* is A* regardless of who wrote it!!). I might post some other parts of my AI in the library format (maybe some of the graph stuff I'm working on) if people are interested, but that'll suit me for now. You'd all probably be horrified by my Java-esque style of coding anyway!!
I use camelCase for variables and ExtremelyExplicitMethodNames().
Ideally I'd like IsBuildable() to return true for coast tiles with nothing on them (it would be helpful for bridge building), but just having consistent results will be a start!
Is this a bug? Can we have it fixed? Is it already fixed?! (I'm still using r13326)
Thanks.
As for libraries, I've only just noticed that there are standard libs already. To be perfectly honest I don't know what the value will be in having 20 separate binary heap implementations made available, so I probably won't bother posting my own code anymore! Plus I'm not going to re-engineer my pathfinder to use the library code at this stage, so there wouldn't be much point in me posting my pathfinder either (and frankly, A* is A* regardless of who wrote it!!). I might post some other parts of my AI in the library format (maybe some of the graph stuff I'm working on) if people are interested, but that'll suit me for now. You'd all probably be horrified by my Java-esque style of coding anyway!!

PathZilla - A networking AI - Now with tram support.
-
- Engineer
- Posts: 70
- Joined: 05 Jun 2008 15:51
Re: NoAI Branch - An AI Framework
I noticed that the game directly crashes if you try to reload your AI in r13442.
The same happened in r13355 but only after a few "reloads" (in the same game). Also if the "newgame" command was issued on the console then the game crashed after "start_ai ....".
(Is this the correct place to post this kind of stuff?)
The same happened in r13355 but only after a few "reloads" (in the same game). Also if the "newgame" command was issued on the console then the game crashed after "start_ai ....".
(Is this the correct place to post this kind of stuff?)
Nunc dimittis servum tuum Domine secundum verbum tuum in pace
Re: NoAI Branch - An AI Framework
You can report bugs here. I'd report my issue above, but I'm not sure if its expected behaviour or not!wilco_moerman wrote:I noticed that the game directly crashes if you try to reload your AI in r13442.
The same happened in r13355 but only after a few "reloads" (in the same game). If the "newgame" command was issued on the console then the game crashed when "start_ai ...." was used.
(Is this the correct place to post this kind of stuff?)
PathZilla - A networking AI - Now with tram support.
Re: NoAI Branch - An AI Framework
As Zutty pointed out, you can report it on flyspray. However, if you post it here it'll get read. About the first bug: get the lastest version (can you compile yourself?) and try if the game still crashes.wilco_moerman wrote:I noticed that the game directly crashes if you try to reload your AI in r13442.
The same happened in r13355 but only after a few "reloads" (in the same game). Also if the "newgame" command was issued on the console then the game crashed after "start_ai ....".
(Is this the correct place to post this kind of stuff?)
The issue about start_ai after a new_game command is known and was fixed in r13454. Thanks for reporting and please keep posting any bugs here or on flyspray. If you want a fast reaction or follow latest development, irc is a good place (#openttd.noai @OFTC).
-
- Engineer
- Posts: 70
- Joined: 05 Jun 2008 15:51
Re: NoAI Branch - An AI Framework
I can't compile here, but I thought I was already using the latest NOAI-binaries. I have tried it with r13442 (latest) and two older ones. All of them have the same error.Yexo wrote:As Zutty pointed out, you can report it on flyspray. However, if you post it here it'll get read. About the first bug: get the lastest version (can you compile yourself?) and try if the game still crashes.wilco_moerman wrote:I noticed that the game directly crashes if you try to reload your AI in r13442.
The same happened in r13355 but only after a few "reloads" (in the same game). Also if the "newgame" command was issued on the console then the game crashed after "start_ai ....".
(Is this the correct place to post this kind of stuff?)
OK, any idea when it will apear on http://nightly.openttd.org/noai/scoreboard.php? Because that is still r13442 instead of r13454The issue about start_ai after a new_game command is known and was fixed in r13454.
maybe I'll do that.Thanks for reporting and please keep posting any bugs here or on flyspray. If you want a fast reaction or follow latest development, irc is a good place (#openttd.noai @OFTC).
I wanted to start a server with restart_game_year = 2007 and starting in 1998 (for the TJIP challenge) and just let it run all night for testing. But if the game crashes after each "newgame" that won't work.
I am trying to implement an AI using a neural network, but networks need a lot of runs to train. That is why I need to start new games and save and load data. The network needs to be stored and loaded between each run. The saving works by using the console to output a script. I'll try to do the loading by modifying the .nut-files automatically using some Java-programming. I'll just get the parts I need from the console-output and substitute them into the .nut-file.
It might be ugly, but as far as I can see it's the only way to transfer information between successive AI's.
Nunc dimittis servum tuum Domine secundum verbum tuum in pace
Re: NoAI Branch - An AI Framework
Nightlies run every night at 1800 CEST ... and the commits are made after thatwilco_moerman wrote: (..)
OK, any idea when it will apear on http://nightly.openttd.org/noai/scoreboard.php? Because that is still r13442 instead of r13454


Avoid FlySpray, I don't read thatwilco_moerman wrote:maybe I'll do that.Thanks for reporting and please keep posting any bugs here or on flyspray. If you want a fast reaction or follow latest development, irc is a good place (#openttd.noai @OFTC).


It most likely iswilco_moerman wrote: I wanted to start a server with restart_game_year = 2007 and starting in 1998 (for the TJIP challenge) and just let it run all night for testing. But if the game crashes after each "newgame" that won't work.
I am trying to implement an AI using a neural network, but networks need a lot of runs to train. That is why I need to start new games and save and load data. The network needs to be stored and loaded between each run. The saving works by using the console to output a script. I'll try to do the loading by modifying the .nut-files automatically using some Java-programming. I'll just get the parts I need from the console-output and substitute them into the .nut-file.
It might be ugly, but as far as I can see it's the only way to transfer information between successive AI's.



The only thing necessary for the triumph of evil is for good men to do nothing.
-
- Engineer
- Posts: 70
- Joined: 05 Jun 2008 15:51
Re: NoAI Branch - An AI Framework
I'm counting the secondsTrueLight wrote:Nightlies run every night at 1800 CEST ... and the commits are made after thatwilco_moerman wrote: (..)
OK, any idea when it will apear on http://nightly.openttd.org/noai/scoreboard.php? Because that is still r13442 instead of r13454So check back in ... 10 minutes
![]()

yeah I read the topic on that. Seems only logical.TrueLight wrote: Avoid FlySpray, I don't read thatI hope to have a subforum soon, then this will get a bit more organized
![]()
at least as long as NOAI doesn't implement any file IOTrueLight wrote: It most likely is![]()

I'll let you know. I have successfully used a NN together with reinforcement learning for my master's thesis, so I thought I would give it a try.TrueLight wrote: Good luck with using a NN for this problem ... I wonder if it ever leads to anythingCan't wait to see if it does
Nunc dimittis servum tuum Domine secundum verbum tuum in pace
Who is online
Users browsing this forum: No registered users and 7 guests