Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Wed Dec 19, 2018 2:33 am

All times are UTC




Post new topic  Reply to topic  [ 21 posts ]  Go to page 1 2 Next
Author Message
PostPosted: Tue Jun 21, 2011 7:04 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
Many people have suggested in-game tutorials. Some (including me) have even suggested to use the current capabilities of the NoAI system rather than wishing that there was even better APIs to use. This project is an aim to test and try the approach to make use of the AI APIs to create an in-game tutorial for OpenTTD. Trying to make the best out of what we actually have.

User instructions
1. Download this AI
2. Go to AI settings and put this AI in the first AI slot.
3. Change AI start delay to 1 day
4. Start a new game
5. When this AI starts, it will print a message using signs at the center of the map (starting location)

6. If you have any suggestions, please post them here


AI - User interaction
My idea is that the AI will print text-messages to the user and wait for the user to carry out some action to tell the AI that it can progress to the next step. My first solution on this is to:
  • Display messages as signs
  • Also print the messages to the AI debug window and tell newbies about this in the introduction
  • Print button-signs that are clicked by removing them
  • Have an optional section (marked as "fairly advanced") in the introduction that explains how to cheat to the AI company and use CTRL+Click to remove signs)
  • Include a message about the existence of the sign list so that they can find the message signs if they get lost

Since signs only can hold 31 characters or so (if they are single-byte chars), I've written a routine to split up long messages on several signs to make it easier to write texts for the tutorial. This also means that the same non-split text string can be used with different line-lengths to produce sign and AI debug log output.

Currently spaces are added at the end of all lines to fill up all chars. This should give good left aligned text if a user have a fixed-width font for signs. However that's not the case for the default fonts in OpenTTD so I wonder if this really is of any benefit or if it would be better to keep all lines centered.

That said, I do realize that the capabilities in OpenTTD to rely longer texts is fairly limited compared to the wiki, thus the main focus has to be on showing users step-by-step rather than giving them long text messages to read.

Tutorial chapters
Currently I've just taken the same chapters as the Wiki article, For this my plan is to copy/reuse as much code as possible from existent AIs with compatible license (GPL2).

1. Introduction
2. Bus Service
3. Train Service [not done]
4. Train Service [not done]
5. Conclusion [not done]

An initial implementation of the bus chapter has been included in version 2 of Tutorial AI. Some texts has been written for the Introduction. But apart from that the remaining chapters yet has to be written. If anyone is interested in contributing chapters that would be more than welcome. If anyone want to write a chapter of them own, each chapter has its own directory and can live fairly separated from everything else. (except for sharing the same global scope with the rest of the AI)

The text strings in the initial version of the Tutorial AI has only been quickly written and checked by the spellchecker in GVIM, so there are surely room for improvements in wordings and selection of what to include and not include in the strings. If anyone see any text improvements text change suggestions are welcome.

Download
An initial version can be downloaded here. Depends on SuperLib 9. License is GPL v2.
Attachment:
TutorialAI-v5.tar [40 KiB]
Downloaded 633 times


Development
http://dev.openttdcoop.org/projects/tutorial-ai (including hg repository)

Screenshot
Attachment:
Unnamed, 6th Jan 1950.png
Unnamed, 6th Jan 1950.png [ 36.02 KiB | Viewed 13745 times ]

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Last edited by Zuu on Sun Aug 14, 2011 6:55 pm, edited 7 times in total.

Top
   
PostPosted: Tue Jun 21, 2011 7:08 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
Reserved for future use

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
PostPosted: Tue Jun 21, 2011 9:43 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 888
This is simply ingenious :D
As Rondje deserved the 'Most creative use of game mechanics', this AI deserves the 'Most creative use of the NoAI API' title :D

My only problem here is that finding and downloading TutorialAI (even through the online content downloader) is not the first thing someone would do when they play OpenTTD for the first time. We need some solution to point new players towards this tutorial.

Anyway I'm really interested about what you will make of this :)


Top
   
PostPosted: Tue Jun 21, 2011 10:29 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
I'm sure *if* we end up with a very good tutorial and put effort into writing OpenTTD patches it is possible to make the process more smoth. One option is (if the -a CLI-argument still exist or if it was only in the NoAI branch) to add an option to the OpenTTD installer to install this AI and start OpenTTD with this AI.

I don't say that I suggest that that is what should be done with this gamma-state tutorial, if it is even gamma. Just that while there surely are several limitations, they are still possible to overcome. But the first focus I think will be to make a tutorial AI that uses what is available and demonstrate where the limitations are and also give people motivations for fixing the issues that previously only existed in theory because someone might write a such thing. And I don't think we are there yet. The hard work still remains. I've only put together a small framework to start with. (though, I hope to heavily reuse already written AI-code and more or less just add break-points and explanations to it)


