Map Rotation without 0.3

For all the help you need with Armagetron!
foxx
Core Dumper
Posts: 110
Joined: Sat Aug 28, 2010 9:31 pm

Map Rotation without 0.3

Post by foxx »

Is there a way i can use map rotation with http://wiki.armagetronad.net/index.php?title=Sty (0.2.8)? Like maybe a script of some sort? (An already made up script?)
Image
^Someone's mad ;)
DJ_RICHARD
Posts: 7
Joined: Sun Sep 19, 2010 12:46 am

Re: Map Rotation without 0.3

Post by DJ_RICHARD »

I know how...By reading this http://wiki.armagetronad.net/index.php? ... g_Rotation and this to ask Zurd.
foxx
Core Dumper
Posts: 110
Joined: Sat Aug 28, 2010 9:31 pm

Re: Map Rotation without 0.3

Post by foxx »

That doesn't help at all
Image
^Someone's mad ;)
User avatar
INW
Reverse Outside Corner Grinder
Posts: 1950
Joined: Tue Jul 07, 2009 4:10 pm
Location: Charlotte, NC, USA

Re: Map Rotation without 0.3

Post by INW »

I am pretty sure you have to have .3 for it to work. Now all you need is the .3 Armagetron server. You can still play tron with the 2.8.x version but when hosting a server, you must use .3.
Tobe
Round Winner
Posts: 215
Joined: Wed Jan 14, 2009 12:31 am
Location: Miami, FL

Re: Map Rotation without 0.3

Post by Tobe »

I'm pretty sure you can setup a rotation server using 0.2.8.x. How is what I do not know. Try asking Kyle for info on it.
<-- Proud co-leader of Rogue Tronners
User avatar
kyle
Reverse Outside Corner Grinder
Posts: 1876
Joined: Thu Jun 08, 2006 3:33 pm
Location: Indiana, USA, Earth, Milky Way Galaxy, Universe, Multiverse
Contact:

Re: Map Rotation without 0.3

Post by kyle »

With a script :)

I don't really have any script fragments with just rotation, that is the problem

Mainly read in ladderlog.txt and on ROUND_COMMENCING you change the maps

use the WAIT_FOR_EXTERNAL_SCRIPT setting to help with the process
Image
User avatar
AI-team
Shutout Match Winner
Posts: 1020
Joined: Tue Jun 23, 2009 6:17 pm
Location: Germany/Munich
Contact:

Re: Map Rotation without 0.3

Post by AI-team »

I think I once wrote a script for my server which has map rotation in it.
Let me have a look

edit: Sorry , I don't have it anymore
  
 
"95% of people believe in every quote you post on the internet" ~ Abraham Lincoln
 
 
Wik
Average Program
Posts: 72
Joined: Tue Aug 10, 2010 1:32 pm

Re: Map Rotation without 0.3

Post by Wik »

Dunno if this one is useful to anyone, it's just a quick'n'dirty PHP solution:

Code: Select all

<?php
/*
	First make sure a list of all map files exists, otherwise create one.
*/
if(!file_exists("maplist.txt")){
	$data=fopen("maplist.txt","w");
	$dir=opendir(".");
	while($file=readdir($dir)){
		if(strstr($file,"aamap.xml"))fwrite($data,$file."\n");
		}
	closedir($dir);
	fclose($data);
	$index=fopen("count.txt","w");
	fwrite($index,0);
	fclose($index);
	}
/*
	Check the ladderlog for a NEW_ROUND. If found, write the map next
	to come into everytime.cfg, write the incremented index back and
	clear ladderlog.
*/
$log=file("ladderlog.txt");
if(trim($log[0])=="NEW_ROUND"){
	$maps=file("maplist.txt");
	$index=file("count.txt");
	$pointer=$index[0];
	$every=fopen("everytime.cfg","w");
	fwrite($every,"map_file ".trim($maps[$pointer]));
	fclose($every);
	$pointer++;
	if($pointer==count($maps))$pointer=0;
	$index=fopen("count.txt","w");
	fwrite($index,$pointer);
	fclose($index);
	$log=fopen("ladderlog.txt","w");
	fclose($log);
	}
?>
The above is supposed to sit in your map folder, running as a kind of cronjob every n seconds, where n=shortest possible round time (extra_round_time?). You will have to correct the (relative) paths to ladderlog.txt and everytime.cfg, though.
If you want your maps fetched from an external resource, creating dummy files with the same name as the desired maps and setting resource_repository_server should do the job.
The reason why I'm not using wait_for_whatever is that I, obviously, am unable to tell my AA to write it to ladderlog.txt. /me builds workarounds instead.

EDIT: NOTE: forgot to say this one only works correct if "NEW_ROUND" is the only thing you write to ladderlog. Mea culpa.

