AI Common Libraries - (now with AILib.Direction)
Moderator: OpenTTD Developers
AI Common Libraries - (now with AILib.Direction)
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
>> 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
Last edited by fanioz on 26 Jun 2010 10:17, edited 10 times in total.
Re: AI Common Library
Project Host :
License : GPl 2.0
Download Links (Bananas) Documentation
Check Out here
Download Links (Non-Bananas)
- 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 789 times
Last edited by fanioz on 19 Aug 2010 03:33, edited 17 times in total.
Re: AI Common Library
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
edit : note that AILib.Tile test wasn't included yet
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
edit : note that AILib.Tile test wasn't included yet
- Attachments
-
- Lib_Test.sav
- Saved Test Game for Library Tester
- (12.12 KiB) Downloaded 282 times
-
- test.tar
- (20 KiB) Downloaded 344 times
Last edited by fanioz on 14 Jul 2010 05:12, edited 7 times in total.
Re: AI Common Library
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.fanioz wrote:pload this to Bananas)
>> mmmmm............ I think Yexo
Let's be very clear from the start that this library is GPL v2 (I hope you all agree ).
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: Select all
local tmp = AIList().AddList(this._list);
Re: AI Common Library
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 :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.
Code: Select all
local tmp = clone this._list;
Re: AI Common Library
This will go to vote to ... I believe you will be the winner.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.
Of course yes.Yexo wrote: Let's be very clear from the start that this library is GPL v2 (I hope you all agree ).
I didn't know that, will try it to nightYexo 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.
Typos ..Yexo wrote: 2. AbstractList::SetItemValue returns ar without ever defining it.
Thanks for better solutionYexo 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: Select all
local tmp = AIList().AddList(this._list);
Re: AI Common Library
r17043 was committed after you posted your library, so it wasn't possible before (guess what was the reason for that commit)fanioz wrote:I didn't know that, will try it to nightYexo 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.
Re: AI Common Library
However... Thanks (thats happen too, long time ago )Yexo wrote: r17043 was committed after you posted your library, so it wasn't possible before (guess what was the reason for that commit)
==========
Okay All,
Have no time yet to generate html documentation now, please read the code instead, or read below
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. ?
Re: AI Common Library
I haven't looked through your new source code yet, but your overview of functions is nice.
All function names look ok.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.
I'm in favor of making a different library for each class you have above.Another question :: Which is better, Make this all as single library or separate them for each category. ?
Re: AI Common Library
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), probablyfanioz wrote:-- Tile.IsMine() to check if I am the owner
To be consistent, I think the names should be:-- Tile.IsCompetitorTile() to check if my competitor owned that.
- Tile.IsMyTile() and Tile.IsCompetitorTile()
or
- Tile.IsMine() and Tile.IsCompetitors()
Re: AI Common Library
I prefer the first option (IsMyTile/IsCompetitorTile)AndersI wrote:To be consistent, I think the names should be:
- Tile.IsMyTile() and Tile.IsCompetitorTile()
or
- Tile.IsMine() and Tile.IsCompetitors()
Re: AI Common Library
Change in AILib.TileYexo wrote:I prefer the first option (IsMyTile/IsCompetitorTile)AndersI wrote:To be consistent, I think the names should be:
- Tile.IsMyTile() and Tile.IsCompetitorTile()
or
- Tile.IsMine() and Tile.IsCompetitors()
changed function name :
Tile.IsMine() => Tile.IsMyTile();
Added code : From this thread
Code: Select all
/**
* 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
Re: AI Common Library
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
http://code.google.com/p/ottd-noai-path ... common.nut
PathZilla - A networking AI - Now with tram support.
Re: AI Common Library
Wow.......... very much functions there, i think I should divide them for each category. ThanksZutty 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
Re: AI Common Library
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.
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
-
- Lib.Event.1.tar
- Libary with event system code.
- (6 KiB) Downloaded 244 times
-
- Lib.Event.1.example.txt
- How to use example.
- (1.73 KiB) Downloaded 260 times
Re: AI Common Library
thanks for contributing. It seems interesting, although I've only look at exampleac84 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.
Re: AI Common Library
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.Yexo wrote:Let's be very clear from the start that this library is GPL v2 (I hope you all agree :p).
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)
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)
Re: AI Common Library
Really nice work, fanioz.
Vote for GPL: I say GPL v2. Why would anyone even want v3?
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'!
Patches (OpenTTD): Improved smooth_economy [in trunk], More (diesel) smoke [in trunk], Realistic_acceleration finetune.
Keep 'em rollin'!
Re: AI Common Library
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.Yexo wrote:Let's be very clear from the start that this library is GPL v2 (I hope you all agree ).
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.Bilbo wrote:GPL v2+?
Re: AI Common Library
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)
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)
Who is online
Users browsing this forum: No registered users and 1 guest