Costum AI's

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

Post Reply
nWkobi
Engineer
Engineer
Posts: 4
Joined: 11 Feb 2010 10:29

Costum AI's

Post by nWkobi »

hi

is there a way to create costum AI's of my own in OpenTTD?

havent seen a thing abput it, so sorry if it already exists(the topic).
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Costum AI's

Post by Zuu »

Please check our FAQ: http://wiki.openttd.org/NoAI_Forum_FAQ

It is linked to as a sticky in this forum.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
nWkobi
Engineer
Engineer
Posts: 4
Joined: 11 Feb 2010 10:29

Re: Costum AI's

Post by nWkobi »

i have read that, but it didnt answer my question...
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Costum AI's

Post by Alberth »

What about question 1.6?

I think it answers your question, since to have your own custom AI, you have to write one.

If that is not what you mean with "create costum AI's of my own", then please explain what you do mean with that phrase?
nWkobi
Engineer
Engineer
Posts: 4
Joined: 11 Feb 2010 10:29

Re: Costum AI's

Post by nWkobi »

ok i'll try.

what i meant was - is there and add-on that makes it possible to edit /create an AI for the game? something like the scenario editor,maybe.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Costum AI's

Post by planetmaker »

Yes: any text editor of your choice. But I guess that doesn't really qualify as 'add-on'.
nWkobi
Engineer
Engineer
Posts: 4
Joined: 11 Feb 2010 10:29

Re: Costum AI's

Post by nWkobi »

what do u mean by 'text editor'?
User avatar
CommanderZ
Tycoon
Tycoon
Posts: 1872
Joined: 07 Apr 2008 18:29
Location: Czech Republic
Contact:

Re: Costum AI's

Post by CommanderZ »

You are obviously missing the fact, that you must program the AI, its not like there is some nice graphical drag and drop editor. The AI is just a piece of program code.

Text editor is any program that can edit text - for example notepad or word.
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: Costum AI's

Post by Brumi »

I'm developing my AI using plain notepad... :mrgreen:

EDIT: corrected ugly grammar mistake
Last edited by Brumi on 15 Feb 2010 14:27, edited 1 time in total.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Costum AI's

Post by Zuu »

There is editors like eclipse or vim that can help you a little bit by completing words/code. Though it still comes down to the fact that you need to know programming fairly well (or be very motivated beginner programmer) in order to make an AI. The tools can't help you understand programming, just make programming a bit faster and more convenient.

To take an example, PAXLink is about 5 000 lines of code. Compared to OpenTTD that is not much, but it is still not something you write in an afternoon or two.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
SummerBulb
Engineer
Engineer
Posts: 24
Joined: 06 Feb 2010 22:12

Re: Costum AI's

Post by SummerBulb »

Zuu wrote:There is editors like eclipse... that can help you a little bit by completing words/code.
Sorry to intrude, but does anyone knoe why my Eclipse doesn't complete any words and/or indent my code.

Yes, i am using the squirrel plugin.

Thanks,
SummerBulb
User avatar
Zutty
Director
Director
Posts: 565
Joined: 22 Jan 2008 16:33

Re: Costum AI's

Post by Zutty »

SummerBulb wrote:
Zuu wrote:There is editors like eclipse... that can help you a little bit by completing words/code.
Sorry to intrude, but does anyone knoe why my Eclipse doesn't complete any words and/or indent my code.

Yes, i am using the squirrel plugin.

Thanks,
SummerBulb
SQDEV cant complete members from the NoAI API, or from object instances (since Squirrel is not stringly typed).

The only way to have something autocompleted (Ctrl-Space) is if it is a static member of a class defined in your AI, from a static context.

Code: Select all

class Foo {
  static memberA = "This is static"
  memberB = null
  function bar(b) {
    this.memberB = b
  }
}

local x = Foo()
x.<CTRL-SPACE> <-- Nothing happens
Foo.<CTRL-SPACE> <-- Autocomplete window shows [ memberA, bar() ]
PathZilla - A networking AI - Now with tram support.
SummerBulb
Engineer
Engineer
Posts: 24
Joined: 06 Feb 2010 22:12

Re: Costum AI's

Post by SummerBulb »

Wow, looks like you know it all.

Thanks. :bow:
Blustuff
Engineer
Engineer
Posts: 112
Joined: 21 Aug 2008 09:37
Location: France

Re: Costum AI's

Post by Blustuff »

Zutty wrote:SQDEV cant complete members from the NoAI API, or from object instances (since Squirrel is not stringly typed).

The only way to have something autocompleted (Ctrl-Space) is if it is a static member of a class defined in your AI, from a static context.
Even with dynamically typed language, you can do static analysis to discover types and enable auto completion. What you said about static methods is true so you can use some trick to fool SQDev : create some file defining the AI* classes with their static methods and constants. SQDev believe the file is included in the project and then use it to autocomplete.
SummerBulb
Engineer
Engineer
Posts: 24
Joined: 06 Feb 2010 22:12

Re: Costum AI's

Post by SummerBulb »

Blustuff wrote:
Zutty wrote:SQDEV cant complete members from the NoAI API, or from object instances (since Squirrel is not stringly typed).

The only way to have something autocompleted (Ctrl-Space) is if it is a static member of a class defined in your AI, from a static context.
Even with dynamically typed language, you can do static analysis to discover types and enable auto completion. What you said about static methods is true so you can use some trick to fool SQDev : create some file defining the AI* classes with their static methods and constants. SQDev believe the file is included in the project and then use it to autocomplete.
That sounds great, but also sounds like A LOT of work.

|wish|i wonder if i could find a file like that somewhere |endwish| :wink:

I just might go ahead and do that, in the end...

SummerBulb
User avatar
CommanderZ
Tycoon
Tycoon
Posts: 1872
Joined: 07 Apr 2008 18:29
Location: Czech Republic
Contact:

Re: Costum AI's

Post by CommanderZ »

If it is has done it yet, you can do it quite easily by copying the vertical lists from the doxygen html help. It still needs some manual cleaning, but it simplifies the work a lot.
Blustuff
Engineer
Engineer
Posts: 112
Joined: 21 Aug 2008 09:37
Location: France

Re: Costum AI's

Post by Blustuff »

I did it for some classes, I could upload it. There is still a lot of work to do to complete this file.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 26 guests