Pause/unpause & company declaration
Moderator: OpenTTD Developers
Pause/unpause & company declaration
Hi all,
Sorry for english mistakes, i'm not native... ^^
I'm trying to build an(some) basic AI to achieve meres functions. So, I'm asking myself some basic questions...
1° does it is possible that an AIcompany put the game in pause/unpause? I mean, all time reading for Ai are made in ticks. So if the game is in pause no ticks incrase.
2° I understand somewhere that it is possibe to create non-companyAI. Is that possible? is there any examples ?
Thanks for answers
Sorry for english mistakes, i'm not native... ^^
I'm trying to build an(some) basic AI to achieve meres functions. So, I'm asking myself some basic questions...
1° does it is possible that an AIcompany put the game in pause/unpause? I mean, all time reading for Ai are made in ticks. So if the game is in pause no ticks incrase.
2° I understand somewhere that it is possibe to create non-companyAI. Is that possible? is there any examples ?
Thanks for answers
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: Pause/unpause & company declaration
An AI can only do what a player could do in a multiplayer game. That does not include pausing the game.
With OpenTTD 1.2.0 the concept of game scripts was introduced. Their purpose is NOT to run a company but to provide scenario and game flow control. While it shares parts of the API with AI, the available access to the game state differs. E.g. it cannot buy vehicles or change vehicle orders.
You find a number of projects on the DevZone: http://dev.openttdcoop.org/projects/aidev and http://dev.openttdcoop.org/projects/gamescripts
With OpenTTD 1.2.0 the concept of game scripts was introduced. Their purpose is NOT to run a company but to provide scenario and game flow control. While it shares parts of the API with AI, the available access to the game state differs. E.g. it cannot buy vehicles or change vehicle orders.
You find a number of projects on the DevZone: http://dev.openttdcoop.org/projects/aidev and http://dev.openttdcoop.org/projects/gamescripts
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Re: Pause/unpause & company declaration
Ok, thanks. As usual i was a bit decayed. ^^
But, can't an AI call scripts? I was thinking that yes...
And is the admin socket requests the only way to execute a "pause-script" cyclicly and automaticly?
Thanks again
But, can't an AI call scripts? I was thinking that yes...
And is the admin socket requests the only way to execute a "pause-script" cyclicly and automaticly?
Thanks again
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: Pause/unpause & company declaration
An AI _is_ a script. But it is not supposed to control the game. It's supposed to control one, single company.
A game script is also a script. It's supposed to control the game flow on a global level - and not manage single companies.
The capabilities of the single APIs are limited accordingly.
A game script is also a script. It's supposed to control the game flow on a global level - and not manage single companies.
The capabilities of the single APIs are limited accordingly.
A game script can pause and unpause the game the same way as one could do via admin port or rcon. If it's just about starting stopping the server when a certain amount of players is connected, using the min_active_clients setting is the recommended way.gligli.ch wrote: And is the admin socket requests the only way to execute a "pause-script" cyclicly and automaticly?
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Re: Pause/unpause & company declaration
No. min_active_clients is none in concern.
To be more precise, the question which stills is only what can put pause/unpause automatically by time(ex:everyday 20:00) except players(its not auto), AI(who can't,as said), admin port(not yet used on my server)
If i understand right, there only stills scripts... Which can't be called by an AI for pause purpose...
In that case my last solution is admin port, right?
To be more precise, the question which stills is only what can put pause/unpause automatically by time(ex:everyday 20:00) except players(its not auto), AI(who can't,as said), admin port(not yet used on my server)
If i understand right, there only stills scripts... Which can't be called by an AI for pause purpose...
In that case my last solution is admin port, right?
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: Pause/unpause & company declaration
Yes, indeed.gligli.ch wrote: To be more precise, the question which stills is only what can put pause/unpause automatically by time(ex:everyday 20:00)
If i understand right, there only stills scripts... Which can't be called by an AI for pause purpose...
In that case my last solution is admin port, right?
The "best" solution is making use of the admin port (sample script + library); the admin port is engineered for this purpose.
You might probably also achieve it via a specific game script. As it's written in squirrel you probably can query also the system time somehow. That will interfer with you ever running another goal script.
The third option is a console wrapper like ap+ which also executes a periodic callback to check for system time and pauses the server accordingly.
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Re: Pause/unpause & company declaration
GSDate::GetSystemTime() gives seconds since 1 jan 1970.
So indeed you can make a GS that checks the system time. But unless you need access to map features not available through the console (with ap+) or the admin port, I don't see any reason why using NoGo for this. You are better of with something that have easier to communicate with your other systems outside of OpenTTD. (eg. if you want to connect to IRC or your webserver)
So indeed you can make a GS that checks the system time. But unless you need access to map features not available through the console (with ap+) or the admin port, I don't see any reason why using NoGo for this. You are better of with something that have easier to communicate with your other systems outside of OpenTTD. (eg. if you want to connect to IRC or your webserver)
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Re: Pause/unpause & company declaration
I quickly thanks you two, to gave me the right direction.
But in 2 posts you gave me a lot of subjects for my reserches. So it'll take time till i understand them completely ^^
Planetmaker: Allright, so ap+ looks like to make it ^^ i'll dig on that direction, that sounds easyer... But at that time, I only know few on Admin port. I'll look for...
Zuu: thanks for GS enlightment, i was wonder if such thing was possible. But as expected, that will be too complex to realize.
...
EDIT
EDIT
After a short reading of port admin docs i have the idea of simply try a tcpclient to see how it answers... -> abandonned
It looks clear that Adminport is the only way to perform what i wants.
ap+ seems great to group a major part of administration process, but in fact, i only need (at that time) to perfome one... so i think that deploy a "gaz factory to full my zippo" is a bit much. even more if i never hear about the Tcl language, and the final result will be on server side(weight,debug...).
Finally, i choose to build one (or two) java program which will be called by cron to achieve a pause/unpause cyclicly. That shall be not so difficult to realise and already represent a challenge for me (i would'nt do in other case) . As its server-side java will be more usefull for me for other purpose. (I honestly hesitate to directly think with the already implemented PHP like someone else on that forum, but for the moment, I don't wants to remelt ideas in web-programing)
Now, since i slide on 3 party app, i wonder if i can continue to ask questions on that topic, if you prefer an other one or francly think that its no more the right place?
Thanks again.
But in 2 posts you gave me a lot of subjects for my reserches. So it'll take time till i understand them completely ^^
Planetmaker: Allright, so ap+ looks like to make it ^^ i'll dig on that direction, that sounds easyer... But at that time, I only know few on Admin port. I'll look for...
Zuu: thanks for GS enlightment, i was wonder if such thing was possible. But as expected, that will be too complex to realize.
...
EDIT
EDIT
After a short reading of port admin docs i have the idea of simply try a tcpclient to see how it answers... -> abandonned
It looks clear that Adminport is the only way to perform what i wants.
ap+ seems great to group a major part of administration process, but in fact, i only need (at that time) to perfome one... so i think that deploy a "gaz factory to full my zippo" is a bit much. even more if i never hear about the Tcl language, and the final result will be on server side(weight,debug...).
Finally, i choose to build one (or two) java program which will be called by cron to achieve a pause/unpause cyclicly. That shall be not so difficult to realise and already represent a challenge for me (i would'nt do in other case) . As its server-side java will be more usefull for me for other purpose. (I honestly hesitate to directly think with the already implemented PHP like someone else on that forum, but for the moment, I don't wants to remelt ideas in web-programing)
Now, since i slide on 3 party app, i wonder if i can continue to ask questions on that topic, if you prefer an other one or francly think that its no more the right place?
Thanks again.
Re: Pause/unpause & company declaration
Another simply attempt to pause/unpause automatcally, if linux dedicated server is running under detached screen is to put following command in crontab:
<min> <hour> * * * screen -S <put.your.screen-session.id.here> -p 0 -X stuff "pause^M"
and second similar line for unpause.
^M must to be an end of line sign.
<min> <hour> * * * screen -S <put.your.screen-session.id.here> -p 0 -X stuff "pause^M"
and second similar line for unpause.
^M must to be an end of line sign.
Formerly known as: McZapkie
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
Who is online
Users browsing this forum: No registered users and 27 guests