Here is the function definition:
/**
 * @param {number} x The x-coordinate (can be positive or negative)
 * @param {number} y The y-coordinate (can be positive or negative)
 * @param {number} tileCount The number of available tiles
 * @return {number} The selected tile index
 */
 function getRandomTileIndex(x, y, tileCount) {
    // Fill in code here
 }
I could, for example, return x * y % tileCount but I want to introduce randomness. I could do return Math.round(Math.random() * (tileCount-1)) but then that would return different tile indices every time.
I want this function to be deterministic, so when using the same input (x, y, tileCount) the same output will always occur. But I also want it to appear (as much as possible) to be random with an even distribution - the quality of the randomness does not have to be perfect.
The purpose for this random tile generator is for a game with a (nearly) infinite grid - user starts in the middle (x,y) = (0,0) and will move outwards in whatever direction he wants - I will only have a fixed number of background tiles for the "ground" - and I want it so that every time you load the game the world looks the same.
 
     
     
    