Author Topic: working on a new map rotation system  (Read 9571 times)

Pbhead

  • Posts: 17
  • Turrets: +0/-0
working on a new map rotation system
« on: November 27, 2008, 05:05:55 am »
So, anyway... the old map rotation system is bulky and stupid... so I pretty much started over and came up with the following (most likely incredibly buggy) code... its ugly looking, cause i haven't put everything in nice little functions, and I can streamline it later when i have time. (and when I learn a bit more about C) ... its my first real sort of coding thing so... whatever.

The point of this thing below, is to pretty much allow a server to pick a map based on who is winning, and the server population... e.g. if aliens are on a winning spree... don't pick tremor... if the server has 4 people playing... don't pick transit.   The old (rather neat) text reader system... is not smart enough for what i wanted it to do... so this is why i (attempted to) do this... so my clan's server can have a "smarter" map rotation.

It has some bugs... for instance... i think the compiler might have issues with "string (array);" (not sure how to fix this IF its an issue) and one certain variable is missing (can someone fill it in?)... I have not put "static" in here anywhere, and I probably need to (as soon as i learn how to correctly use "static") and many, many others that I have not seen that are probably painfully obvious to you... and you can flame me all you want for them because then you have pointed them out to me, and I can fix it. (which is why i am posting it here)

Since this is a sort of a rough draft... it is here, and not in the "mod showing off" place... here it is.

Code: [Select]
int g_maprotationwarmup( );  // these are defined somewhere in the server turnon code or something (ideas where exactly?)
int warmup = 0;

//everything below is placed into g_maprotation.c

