Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Wed Dec 12, 2018 1:25 pm

All times are UTC




Post new topic  Reply to topic  [ 41 posts ]  Go to page 1 2 3 Next

What do you think
Usefully 100%  100%  [ 23 ]
Useless 0%  0%  [ 0 ]
Total votes: 23
Author Message
PostPosted: Sun Aug 02, 2009 1:35 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Fri Dec 19, 2008 5:03 am
Posts: 313
Location: Indonesia
The Idea :
>> Common library that would be useful for all AI writers. This should be written by, from and for all AI writers.

Scope :
>> Every problem that can be solved using squirrel, included but not limited to Math, String, even extension to current API (tile, vehicle, cargo, industry etc..)

Contributors :
>> All AI writer

Administrator
>> Yexo, fanioz

Registered Developer
>> Zutty, Zuu

Every body could register here :D

_________________
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image


Last edited by fanioz on Sat Jun 26, 2010 10:17 am, edited 10 times in total.

Top
   
 Post subject: Re: AI Common Library
PostPosted: Sun Aug 02, 2009 1:37 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Fri Dec 19, 2008 5:03 am
Posts: 313
Location: Indonesia
Project Host :
  • Lib common : Series of library that contain assorted function that hopefully to be useful for many AI writers.
  • Lib List : An improvement of API - AIList, which can call do command inside valuator and several other functions
  • Lib Tile : Improvement on API - AITile functions
  • Lib String : Provide string handling
  • Lib Direction : Provide direction handling for AI


License : GPl 2.0

Download Links (Bananas)

Documentation
Check Out here

Download Links (Non-Bananas)


Attachments:
AILib.Tile.1.tar [10 KiB]
Downloaded 609 times

_________________
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image


Last edited by fanioz on Thu Aug 19, 2010 3:33 am, edited 17 times in total.
Top
   
 Post subject: Re: AI Common Library
PostPosted: Sun Aug 02, 2009 1:37 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Fri Dec 19, 2008 5:03 am
Posts: 313
Location: Indonesia
Library Tester

It's here to test AI Common Libraries Project functions.

Make sure you have the latest Libraries in 2nd post.
Put Test.tar inside your /ai folder
Load Lib_Test.sav in OpenTTD (nightly)
Look at AI's Log and Game Map
:D

edit : note that AILib.Tile test wasn't included yet


Attachments:
File comment: Saved Test Game for Library Tester
Lib_Test.sav [12.12 KiB]
Downloaded 144 times
test.tar [20 KiB]
Downloaded 123 times

_________________
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image


Last edited by fanioz on Wed Jul 14, 2010 5:12 am, edited 7 times in total.
Top
   
 Post subject: Re: AI Common Library
PostPosted: Sun Aug 02, 2009 6:46 pm 
Offline
Tycoon
Tycoon

Joined: Thu Dec 20, 2007 12:49 pm
Posts: 3653
fanioz wrote:
pload this to Bananas)
>> mmmmm............ I think Yexo :D
If you want me to do it, that's fine, but I think it should be the general maintainer of the library (I think we should appoint someone who is responsible for merging patching and keeping the latest version), and why would that not be you, fanioz? After all, you've taken the time to start it.

Let's be very clear from the start that this library is GPL v2 (I hope you all agree :p).

I've looked through your files, and they seems to be nice.Some comments:
1. Since r17043 it's possible to subclass API classes without problems, so you don't have to wrap all AIAbstractList functions.
2. AbstractList::SetItemValue returns ar without ever defining it.
3. Did you test CountIfRemoveAboveValue/CountIfRemoveValue? I'm not sure, but I think that "local tmp = this._list;" just makes another reference to the same list, so you still remove the items from the original list. Easiest solution (untested):
Code:
local tmp = AIList().AddList(this._list);


Top
   
 Post subject: Re: AI Common Library
PostPosted: Sun Aug 02, 2009 7:06 pm 
Offline
Engineer
Engineer

Joined: Thu Aug 21, 2008 9:37 am
Posts: 112
Location: France
Yexo wrote:
I'm not sure, but I think that "local tmp = this._list;" just makes another reference to the same list, so you still remove the items from the original list.