(I'm not sure if map_file accepts php resources which generate/select a map on-the-fly, like Username/race/mapscript.php; would be a bit easier.)

Btw, if someone needs Windows batch scripts (rotation/random) for a server at home, i have some.

General question @ all: As this topic comes up quite frequently, would it be a good idea to open a thread where admins could post their rotator/randomizer/anything scripts to share experiences and help others?
Last edited by Wik on Mon Dec 06, 2010 2:50 pm, edited 3 times in total.
User avatar
kyle
Reverse Outside Corner Grinder
Posts: 1876
Joined: Thu Jun 08, 2006 3:33 pm
Location: Indiana, USA, Earth, Milky Way Galaxy, Universe, Multiverse
Contact:

Re: Map Rotation without 0.3

Post by kyle »

A lot of bugs will happen with wik's so i wrote a really quick one, untested, but should work

Code: Select all

#!/usr/bin/php
<?php
$maps=array("map1.aamap.xml","map2.aamap.xml");
while (1)  {
    $line = rtrim(fgets(STDIN, 1024));
    if ( preg_match( "/^ROUND_COMMENCING/", $line ) ){
        $keywords = preg_split("/ /", $line);
	$map=rand (0 , count($maps )-1);
        echo "MAP_FILE ".$maps[$map]."\n";
        echo "WAIT_FOR_EXTERNAL_SCRIPT 0\n";
        sleep(6);
        echo "WAIT_FOR_EXTERNAL_SCRIPT 1\n";
    }
}
?>
Note I have not tested it
to run look here

this is meant to be feed into the server
and feed laderlog.txt to it.
very generally

Code: Select all

tail -f laderlog.txt | thisscript.php | armagetronad 
the maps is an array of your map files

EDIT: added \n to end of output lines
Last edited by kyle on Mon Dec 06, 2010 4:36 am, edited 1 time in total.
Image
Wik
Average Program
Posts: 72
Joined: Tue Aug 10, 2010 1:32 pm

Re: Map Rotation without 0.3

Post by Wik »

A lot of bugs will happen with wik's
I guess not :) It's tested successfully. Given the correct paths for the relevant files, of course, and that you have to sacrifice your other ladderlog content. Please tell me what other bugs you mean, via PM.

And the code has to remember somehow which map was the last one; this line

Code: Select all

$map=rand (0 , count($maps )-1);
makes yours a randomizer, but he asked for rotation.

Addendum:

Code: Select all

while (1)  {
Wouldn't this endless loop demand max_execution_time set to infinite and safe mode disabled? Which CPU load may one expect? Just asking.
User avatar
kyle
Reverse Outside Corner Grinder
Posts: 1876
Joined: Thu Jun 08, 2006 3:33 pm
Location: Indiana, USA, Earth, Milky Way Galaxy, Universe, Multiverse
Contact:

Re: Map Rotation without 0.3

Post by kyle »

wik the main thing is how can you guarantee that the second it runs with lots of people that the NEW_MAP will be located first in the array?

the while loop in mine will stop at "$line = rtrim(fgets(STDIN, 1024));" if there is no line to read in.

I did sort of test it just now, only think i forgot were the \n at the end of what i print out (edited it in)

also if you don't want random just keep a counter variable and reset it when it gets bigger than count
Image
Wik
Average Program
Posts: 72
Joined: Tue Aug 10, 2010 1:32 pm

Re: Map Rotation without 0.3

Post by Wik »

the while loop in mine will stop at "$line = rtrim(fgets(STDIN, 1024));" if there is no line to read in.
Really? Since the condition "1" is always true, it would run eternally while fgets "accidentally" picks up freshly written data now and then.
guarantee that the second it runs [...] the NEW_MAP will be located first
Presuming the server will be up 24/7, by never changing the list again once it is written using this

Code: Select all

if(!file_exists("maplist.txt")){
command. (Hm. I sense some inconvenience here when adding maps.)
Afterwards I
just keep a counter variable
in a file, that's all.

I deem it a good thing to have the maps on the game server and being independant of external (re)sources, therefore said maplist. Nothing else.

A bit improved version: 1. no maplist file needed anymore; 2. you keep your ladderlog content. Fill in the path/to/ladderlog.txt and put in where your everytime.cfg is.
(I still don't rely on stdin/stdout for some reasons.)
Last edited by Wik on Mon Dec 06, 2010 8:08 am, edited 1 time in total.
User avatar
sinewav
Graphic Artist
Posts: 6413
Joined: Wed Jan 23, 2008 3:37 am
Contact:

Re: Map Rotation without 0.3

Post by sinewav »

Pretty good material here. I linked the wiki to it.
Wik
Average Program
Posts: 72
Joined: Tue Aug 10, 2010 1:32 pm

Re: Map Rotation without 0.3

Post by Wik »

I'm not sure if map_file accepts php resources
Just did some research on it: it does. And there was much rejoicing. [Edited, typo. sry AI]

This means, you only have to write in your everytime.cfg a line like "rinclude url/to/mapdemon.php" (for example), everything else is script managed. The big advantage here is that it only runs when it's actually needed - in between rounds - leaving us much more CPU time during fights, thus smoother gameplay and less lag. (Correct me please if this assumption is wrong.)

One could not only change or generate maps this way, but do a lot of other fancy stuff (gametype voting, autosuspend TK'ers, hall of fame... off topic, I know).

Eh... writing that makes me understand how some admins do their magic. Woot.

I'll post a bit of example code, but it could take some time. Real life duties, meh.
Last edited by Wik on Mon Dec 06, 2010 4:57 pm, edited 3 times in total.
User avatar
AI-team
Shutout Match Winner
Posts: 1020
Joined: Tue Jun 23, 2009 6:17 pm
Location: Germany/Munich
Contact:

Re: Map Rotation without 0.3

Post by AI-team »

Wik wrote:
I'm not sure if map_file accepts php resources
Just did some research on it: it does, and INCLUDE does, too. And there was much rejoicing.

This means, you only have to write in your everytime.cfg a line like "include mapdemon.php" (for example), everything else is script managed. The big advantage here is that it only runs when it's actually needed - in between rounds - leaving us much more CPU time during fights, thus smoother gameplay and less lag. (Correct me please if this assumption is wrong.)
Wow thx for the info , I didn't know include could handle .php files :D
  
 
"95% of people believe in every quote you post on the internet" ~ Abraham Lincoln
 
 
Post Reply