Speed issues

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

User avatar
Dustin
Transport Coordinator
Transport Coordinator
Posts: 272
Joined: 07 Dec 2005 19:22

Re: Speed issues

Post by Dustin »

Blustuff wrote:
Yexo wrote:But I never coded anything for nail, so your best bet is to ask either TrueBrain or Rubidium (and maybe glx/smatz).
I spoke with TrueBrain and about this project:
TrueBrain wrote:Replacing Squirrel at this stage in OpenTTD is almost impossible, because people use the full set, and any replacement will start out with a very small set.
It may not be a replacement at the begining. The important thing is that it would be a replacement at some point of the developpement. I think that even if I were alone on such a project it would take about one year to get a full replacement for Squirrel. All I need is some brainstorming about ideas about some issues.
I saw some mention of moving from Squirrel to Nail. What would be the advantage? I don't know a thing about Nail. Squirrel seemed pretty reasonable. Maybe because I have a preference for C like OO languages. (Perl and C# are my favorites). I used LUA once apon a time and found it to be a bit of a hassle to code in.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Speed issues

Post by Zuu »

One of the features of NAIL is that it will have almost 100% syntax compatibility with Squirrel. (Semicolons are mandatory in NAIL where they are not in Squirrel)

Squirrel has some problems with scoping and destroying objects as soon as they run out of scope. This sometimes causes problems with AI*Mode.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Blustuff
Engineer
Engineer
Posts: 112
Joined: 21 Aug 2008 09:37
Location: France

Re: Speed issues

Post by Blustuff »

Zuu wrote:Squirrel has some problems with scoping and destroying objects as soon as they run out of scope. This sometimes causes problems with AI*Mode.
Well the idea of AI*Mode is very dangerous. A variable can be freed as soon as it is not alive and this as nothing to do with scoping. A garbage collector could decide to free the variable as soon as possible or on the contrary whenever the memory need to be freed. This is a bad idea to rely on the Garbage Collector internal.

Dustin wrote:What would be the advantage?
That's roughly the question I asked. Here is the answer.
TrueBrain wrote:Squirrel is a nice piece of software, but the coding style is far from optimal. Also, nobody in our team has any insight knowledge of Squirrel, and the complete lack of documentation in the code makes it really hard to follow what the original author means with a given statement. So it was decided that it would be much better if we would write our own. This in theory is not such a big job, just we ran into a few issues (we wanted more than Squirrel offered ;)).
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Speed issues

Post by Yexo »

Zuu wrote:Squirrel has some problems with scoping and destroying objects as soon as they run out of scope. This sometimes causes problems with AI*Mode.
Those problems should be fixed now. If sometimes goes wrong now the AI is killed, not OpenTTD.
Blustuff wrote:Well the idea of AI*Mode is very dangerous. A variable can be freed as soon as it is not alive and this as nothing to do with scoping.
This has everything to do with scoping.
A garbage collector could decide to free the variable as soon as possible or on the contrary whenever the memory need to be freed. This is a bad idea to rely on the Garbage Collector internal.
That's why we don't rely on the garbage collector but free every item as soon as it's cleared.
Blustuff
Engineer
Engineer
Posts: 112
Joined: 21 Aug 2008 09:37
Location: France

Re: Speed issues

Post by Blustuff »

Yexo wrote:This has everything to do with scoping.
No, a variable can be alive outside its scope and dead inside.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 2 guests