That's absolutely right. Since copy of objects is a common operation, Squirrel use the keyword "clone" to explicitely copy an objet. Note that it only clone one level, subobjects are not cloned. Hopefully this would work :

Code:
local tmp = clone this._list;


but I think it won't since there probably no _cloned metamethod for AIAbstractList which is able to clone internal representation of the list. The solution of Yexo seems to be the best.


Top
   
 Post subject: Re: AI Common Library
PostPosted: Mon Aug 03, 2009 1:02 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Fri Dec 19, 2008 5:03 am
Posts: 313
Location: Indonesia
Yexo wrote:
If you want me to do it, that's fine, but I think it should be the general maintainer of the library (I think we should appoint someone who is responsible for merging patching and keeping the latest version), and why would that not be you, fanioz? After all, you've taken the time to start it.

This will go to vote to ... :D I believe you will be the winner. :mrgreen:

Yexo wrote:
Let's be very clear from the start that this library is GPL v2 (I hope you all agree :p).

Of course yes.
Yexo wrote:
I've looked through your files, and they seems to be nice.Some comments:
1. Since r17043 it's possible to subclass API classes without problems, so you don't have to wrap all AIAbstractList functions.

I didn't know that, will try it to night :)

Yexo wrote:
2. AbstractList::SetItemValue returns ar without ever defining it.

Typos .. :oops:
Yexo wrote:
3. Did you test CountIfRemoveAboveValue/CountIfRemoveValue? I'm not sure, but I think that "local tmp = this._list;" just makes another reference to the same list, so you still remove the items from the original list. Easiest solution (untested):
Code:
local tmp = AIList().AddList(this._list);

Thanks for better solution :D

_________________
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image


Top
   
 Post subject: Re: AI Common Library
PostPosted: Mon Aug 03, 2009 1:06 pm 
Offline
Tycoon
Tycoon

Joined: Thu Dec 20, 2007 12:49 pm
Posts: 3653
fanioz wrote:
Yexo wrote:
I've looked through your files, and they seems to be nice.Some comments:
1. Since r17043 it's possible to subclass API classes without problems, so you don't have to wrap all AIAbstractList functions.

I didn't know that, will try it to night :)

r17043 was committed after you posted your library, so it wasn't possible before :p (guess what was the reason for that commit)


Top
   
 Post subject: Re: AI Common Library
PostPosted: Tue Aug 04, 2009 1:21 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Fri Dec 19, 2008 5:03 am
Posts: 313
Location: Indonesia
Yexo wrote:
r17043 was committed after you posted your library, so it wasn't possible before :p (guess what was the reason for that commit)

However... Thanks :D (thats happen too, long time ago :D )

==========
Okay All, :D
Have no time yet to generate html documentation now, please read the code instead, or read below :D

After fixing things around, named this as RC1 version, wich is contain :

1. AILib.Common :
--function ACall() an acall replacement to allow you execute do command with array as arguments
--function GetVersion() return the table of current version of OTTD ran
--Class AIRoadTypeList() to get available Road type in game as AIList
--Class AIPlaneTypeList() to get all plane type as AIList
(the last two class above would be removed if API made them)

2. AILib.List :
--extends AIList() with several new function
--constructor argument is now optional.
--Not overriding Valuate -- not changed
--function DoValuate -- if what you want is to execute do command inside valuator. It need "this" as argument
--Integrating AITileList() methode with new implementation.
--Emulate Queue mode (Pop, Peek, Push) <- ambiguous isn't ..?

3.AILib.Tile ::
-- extends AITile. Right now only two function available
-- Tile.IsMine() to check if I am the owner
-- Tile.IsCompetitorTile() to check if my competitor owned that.

However, my english is not that good, I really need your correction for such a function names, or documentation to make this library self-descriptive.

Another question :: Which is better, Make this all as single library or separate them for each category. ?

_________________
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image


Top
   
 Post subject: Re: AI Common Library