Edit: Oh and thanks for the award ;-)

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
PostPosted: Wed Jun 22, 2011 4:39 pm 
Offline
Tycoon
Tycoon

Joined: Wed Aug 26, 2009 6:33 am
Posts: 2493
Location: Poland
Looks very interesting but it may hard to demonstrate proper train use - as no ai is able to do this. Add also premade game?

_________________
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD


Top
   
PostPosted: Wed Jun 22, 2011 4:45 pm 
Offline
Tycoon
Tycoon

Joined: Thu Dec 20, 2007 12:49 pm
Posts: 3653
Kogut wrote:
Looks very interesting but it may hard to demonstrate proper train use - as no ai is able to do this. Add also premade game?

What is "proper train use"? Creating a two-station single-train single track is perfectly doable for an AI and can serve as first example for new players. Beyond that it gets more difficult. Even two stations with a passing track somewhere in the middle (like the original AI) with multiple trains shouldn't be too hard.

I've yet to try this AI but I find your approach very refreshing :) Nice to see something new like this pop up!


Top
   
PostPosted: Wed Jun 22, 2011 7:46 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
Thanks for the interest. The current version only has text menus, but I'm currently working on a bus chapter that would be the first real chapter in the tutorial.

I think I will rename the "menus" as something else eg. "tutorial messages" or "pages" or something that can't be confused with the OpenTTD GUI.

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
PostPosted: Thu Jun 23, 2011 10:37 am 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 888
By the way, what are your intentions? Guiding the player to build something or making the AI demonstrate the possibilities?


Top
   
PostPosted: Fri Jun 24, 2011 5:05 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
The intention I think is to make a tutorial that players watch. Initially I think the tutorial should aim at getting newbies off the ground, but sure is it possible to add chapters that go into showing off rail intersections etc.

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
PostPosted: Fri Jun 24, 2011 5:53 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
Update - Version 2
I've implemented a new chapter - 2. Buses (the first chapter after the introduction).

Download can be found in first post. I think I might also put this version on bananas as "experimental" as it might actually be useful in this version. :-)


Edit: My script to make AI tar files didn't include the sub directories used in this AI. (this is the first AI where I use sub directories) So I have updated to version 3. (bananas require updating to a new version when replacing the AI tar file)

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
PostPosted: Fri Jun 24, 2011 7:11 pm 
Offline
Chairman
Chairman

Joined: Sat Jul 18, 2009 5:54 pm
Posts: 888
Looks good so far :)
The only thing I was bothered with that the menu and the construction site could be quite far from each other.
When I saw that the AI does the pathfinding first, I tried to build some obstruction before it built the road, but it caused no problem, good job :mrgreen:


Top
   
PostPosted: Fri Jun 24, 2011 8:10 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
I'm not sure if I should move the menu to a location in-between the two towns or not. Though, a first step should be to select Town A near the center of the map.

Edit: Uploaded a new version (4) that picks Town A close to the center of the map. On maps with very few towns, the distance can still be large between the construction site and the menu, but it should reduce the problem in most cases.

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
PostPosted: Sat Jul 02, 2011 10:03 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Wed Dec 29, 2010 7:36 pm
Posts: 336
eheh nice zuu, remember me i spoke with someone about cheating AI that speak with another instance of itself to promote itself as master and the other as slave... the idea was (yeah it's cheat) that master ai ask any demolish and road building to the slave AI until slave AI goes bankrupt and keep going with next instance.

I'm not here to speak about how bad/good it would be (at least i didn't make it for easy to understand reason), but i would like to share what i was having in mind for my AI instances to speak with themselves.
(just because this method could be use to speak with a human too).

pickup a random place on the map, make sure place is clean, for your purpose (speak with a human, well, the button thing), surround it with signs and leave the empty space at center (the E):
---
|E|
---

now your AI just need to drop a tree there, and lookout for case cleaning condition, until the human remove the tree.
Same effect, AI->human speaking, but maybe an easier way, human just need demolish the E place with the tree for your AI to
understand a pushed button.

You may use something else (like asking a rail tile put/remove there...), and you might need that for some other usage. So i've just drop my idea for you to do what you might wish with it.


Top
   
PostPosted: Tue Jul 26, 2011 10:36 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon Feb 07, 2011 10:04 pm
Posts: 1183
Location: East Coast, United States
Just tried it today and I like it!
:D
For the bus chapter, I'd recommend having the user scroll over to town A before the bus stops are built. This can be done by putting a *Continue sign and telling the user to find it.

_________________
Like my avatar? See my screenshot thread
Chill's Patchpack, an awesome collection of OTTD patches


Top
   
PostPosted: Thu Aug 04, 2011 7:49 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
Documenting some comment's from IRC so they are not forgotten: (I hope Alberth and variable don't mind - the logs are anyway publicly available)

