Select AI when missing AI version

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
User avatar
George
Tycoon
Tycoon
Posts: 4364
Joined: 16 Apr 2003 16:09
Skype: george-vb
Location: Varna, Bulgaria
Contact:

Select AI when missing AI version

Post by George »

I made the following test and got result that was not expected.
I loaded a savegame with NoCAB r315, but I had only NoCAB r323 in my OpenTTD\content_download\ai\ folder.
OTTD selected OTHER AI to manage the company. Several tests - several results CluelessPlus, MedievalAI, Trans ...
But why? Can't it recognize the other version of the same AI?
If yes - why doesn't it do so?
If no - may be it would be a good idea to store AI information that allows to load the same AI even of a different version?
Image Image Image Image
User avatar
fanioz
Transport Coordinator
Transport Coordinator
Posts: 320
Joined: 19 Dec 2008 05:03
Location: Indonesia
Contact:

Re: Select AI when missing AI version

Post by fanioz »

:D hi George.
In case of NoCab,and Trans. Because it doesnt declare MinVersionToLoad().
Have you try loading a saved game with Admiral21 when you have Admiral 22?. If you still got the same, I guess it was a bug.
However your idea is good. AI should handle his past version
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: Select AI when missing AI version

Post by Morloth »

I don't think that's an issue fanioz, the save games work for all versions of NoCAB regardlessly. So it'd seem to me as a bug in OpenTTD.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Select AI when missing AI version

Post by Yexo »

Morloth wrote:I don't think that's an issue fanioz, the save games work for all versions of NoCAB regardlessly. So it'd seem to me as a bug in OpenTTD.
If it does, make sure OpenTTD knows that by creating a function MinVersionToLoad in info.nut.

But it's indeed unwanted behavior, and I'm working on it.
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: Select AI when missing AI version

Post by Morloth »

Yexo wrote:
Morloth wrote:I don't think that's an issue fanioz, the save games work for all versions of NoCAB regardlessly. So it'd seem to me as a bug in OpenTTD.
If it does, make sure OpenTTD knows that by creating a function MinVersionToLoad in info.nut.

But it's indeed unwanted behavior, and I'm working on it.
Wasn't aware of this function, but I'll implement it thanks for the heads up :)
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Select AI when missing AI version

Post by Yexo »

Just fixed this. The current behavior (r16651) is the following. As soon as one step succeeds, the sequence is stopped.

1. Try to load the exact same version of the same AI.
2. Try to load the latest version of the same AI that supports loading data from the saved version. (version of saved AI >= return value of MinVersionToLoad)
3. Load the latest version of the same AI.
4. Load a random AI.
5. Load the dummy AI.

Calling the AI Load() function is only done when either 1. or 2. succeeds. When MinVersionToLoad is missing the return value is assumed to be the same as GetVersion, so no loading from older AI versions.
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: Select AI when missing AI version

Post by Morloth »

Fixed this in NoCAB as well, thanks again :).
User avatar
fanioz
Transport Coordinator
Transport Coordinator
Posts: 320
Joined: 19 Dec 2008 05:03
Location: Indonesia
Contact:

Re: Select AI when missing AI version

Post by fanioz »

Yexo wrote:Just fixed this. The current behavior (r16651) is the following. As soon as one step succeeds, the sequence is stopped.

1. Try to load the exact same version of the same AI.
2. Try to load the latest version of the same AI that supports loading data from the saved version. (version of saved AI >= return value of MinVersionToLoad)
3. Load the latest version of the same AI.
4. Load a random AI.
5. Load the dummy AI.

Calling the AI Load() function is only done when either 1. or 2. succeeds. When MinVersionToLoad is missing the return value is assumed to be the same as GetVersion, so no loading from older AI versions.
:lol: that's made clear now.

I think there are other function for Info.nut : (which is used in latest Trans )

Code: Select all

function CanLoadFromVersion(version) 
{
    return version < currentversion ;
}
Is it obsoleted now ?
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image
User avatar
George
Tycoon
Tycoon
Posts: 4364
Joined: 16 Apr 2003 16:09
Skype: george-vb
Location: Varna, Bulgaria
Contact:

Re: Select AI when missing AI version

Post by George »

