GithubHelp home page GithubHelp logo

Comments (15)

D4edalus avatar D4edalus commented on July 19, 2024 1

picking maps purely by a random distribution at all doesn't make sense as i explained above. same maps might appear twice in a row, or with only one map in between etc.

example set of maps: A, B, C, D

using permutations of the full set
B C A D, C A B D <-- good
B C A D, D A C B <-- bad (D appears twice in a row)

using any random distribution:
A, A, A, A, A, A <-- bad, and is perfectly possible

therefore i would prefer permutations .. or some other smart algorithm that assures some spacing between equal maps.

idea extended: having a probability of appearance per map might be also cool, such that popular maps can appear more often.

from cod4x_server.

IceNinjaman avatar IceNinjaman commented on July 19, 2024 1

Removing maps from sv_maprotationcurrent in random order. That is all you have to do.

from cod4x_server.

D4edalus avatar D4edalus commented on July 19, 2024

sv = "server" i believe?
i'm not sure if it makes sense to pick the maps completely randomly, that would include maps can be played twice or more times in a row, and also the frequencies of maps in general wouldn't be uniform.

from cod4x_server.

PureTryOut avatar PureTryOut commented on July 19, 2024

You could keep track of what maps are played already, and only allow a map to be played if it hasn't been played that rotation. Basically just create an internal array of the maps in sv_randomMapRotation, and randomly choose a map. Once the map is loaded take it out of the array. Continue this till the array is empty, and then fill the array again.

It's easy talking for me since I'm just an user, but seems reasonably easy to me.

Isn't that sv redundant? Could it maybe be taken out? Or is this done to keep it clear in code?

from cod4x_server.

D4edalus avatar D4edalus commented on July 19, 2024

the prefixes are useful to categorize commands
what you are describing would be a permutation (like shuffling cards). problem remains between two permutations.

from cod4x_server.

PureTryOut avatar PureTryOut commented on July 19, 2024

You mean if you rotated once, how to make sure the first map of the next rotation isn't the same map? Don't you have a variable somewhere that holds the previous map? If so, just check if the next chosen random map is the same as the previous one. If it is, try a new random map.

from cod4x_server.

PureTryOut avatar PureTryOut commented on July 19, 2024

If it helps anything, I have some .gsc code (I can't exactly remember the name of the guy who gave it to me, and the old Iceops forums are down so I can't check) that currently does it for me in localized_english_iw07.iwd, but of course it would be preferable to just have it as a variable in Cod4X.

init(){
    level.mapPool = strtok("mp_bo2mir;mp_bo2cargo;mp_box_hjacked;mp_chateau;mp_ctan;mp_mbdepot;mp_pow_rld;mp_tigertown_v2;mp_toujane_beta;mp_brecourt_v2;mp_killhouse;mp_shipment;mp_cargoship;mp_vacant;mp_farm;mp_overgrown;mp_convoy;mp_crash;mp_backlot;mp_crossfire;mp_citystreets;mp_strike;mp_fav;mp_karachi;mp_rundown;mp_scrapyard;mp_skidrow;mp_highrise;mp_inv;mp_modern_rust;mp_mw2_term;mp_sbase;mp_storm_b;mp_nuketown;mp_firingrange_v2;mp_4hanoi;mp_summit;;mp_qmx_matmata;",";");
    level thread randomRotation();
}

randomRotation(){
    wait 5;
    newmap = level.mapPool[randomInt(level.mapPool.size)];
    while(newmap == level.script)
        newmap = level.mapPool[randomInt(level.mapPool.size)];
    setDvar("sv_maprotationCurrent","map " + newmap);
}

Although I don't think it checks for playing same map twice in a row and frequency of maps played like you said.

from cod4x_server.

T-Maxxx avatar T-Maxxx commented on July 19, 2024

I think, I can take a look on it. The problem is C library function rand() is not providing uniform distribution of results.

from cod4x_server.

IceNinjaman avatar IceNinjaman commented on July 19, 2024

Com_RandomBytes()

from cod4x_server.

T-Maxxx avatar T-Maxxx commented on July 19, 2024

This variable just copied from sv_maprotation so deleting c from abcd will affect map sequence a bit and thats not a random

from cod4x_server.

IceNinjaman avatar IceNinjaman commented on July 19, 2024

It is a random rotation which is duplicate free.

from cod4x_server.

T-Maxxx avatar T-Maxxx commented on July 19, 2024

In vanilla cod its not random, its a sequence based on sv_maprotation. Did you changed something?

from cod4x_server.

D4edalus avatar D4edalus commented on July 19, 2024

removing random items from the rotation is a good idea. if we remove like 50% of the maps it should feel random and duplicates are avoided.

from cod4x_server.

T-Maxxx avatar T-Maxxx commented on July 19, 2024

... And might happen we will never play on map XXX or play it extremely rare.
I think it's better to rebuild whole sv_maprotationcurrent in completely random sequence of maps (having in mind different gametypes for one map)

from cod4x_server.

PureTryOut avatar PureTryOut commented on July 19, 2024

So... Building an array of some sorts of all maps specified by the server admin sounds good. Removing the map out of the array when the map is being played/done. When the array is empty, fill it with new maps. You just have to check that the last map being played of that array isn't the randomly picked map of the new array. The second map of the new array doesn't really matter anymore. Should be relatively easy I would think, right...?

from cod4x_server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.