PostPosted: Tue Aug 04, 2009 1:30 pm 
Offline
Tycoon
Tycoon

Joined: Thu Dec 20, 2007 12:49 pm
Posts: 3653
I haven't looked through your new source code yet, but your overview of functions is nice.
fanioz wrote:
However, my english is not that good, I really need your correction for such a function names, or documentation to make this library self-descriptive.
All function names look ok.

Quote:
Another question :: Which is better, Make this all as single library or separate them for each category. ?

I'm in favor of making a different library for each class you have above.


Top
   
 Post subject: Re: AI Common Library
PostPosted: Tue Aug 04, 2009 1:51 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon Apr 19, 2004 8:09 pm
Posts: 1732
Location: Sweden
fanioz wrote:
-- Tile.IsMine() to check if I am the owner

My first thought was that this would check if there was a mining industry on the tile. I'm playing too much Civilization (and clones), probably :-)

Quote:
-- Tile.IsCompetitorTile() to check if my competitor owned that.


To be consistent, I think the names should be:

- Tile.IsMyTile() and Tile.IsCompetitorTile()

or

- Tile.IsMine() and Tile.IsCompetitors()

_________________
Image
Swedish trains * Swedish Town Names * BlockCAD * The GRFMaker Community Page


Top
   
 Post subject: Re: AI Common Library
PostPosted: Tue Aug 04, 2009 1:54 pm 
Offline
Tycoon
Tycoon

Joined: Thu Dec 20, 2007 12:49 pm
Posts: 3653
AndersI wrote:
To be consistent, I think the names should be:

- Tile.IsMyTile() and Tile.IsCompetitorTile()
or
- Tile.IsMine() and Tile.IsCompetitors()

I prefer the first option (IsMyTile/IsCompetitorTile)


Top
   
 Post subject: Re: AI Common Library
PostPosted: Wed Aug 05, 2009 9:20 am 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Fri Dec 19, 2008 5:03 am
Posts: 313
Location: Indonesia
Yexo wrote:
AndersI wrote:
To be consistent, I think the names should be:

- Tile.IsMyTile() and Tile.IsCompetitorTile()
or
- Tile.IsMine() and Tile.IsCompetitors()

I prefer the first option (IsMyTile/IsCompetitorTile)


Change in AILib.Tile


changed function name :
Tile.IsMine() => Tile.IsMyTile();

Added code : From this thread
Code:
/**
 * Gets the TileIndex relatively from given offset.
 * @param tile Start tile index
 * @param x The X coordinate.
 * @param y   The Y coordinate.
 * @return Tile index
 */
function Tile::AddOffset(tile, x, y)
{
   /* pre-condition */
   if (!AIMap.IsValidTile(tile)) return -1;
   local tx = AIMap.GetTileX(tile) + x;
   local ty = AIMap.GetTileY(tile) + y;
   if (tx < 1) return -1;
   if (ty < 1) return -1;
   if (tx > (AIMap.GetMapSizeX() - 2)) return -1;
   if (ty > (AIMap.GetMapSizeY() - 2)) return -1;
   /* ==== */
   return AIMap.GetTileIndex(tx, ty);
}


=====
Please look at the precondition, is the behaviour of AddOffset() function is ok?
also there is no INVALID_TILE enumeration, so I've decided to use -1 instead. Which is should be an Invalid Tile :D

_________________
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image


Top
   
 Post subject: Re: AI Common Library
PostPosted: Wed Aug 05, 2009 9:49 am 
Offline
Director
Director
User avatar

Joined: Tue Jan 22, 2008 4:33 pm
Posts: 565
This is quite a good idea. Are any of the functions in here of use to you?...

http://code.google.com/p/ottd-noai-path ... common.nut

_________________
PathZilla - A networking AI - Now with tram support.


Top
   
 Post subject: Re: AI Common Library
PostPosted: Wed Aug 05, 2009 9:56 am 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Fri Dec 19, 2008 5:03 am
Posts: 313
Location: Indonesia
Zutty wrote:
This is quite a good idea. Are any of the functions in here of use to you?...