G_AdvanceMapRotation( )  //only using this name so i dont have to edit main.
{

string thenextmap[9][63]; 

if(warmup != 1)
{
g_maprotationwarmup( )  //initilizes most varibles
}







if(level.numConnectedClients < 10)   //this section picks a "list" depending on server size, and who is winning.
{
x = 0;
}
if(level.numConnectedClients < 20)
{
x = 1;
}
if(level.numConnectedClients >= 20)
{
x = 2;
}

if(level.lastwin == PTE_ALIENS) 
{
if(bias < 2) bias++;
}
else if(level.lastwin == PTE_HUMANS)
{
if(bias > 0) bias--;
}
if(bias = 1) x=x+3;
if(bias = 2) x=x+6;


switch(x)                 //this section picks the next map in the "list" chosen
{
case 0:
y = previous0y;
previous0y = (y + 1);
if(previous0y = numberOmaps0) previous0y = 0;
break;
case 1:
y = previous1y;
previous1y = (y + 1);
if(previous1y = numberOmaps1) previous1y = 0;
break;
case 2:
y = previous2y;
previous2y = (y + 1);
if(previous2y = numberOmaps2) previous2y = 0;
break;
case 3:
y = previous3y;
previous3y = (y + 1);
if(previous3y = numberOmaps3) previous3y = 0;
break;
case 4:
y = previous4y;
previous4y = (y + 1);
if(previous4y = numberOmaps4) previous4y = 0;
break;
case 5:
y = previous5y;
previous5y = (y + 1);
if(previous5y = numberOmaps5) previous5y = 0;
break;
case 6:
y = previous6y;
previous6y = (y + 1);
if(previous6y = numberOmaps6) previous6y = 0;
break;
case 7:
y = previous7y;
previous7y = (y + 1);
if(previous7y = numberOmaps7) previous7y = 0;
break;
case 8:
y = previous8y;
previous8y = (y + 1);
if(previous8y = numberOmaps8) previous8y = 0;
break;
}
 
if(thelastmap == (thenextmap[x][y]||<insert varible to call current map incase voted on here>)   //I need this function/variable.  (help?)
{
G_AdvanceMapRotation( ); //ya, it calls itself... dont create situations where "thelastmap" allways = "thenextmap[x][y]"
}
thelastmap = thenextmap[x][y];

trap_SendConsoleCommand( EXEC_APPEND, va( "map %s\n",
    thenextmap[x][y] )


}

int g_maprotationwarmup( )
{

int x = 0;
int y = 0;
int previous0y = 0;
int previous1y = 0;
int previous2y = 0;
int previous3y = 0;
int previous4y = 0;
int previous5y = 0;
int previous6y = 0;
int previous7y = 0;
int previous8y = 0;
int bias = 1
string thelastmap = "dontnameyourmapthis"

//IMPORTANT!!! if you added or removed maps from the rotation,
//MAKE SURE you change these!
int numberOmaps0 = 3;
int numberOmaps1 = 3;
int numberOmaps2 = 3;
int numberOmaps3 = 3;
int numberOmaps4 = 3;
int numberOmaps5 = 3;
int numberOmaps6 = 2;
int numberOmaps7 = 3;
int numberOmaps8 = 3;



//got maps you want in rotation? put them in here!  this puts all the information into the array.
// NOTE: placing maps in more than one list will tend to increase the amount of times that map is played.
// Also, if lists are different sizes... the maps in the smaller sized lists will be picked more
// ONE more thing: maps in the neutral lists will be called more than the biased lists, do to the code.
// (I lied) you can put maps multiple times in the same list if you feel they arent getting picked enough
// aaaannnnd... the bigger the lists, the better the system will work.

//put small alien biased maps here
thenextmap[0][0] = "atcs"
thenextmap[0][1] = "tremor"
thenextmap[0][2] = "utcsb2"

//put small neutral maps here
thenextmap[1][0] = "atcs"
thenextmap[1][1] = "tremor"
thenextmap[1][2] = "pushcannon_b3"

//put small humman biased maps here
thenextmap[2][0] = "atcs"
thenextmap[2][1] = "wth"
thenextmap[2][2] = "pushcannon_b3"

/put medium alien biased maps here
thenextmap[3][0] = "tremor"
thenextmap[3][1] = "rotcannon_b11"
thenextmap[3][2] = "karith"

//put medium neutral maps here
thenextmap[4][0] = "niveus"
thenextmap[4][1] = "tremor"
thenextmap[4][2] = "rotcannon_b11"

//put medium humman biased maps here
thenextmap[5][0] = "niveus"
thenextmap[5][1] = "mancannon_b3"
thenextmap[5][1] = "gloom2beta2"

/put large alien biased maps here
thenextmap[7][0] = "transit"
thenextmap[6][1] = "pulse"

//put large neutral maps here
thenextmap[7][0] = "transit"
thenextmap[7][1] = "rotcannon_garbage1"
thenextmap[7][2] = "thermal"

//put large humman biased maps here
thenextmap[8][0] = "proycyon"
thenextmap[8][1] = "induction_b3"



warmup = 1  //
}

please post thoughts and bugs and such! thanks.

Archangel

  • Guest
Re: working on a new map rotation system
« Reply #1 on: November 27, 2008, 05:53:30 am »
hardcoded map rotations are lame

kevlarman

  • Posts: 2737
  • Turrets: +291/-295
Re: working on a new map rotation system
« Reply #2 on: November 27, 2008, 06:36:54 am »
Quote from: Asvarox link=topic=8622.msg169333#msg169333
Ok let's plan it out. Asva, you are nub, go sit on rets, I will build, you two go feed like hell, you go pwn their asses, and everyone else camp in the hallway, roger?
the dretch bites.
-----
|..d| #
|.@.-##
-----

Amanieu

  • Posts: 647
  • Turrets: +135/-83
    • Amanieu
Re: working on a new map rotation system
« Reply #3 on: November 27, 2008, 08:48:29 am »
The plan for the map rotation system in Tremfusion is to replace the whole thing with a Lua script which picks the next map and runs and mapconfigs.
Quote
< kevlarman> zakk is getting his patches from shady frenchmen on irc
< kevlarman> this can't be a good sign :P

jal

  • Posts: 249
  • Turrets: +8/-7
Re: working on a new map rotation system
« Reply #4 on: November 27, 2008, 11:07:45 am »
Do you really need a script for creating a list of maps?

nubcake

  • Posts: 529
  • Turrets: +49/-85
Re: working on a new map rotation system
« Reply #5 on: November 27, 2008, 12:42:38 pm »
Go on tremwars sometime and take a look at there map rotation system. Users get to pick between 3 maps out of 7 'categories' (ie ATCS, Tremor, ds arena, then next map they can choose between rottcannon, pushcannon, Atcs3). Map with most votes wins

Undeference

  • Tremulous Developers
  • *
  • Posts: 1254
  • Turrets: +122/-45
Re: working on a new map rotation system
« Reply #6 on: November 27, 2008, 05:00:37 pm »
The point of this thing below, is to pretty much allow a server to pick a map based on who is winning, and the server population... e.g. if aliens are on a winning spree... don't pick tremor... if the server has 4 people playing... don't pick transit.   The old (rather neat) text reader system... is not smart enough for what i wanted it to do... so this is why i (attempted to) do this... so my clan's server can have a "smarter" map rotation.
It may not be very smart but it can do everything you mentioned.
The plan for the map rotation system in Tremfusion is to replace the whole thing with a Lua script which picks the next map and runs and mapconfigs.
I don't get the infatuation with Lua (or Python, PHP, VBScript, et al). Sure, it has a cool name, but so does brainfuck. Making people learn Lua to use map rotations is a good idea if I've ever seen one…
If it were instead bash, I'd be [marginally] impressed.

Edit: After rereading what Amanieu said, I think I may have misinterpreted it. If he meant rewriting the existing code with Lua and remaining more or less compatible, that just seems dumb.
« Last Edit: November 27, 2008, 06:14:37 pm by Undeference »
Need help? Ask intelligently. Please share solutions you find.

Thats what we need, helpful players, not more powerful admins.

Archangel

  • Guest
Re: working on a new map rotation system
« Reply #7 on: November 27, 2008, 06:05:31 pm »
Go on tremwars sometime and take a look at there map rotation system. Users get to pick between 3 maps out of 7 'categories' (ie ATCS, Tremor, ds arena, then next map they can choose between rottcannon, pushcannon, Atcs3). Map with most votes wins
yeah, TremWars makes it a lot better, using the default setup.

Lua is probably TremFusion's favorite because it's so easy to integrate into things.

SlackerLinux

  • Spam Killer
  • *
  • Posts: 555
  • Turrets: +41/-62
Re: working on a new map rotation system
« Reply #8 on: November 28, 2008, 08:15:48 am »
Go on tremwars sometime and take a look at there map rotation system. Users get to pick between 3 maps out of 7 'categories' (ie ATCS, Tremor, ds arena, then next map they can choose between rottcannon, pushcannon, Atcs3). Map with most votes wins

thank rezyn sst and p-g qvm for that not tremwars we just ported it over
Slackware64 13.1
SlackersQVM/

Pbhead

  • Posts: 17
  • Turrets: +0/-0
Re: working on a new map rotation system
« Reply #9 on: November 28, 2008, 05:25:56 pm »
It may not be very smart but it can do everything you mentioned.[/quote]

ya, the coding sucks, but... if you mean by "it can do everything you mentioned"... does that mean it would work?

The thing I really need, is:

Can I use strings like I did? (if not, how do i work around it)


David

  • Spam Killer
  • *
  • Posts: 3543
  • Turrets: +249/-273
Re: working on a new map rotation system
« Reply #10 on: November 28, 2008, 05:44:58 pm »
Your code won't compile in a million years.
C has no type call string, you have assignments instead of comparisons in most of the ifs, and are missing more than a few semi-colons and brackets.
Its generally easier to test your code and post a diff.

The current rotation system can do everything you're trying to do.  That's why it was made.
Any maps not in the MG repo?  Email me or come to irc.freenode.net/#mg.
--
My words are mine and mine alone.  I can't speak for anyone else, and there is no one who can speak for me.  If I ever make a post that gives the opinions or positions of other users or groups, then they will be clearly labeled as such.
I'm disappointed that people's past actions have forced me to state what should be obvious.
I am not a dev.  Nothing I say counts for anything.

gimhael

  • Posts: 546
  • Turrets: +70/-16
Re: working on a new map rotation system
« Reply #11 on: November 28, 2008, 05:50:53 pm »
Technically there is no string type in C, you can't compare strings with == and you should use arrays of integers for the previousy and number0maps stuff, but the declaration of the string arrays is ok. Of course this will require a new game.qvm whenever you change the maprotation, so I guess that you won't find many server admins who use this stuff.

kevlarman

  • Posts: 2737
  • Turrets: +291/-295
Re: working on a new map rotation system
« Reply #12 on: November 28, 2008, 06:24:59 pm »
you do realize that game memory doesn't persist between maps right?
Quote from: Asvarox link=topic=8622.msg169333#msg169333
Ok let's plan it out. Asva, you are nub, go sit on rets, I will build, you two go feed like hell, you go pwn their asses, and everyone else camp in the hallway, roger?
the dretch bites.
-----
|..d| #
|.@.-##
-----

Undeference

  • Tremulous Developers
  • *
  • Posts: 1254
  • Turrets: +122/-45
Re: working on a new map rotation system
« Reply #13 on: November 28, 2008, 08:39:04 pm »
The thing I really need, is:

Can I use strings like I did? (if not, how do i work around it)
If I understand what you are trying to do right, you can use if (specifically with numClients and lastWin). Using multiple rotations might be handy for keeping things organized and avoiding limits. timtowtdi
« Last Edit: November 28, 2008, 08:51:46 pm by Undeference »
Need help? Ask intelligently. Please share solutions you find.

Thats what we need, helpful players, not more powerful admins.

Pbhead

  • Posts: 17
  • Turrets: +0/-0
Re: working on a new map rotation system
« Reply #14 on: November 30, 2008, 02:20:11 am »
hmmm... thanks gimhael and Undeference.

I like that idea to use multiple rotations... so maybe.... 9 different "maprotationx.cfg" and call the correct file depending on server population and who is winning... and then i dont have to rewrite most everything...  this may be possible... and much more user friendly...

does kevlarman want to be helpful and say how i can store my variables in something that does persist? the whole server doesnt restart every map change... right? and something has to persist... how else would the game know which map to play next in even a simple rotation?

Undeference

  • Tremulous Developers
  • *
  • Posts: 1254
  • Turrets: +122/-45
Re: working on a new map rotation system
« Reply #15 on: November 30, 2008, 02:49:14 am »
Multiple map rotations can be specified in the same maprotation.cfg. Only maprotation.cfg can have map rotations.
The map rotation system uses cvars for persistent storage.

At the risk of "sound[ing] like a broken record", as far as I can see, you don't have to re/write any code for what you want.
Need help? Ask intelligently. Please share solutions you find.

Thats what we need, helpful players, not more powerful admins.

Pbhead

  • Posts: 17
  • Turrets: +0/-0
Re: working on a new map rotation system
« Reply #16 on: November 30, 2008, 01:16:56 pm »
Multiple map rotations can be specified in the same maprotation.cfg. Only maprotation.cfg can have map rotations.
The map rotation system uses cvars for persistent storage.

At the risk of "sound[ing] like a broken record", as far as I can see, you don't have to re/write any code for what you want.

hmmm.... Ill have to look at the way the code works again...  unless i missed something... there is no way to do a

if (lastmap) != (nextmap)
       nextmap

command... since i would be calling from multiple rotations at differnt stages in thier rotation... it would be totally possible for atcs to be lined up for 3 games in a row without such a line... and thats a pain to type in every line.  :(

Now, what i think i can do, is fit all the rotations in the same file, and then place code somewheres in maprotation.c that determains which rotation to pick... and to make sure that people arnt playing the same map over and over... I just have to make sure that each rotation has effectivly its own counter so each rotation only "ticks" when that rotation is called...


thanks for telling me that Cvars are persistant.

Undeference

  • Tremulous Developers
  • *
  • Posts: 1254
  • Turrets: +122/-45
Re: working on a new map rotation system
« Reply #17 on: November 30, 2008, 06:10:27 pm »
hmmm.... Ill have to look at the way the code works again...  unless i missed something... there is no way to do a

if (lastmap) != (nextmap)
       nextmap
I don't even know how to respond to that.
When you make your rotations, you have complete control of them. As long as your rotations are not substantially more complicated than they need to be, you should be able to figure out when the next map could ever be the same as the previous one and avoid that. No programming necessary.
Need help? Ask intelligently. Please share solutions you find.

Thats what we need, helpful players, not more powerful admins.

jal

  • Posts: 249
  • Turrets: +8/-7
Re: working on a new map rotation system
« Reply #18 on: December 08, 2008, 05:30:42 pm »
Lua is probably TremFusion's favorite because it's so easy to integrate into things.
Lua isn't really easy to integrate into things unless you only want to execute a script with pretty much no data interchange between the code and the script. Otherwise you have to mess with the Lua stack which becomes soon a mess.

If you want easy to integrate while fast and powerful C++ alike scripting go angelscript (I've integrated both of them to choose one).

But in any case, integrating any scripting system just for selecting a map rotation sounds absurd to me. You spend more time integrating the script languaje than coding the actual thing in C.
« Last Edit: December 08, 2008, 05:38:54 pm by jal »

Amanieu

  • Posts: 647
  • Turrets: +135/-83
    • Amanieu
Re: working on a new map rotation system
« Reply #19 on: December 08, 2008, 05:32:43 pm »
Actually we'll probably have python script support in the next release of Tremfusion. Our Lua programmer is AWOL.
Quote
< kevlarman> zakk is getting his patches from shady frenchmen on irc
< kevlarman> this can't be a good sign :P