MogulAI

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

Dezmond_snz
Engineer
Engineer
Posts: 58
Joined: 19 Apr 2009 11:50

Re: MogulAI

Post by Dezmond_snz »

Thank you, guys, very much!
Now i totally killed 'for' loops with such damn itteration.
There are some other implovements:
- better route selection;
- better money managment while building roads;
- upgraded queue detector (work only at trunk yet);
- sending vehicles to depot now more solid ;)
- something else, forgot already...

Updated BaNaNaS and first post.
Last edited by Dezmond_snz on 02 Aug 2010 09:32, edited 1 time in total.
Russia
Dezmond_snz
Engineer
Engineer
Posts: 58
Joined: 19 Apr 2009 11:50

Re: MogulAI

Post by Dezmond_snz »

Update. Some changes and fixes improved performance of AI at higher difficulties.

Changelog:
- fix for bridge cost calc;
- imploved queue detector;
- fix bug when AI accidentally sent all vehicles to depots;
- better vehicle replacement;

Updated BaNaNaS and first post.
Last edited by Dezmond_snz on 02 Aug 2010 09:33, edited 1 time in total.
Russia
User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2369
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: MogulAI

Post by Lord Aro »

woo!

are you saying port intentionally or by accident?
Dezmond_snz wrote: Updated BaNaNaS and first port.
AroAI - A really feeble attempt at an AI

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
Dezmond_snz
Engineer
Engineer
Posts: 58
Joined: 19 Apr 2009 11:50

Re: MogulAI

Post by Dezmond_snz »

Lord Aro wrote: are you saying port intentionally or by accident?
Dezmond_snz wrote: Updated BaNaNaS and first port.
typo + copypaste :)
Russia
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: MogulAI

Post by Zuu »

I've noticed that on bananas your AI has license := custom. However, in your tar archive you have a license.txt file with the GPL 2 license. In none of your .nut files I've found any statement regarding if your AI is covered by the "or at your opinion any later version" statement that OpenTTD and many AIs do not have.

I would recommend you to mark in at least info.nut and main.nut if it is strictly version 2 or version >= 2 of GPL that you use. If you opt for strictly version 2, then you can select GPL2 at bananas instead of custom license.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: MogulAI

Post by Yexo »

Zuu wrote:I would recommend you to mark in at least info.nut and main.nut if it is strictly version 2 or version >= 2 of GPL that you use. If you opt for strictly version 2, then you can select GPL2 at bananas instead of custom license.
You can select gplv2 on bananas in either case.

If you copy code from an AI that states "gpl v2 only (no later versions)" you can't use "or any later version" at least for the file you copied the code to.
If you copy code from an AI that states "gpl v2 or (at your option) any later version" you can still specify "gpl v2 only" in your AI.
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: MogulAI

Post by Brumi »

Thank you for the update, I was testing your AI for a while, there were no problems, except that it doesn't behave properly when the vehicle limit is reached. At least from the AI debug window it seems that the AI is constantly trying to add new vehicles to existing routes. I also see lines referring to the construction of stations.
Dezmond_snz
Engineer
Engineer
Posts: 58
Joined: 19 Apr 2009 11:50

Re: MogulAI

Post by Dezmond_snz »

Ok, some work made this evening, so...
Update:
- take RV limit into account;
- fix for closing routes.

New tar available at first post and BaNaNaS.

I also noticed strange thing. Look at screenshot:
Moguls Trans Corp ltd., 2051-06-08.png
Moguls Trans Corp ltd., 2051-06-08.png (66.87 KiB) Viewed 880 times
This is r20296. AI removed all order from this vehicle and sent it to depot while this RV stayed at station. And now it stays here forever. Is that normal behavior or bug?
Russia
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: MogulAI

Post by Rubidium »

Dezmond_snz wrote:This is r20296. AI removed all order from this vehicle and sent it to depot while this RV stayed at station. And now it stays here forever. Is that normal behavior or bug?
It's probably the "failed" attempt at fixing https://secure.openttd.org/bugs/task/3935 although the deadlock caused by that "fix" has been reverted according to the logs. In any case, adding the savegame to the bug report might be useful.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: MogulAI

Post by Zuu »

Possible workaround:

* Add two go to depot orders
* Use the skip to order command to switch to the other order
* (remove the last order)