http://code.google.com/p/ottd-noai-path ... common.nut

Wow.......... :o very much functions there, i think I should divide them for each category. Thanks :mrgreen:

_________________
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image


Top
   
 Post subject: Re: AI Common Library
PostPosted: Thu Aug 06, 2009 5:38 pm 
Offline
Engineer
Engineer

Joined: Fri Oct 12, 2007 2:07 pm
Posts: 87
The idea of such library is really great, it'll be very useful.
After reading this topic, I think there is thing in my AI, that could be in library (i.e. if it were in some library, I would not write it, and would be happy).
For own AI(yeah, I'm writting one) I've made a small event system, and today rewrited it to a library form.
Hope you find it useful.


Attachments:
File comment: Libary with event system code.
Lib.Event.1.tar [6 KiB]
Downloaded 114 times
File comment: How to use example.
Lib.Event.1.example.txt [1.73 KiB]
Downloaded 131 times
Top
   
 Post subject: Re: AI Common Library
PostPosted: Fri Aug 07, 2009 2:17 am 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Fri Dec 19, 2008 5:03 am
Posts: 313
Location: Indonesia
ac84 wrote:
The idea of such library is really great, it'll be very useful.
After reading this topic, I think there is thing in my AI, that could be in library (i.e. if it were in some library, I would not write it, and would be happy).
For own AI(yeah, I'm writting one) I've made a small event system, and today rewrited it to a library form.
Hope you find it useful.

:D thanks for contributing. It seems interesting, although I've only look at example

_________________
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image


Top
   
 Post subject: Re: AI Common Library
PostPosted: Fri Aug 07, 2009 4:31 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Jun 06, 2007 9:07 pm
Posts: 1710
Location: Czech Republic
Yexo wrote:
Let's be very clear from the start that this library is GPL v2 (I hope you all agree :p).


Errr .... could it be GPL v2+? GPL v3 / GPL v3+ is gaining popularity, so unless someone is opposed to GPL v3, maybe we should stick to v2+ to allow combinging with GPL v3 code.

_________________
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)


Top
   
 Post subject: Re: AI Common Library
PostPosted: Fri Aug 07, 2009 5:25 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Mar 06, 2004 11:51 pm
Posts: 1494
Location: The sunny side of Alps
Really nice work, fanioz.
Vote for GPL: I say GPL v2. Why would anyone even want v3?

_________________
NewGRF: Oil Wells in Temperate terrain now can Increase production, Better vehicle names, Use-able default aircraft, Oil Rig for Snowland and Desert, Speed for Suspension bridges.
Patches (OpenTTD): Improved smooth_economy [in trunk], More (diesel) smoke [in trunk], Realistic_acceleration finetune.

Keep 'em rollin'!


Top
   
 Post subject: Re: AI Common Library
PostPosted: Fri Aug 07, 2009 6:22 pm 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Thu Feb 09, 2006 7:15 pm
Posts: 3815
Yexo wrote:
Let's be very clear from the start that this library is GPL v2 (I hope you all agree :p).
I disagree with making it GPLv2; GPLv2 would mean that linking to it makes your AI GPLv2 too. I'd go for LGPLv2, which is the generally accepted 'GPLv2' for libraries.

Bilbo wrote:
GPL v2+?
I dislike that; if Mr. Stallman writes e.g. GPL v4 that gives someone all rights to do with the stuff what you want to do, like claim it as your own, your library would be rereleasable under those rules. Not sure where you want that.


Top
   
 Post subject: Re: AI Common Library
PostPosted: Fri Aug 07, 2009 10:14 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Jun 06, 2007 9:07 pm
Posts: 1710
Location: Czech Republic
And what about GPL v2 or v3 (without possibility of 4+)? The problem with GPL2 and GPL3 is that while they are essentially very similar, they are incompatible. And many new projects choose GPL3 or GPL3+ to start. So combining GPL2 and GPL3 code is impossible. LGPL2 would solve that too, though :)

_________________
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 41 posts ]  Go to page 1 2 3 Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2018 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2018.
Hosted by Zernebok Hosting.