irc wrote:
<variable> Zuu: am I in the wrong place - I don't see instructions on the thread linked above
<Alberth> Zuu: lots of newspaper pop-ups
<variable> also is there a way to get the year to be displayed somewhere on the screen?
<Zuu> variable: The year is displayed at the bottom left.
<Zuu> Wait for months to trun to january-ish.
<Zuu> variable: The instructions are in the content download dialog, if you select TutorialAI. Apparently not in the thread however.
<variable> Ah, I see
<planetmaker> and probably using the wrong line endings
<Zuu> Alberth: When fast-forwarding on a big map with all messages on? ;-)
<Alberth> Zuu: I am missing the invitation to move the display to TOWNA
<variable> Zuu: haha very hacky. "to click a button, delete it ;-)"
<Zuu> variable: Unfortutately, that's not much one can do right now about that as AIs can't create GUIs.So it is just a big hack yes :-)
<Alberth> Zuu: 256x256, that is, completely default settings (I am using a new branch where I did not do any configuration)
<Zuu> Okay.
<variable> Zuu: do you poll to see when the button is 'clicked' or is there a notification
<Alberth> stuff like end-of-year finances :)
<Zuu> Alberth: The basics chapter could grow into infinity about turing off news, end-of-year finanses and other disturbances.
<Zuu> But your comments are valid, it's far form perfect and there is large room for improvements to a good user experience :-)
<Alberth> indeed, mainly just mentioning things so you know about it
<Alberth> you could make a save game
<Zuu> But isn't news a gui setting?
<Alberth> oh, that could be the case :(
<Zuu> Otherwise a scenario could be used, but as a scenario can't depend on an AI in bananas, the user instructions become even longer to get started.
<Alberth> ah, now I understand why you need the sign list :p
<Alberth> perhaps mention at which town you start building?
<Alberth> do you check whether I started the bus?
<Alberth> and perhaps at the end mention things the user can do now (eg extend the bus service)?
<Alberth> add a 2nd bus would be another option


In response to Alberths suggestion about mentioning the town name: I've only briefly looked into this, but I'm not really sure if the code I've written that breaks messages into lines will work on multi-byte characters, something that will need to be handled in order to print town names on signs. As far as I remember, the hard-limit of 31 characters is actually 31 bytes and not really characters in the case of multi-byte characters. But I have not made enough investigations in the source code to make a solid work in this area and has therefore decided to not take any risks here.

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
PostPosted: Mon Aug 08, 2011 1:54 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Wed Dec 29, 2010 7:36 pm
Posts: 336
Here's a patch that will allow the tutorialAI to build the menus where you wish (re-using the Menu::SetLocation function that seems only to check the location validity), i suppose you were having that in mind when doing that function.

Also a small patch to bus services to see the effect in action.

Now when the AI will ask user to do something in town A the AI will speak near townA, and when AI ask something in townB, AI messages will be near townB


Attachments:
diff.txt [1.76 KiB]
Downloaded 241 times
Top
   
PostPosted: Sun Aug 14, 2011 9:56 am 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
Why do you change Menu::SetLocation? What is the purpose of the code that you have introduced?

If you want that the menu should not appear directly ontop of towns, then that code has to go elsewhere than in the default execution path of Menu::SetLocation(top_tile), or you will also affect other usages of the function.

It might be acceptable to check if the top_tile is a town, and then re-locate the menu, but not regardless of what kind of tile that is given to the function.

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
PostPosted: Sun Aug 14, 2011 6:52 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
New version: 5

Changes:
  • Move menu location to a spot near Town A before building the road stop there. (uses a slightly more advanced method than the one in the patch that also take into account where Town B is located)
  • Use SuperLib.Road for building road stops and road depot and scrap the old code for that. (reduces the code length of TutorialAI) This means that the algorithms used are the same as CluelessPlus now, while it before used algorithms copied from PAXLink. They differ quite a bit internally but should both produce bus/truck stops and depots for Town A and B.
  • Suggest that the user can extend the bus service as an additional exercise. (as suggested by Alberth above)


If the menu would also move to Town B, further instructions would need to be added I think as the menu would have even higher chance to go out of the screen than the move to Town A. Therefore, I've chosen to only move the menu to Town A. The location selection works so that it will prefer a location on the side of Town A that is close to Town B as long as Town B is not too close.


Edit: Forgot to mention that I've incorporated Alberth's idea on suggesting that the user can extend the bus service.

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
PostPosted: Tue Aug 16, 2011 3:05 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Wed Dec 29, 2010 7:36 pm
Posts: 336
Glad you like the idea even you didn't enjoy the implementation.
When i tried it, i was a bit annoyed that you must go back & forth from center map & town A & B

I think users will be more pleased like that


Top
   
PostPosted: Tue Aug 16, 2011 4:08 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4538
Location: /home/sweden
The town selection favour towns near the center of the map. Especially town A will be selected near the map center. But if you use a large map with very few towns, then town A may still be far from the map center.

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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.