This has worked before to make sure road vehicles actually stop what they are doing and go to depot. That said, I haven't studied this bug enough to know if this procedure has any advantage in this situation.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Dezmond_snz
Engineer
Engineer
Posts: 58
Joined: 19 Apr 2009 11:50

Re: MogulAI

Post by Dezmond_snz »

Rubidium wrote:
Dezmond_snz wrote:This is r20296. AI removed all order from this vehicle and sent it to depot while this RV stayed at station. And now it stays here forever. Is that normal behavior or bug?
It's probably the "failed" attempt at fixing https://secure.openttd.org/bugs/task/3935 although the deadlock caused by that "fix" has been reverted according to the logs. In any case, adding the savegame to the bug report might be useful.
That's easy.
1.sav
(16.17 KiB) Downloaded 150 times
edit:
Updated to r20357 - no changes. It easy to reproduce: while vehicle full-loading at station pause game, remove all orders and append goto-depot (service) order (what require unpause) - vehicle will stay at station until it full-loaded, only after that it will go to depot. However, if set "stop" flag for goto-depot order after that, vehicle leave station immediately.
Russia
Dezmond_snz
Engineer
Engineer
Posts: 58
Joined: 19 Apr 2009 11:50

Re: MogulAI

Post by Dezmond_snz »

And new version again!

Now with more important changes:
- better behavior when coming close to RVs limit;
- use built-in replace functions;
- fixed bug of calculating starting count of vehicles for route;
- some minor tweaks.

Enjoy. And feedback are welcome. :)
Russia
User avatar
ostlandr
Chairman
Chairman
Posts: 882
Joined: 12 May 2007 01:09
Location: Northeastern USA

Re: MogulAI

Post by ostlandr »

I like! I have added MogulAI to my games, along with NoCab (and Town Cars for the eye candy.)
Who is John Galt?
LamRis
Engineer
Engineer
Posts: 2
Joined: 27 Sep 2010 11:58

Re: MogulAI

Post by LamRis »

Bug report:
openttd r20911
Attachments
BugReport.png
BugReport.png (7.02 KiB) Viewed 5150 times
RokyTrans, 14. pro 1974.sav
(180.38 KiB) Downloaded 149 times
Dezmond_snz
Engineer
Engineer
Posts: 58
Joined: 19 Apr 2009 11:50

Re: MogulAI

Post by Dezmond_snz »

LamRis wrote:Bug report:
openttd r20911
Thank You very much!
Fixed 5900.
Russia
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: MogulAI

Post by Kogut »

bugbugbug
Attachments
mogulaibug.PNG
mogulaibug.PNG (223.56 KiB) Viewed 881 times
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: MogulAI

Post by Kogut »

In long run MogulAI is collecting RV in depots what is bad afterhitting RV limit.

Code: Select all

function AIAI::DeleteVehiclesInDepots()
	{
	local counter=0;
	local list=AIVehicleList();
	for (local q = list.Begin(); list.HasNext(); q = list.Next()){ //from Chopper 
		if(AIVehicle.IsStoppedInDepot(q)){
			AIVehicle.SellVehicle(q);
			counter++;
		}
	}
	return counter;
	}
Attachments
Przechwytywanie.PNG
(189.63 KiB) Downloaded 1 time
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: MogulAI

Post by Zuu »

Hint: that code can be shortened as:

Code: Select all

function AIAI::DeleteVehiclesInDepots()
{
   local list = AIVehicleList();
   list.Valuate(AIVehicle.IsStoppedInDepot);
   list.KeepValue(1);
   list.Valuate(AIVehicle.SellVehicle);
   return list.Count();
}
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: MogulAI

Post by Kogut »

Zuu wrote:Hint: that code can be shortened as:

Code: Select all

function AIAI::DeleteVehiclesInDepots()
{
   local list = AIVehicleList();
   list.Valuate(AIVehicle.IsStoppedInDepot);
   list.KeepValue(1);
   list.Valuate(AIVehicle.SellVehicle);
   return list.Count();
}
Thanks!
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: MogulAI

Post by Kogut »

Warning! It is not working:
Attachments
Przechwytywanie.PNG
Przechwytywanie.PNG (7.32 KiB) Viewed 880 times
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 28 guests