Yexo wrote:When MinVersionToLoad is missing the return value is assumed to be the same as GetVersion, so no loading from older AI versions.
Sorry, not clean here. If I have AI ver 1 in savegame and ver 2 loaded, who does not define MinVersionToLoad, does it mean that random AI will be loaded? Or GetVersion here means the version of AI in the savegame, not the version of AI loaded?
Image Image Image Image
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Select AI when missing AI version

Post by Yexo »

fanioz wrote:I think there are other function for Info.nut : (which is used in latest Trans )

Code: Select all

function CanLoadFromVersion(version) 
{
    return version < currentversion ;
}
Is it obsoleted now ?
That function has been been obsolete for several months now :)
George wrote:
Yexo wrote:When MinVersionToLoad is missing the return value is assumed to be the same as GetVersion, so no loading from older AI versions.
Sorry, not clean here. If I have AI ver 1 in savegame and ver 2 loaded, who does not define MinVersionToLoad, does it mean that random AI will be loaded? Or GetVersion here means the version of AI in the savegame, not the version of AI loaded?
Both MinVersionToLoad and GetVersion are functions in info.nut, so the are defined b the AI you have. What this means is that the AI won't get the AI savegame data that is stored. An AI with the same name will alwas be prefered over an AI with a different name.
User avatar
fanioz
Transport Coordinator
Transport Coordinator
Posts: 320
Joined: 19 Dec 2008 05:03
Location: Indonesia
Contact:

Re: Select AI when missing AI version

Post by fanioz »

Yexo wrote: That function has been been obsolete for several months now :)
Oh my god :oops:

George wrote:Sorry, not clean here. If I have AI ver 1 in savegame and ver 2 loaded, who does not define MinVersionToLoad, does it mean that random AI will be loaded? Or GetVersion here means the version of AI in the savegame, not the version of AI loaded?
After seeing this steps : ...
Yexo wrote:Just fixed this. The current behavior (r16651) is the following. As soon as one step succeeds, the sequence is stopped.

1. Try to load the exact same version of the same AI.
2. Try to load the latest version of the same AI that supports loading data from the saved version. (version of saved AI >= return value of MinVersionToLoad)
3. Load the latest version of the same AI.
4. Load a random AI.
5. Load the dummy AI.

Calling the AI Load() function is only done when either 1. or 2. succeeds. When MinVersionToLoad is missing the return value is assumed to be the same as GetVersion, so no loading from older AI versions.
It will halt at step 3. Where the AI run without any knowledge of saved data in previous saved game. Never reach step 4 unless there is no AI of the same name. :D
Correct me If I am wrong - PM me if my English was bad :D

**[OpenTTD AI]** Image
***[NewGRF] *** Image
Chruker
Engineer
Engineer
Posts: 49
Joined: 01 Jun 2009 20:13

Re: Select AI when missing AI version

Post by Chruker »

Yexo wrote:Just fixed this. The current behavior (r16651) is the following. As soon as one step succeeds, the sequence is stopped.

1. Try to load the exact same version of the same AI.
2. Try to load the latest version of the same AI that supports loading data from the saved version. (version of saved AI >= return value of MinVersionToLoad)
3. Load the latest version of the same AI.
4. Load a random AI.
5. Load the dummy AI.

Calling the AI Load() function is only done when either 1. or 2. succeeds. When MinVersionToLoad is missing the return value is assumed to be the same as GetVersion, so no loading from older AI versions.
In my opinion 1. should never be done. Currently I have some savegames with AdmiralAI.20 when I load them the game find that version which just happens to break/crash because it is taking too long to start.

And I know I manually could remove that broken .tar, but relying on every casual player to do that is flawed.

Even when I click the reload button in the UI it sticks with the broken version, but thats an issue for a different thread: http://www.tt-forums.net/viewtopic.php? ... 00&start=0
User avatar
George
Tycoon
Tycoon
Posts: 4364
Joined: 16 Apr 2003 16:09
Skype: george-vb
Location: Varna, Bulgaria
Contact:

Re: Select AI when missing AI version

Post by George »

Chruker wrote:
Yexo wrote:Just fixed this. The current behavior (r16651) is the following. As soon as one step succeeds, the sequence is stopped.
1. Try to load the exact same version of the same AI.
2. Try to load the latest version of the same AI that supports loading data from the saved version. (version of saved AI >= return value of MinVersionToLoad)
3. Load the latest version of the same AI.
4. Load a random AI.
5. Load the dummy AI.
In my opinion 1. should never be done.
agree
Image Image Image Image
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 11 guests