I'm working on a simple JS/canvas game. In this game I want the users to be able to navigate a world that is generated by the client according to the same seed every time. So while the world is random, every user gets the same.
So for that I'm looking for a way to do the following:
var some_seed = "abcdefg" // For instance
function get_world_rect(ab, cd) { ... }
get_world_rect([0,0], [9,9])
// Yields the following:
[[0, 0, 0, 0, 0, 0, "some_feature", 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, "rock", 0, 0, "bush", 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, "bush", 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, "bush", 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, "rare_flower", 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
The two important bits here are that I want to be able to generate the same "map" every time on every client and control the "rarity" of certain features. So I'm able to say that the map has an X chance of spawning "bush" and Y chance of spawning "rare_flower".