dimanche 10 juillet 2016

Implement Array Shuffle with Given Methods

Prelude

I am writing a grid-based random-map generator. Currently, I want to populate a 2D array with a variety of tiles.


Problem

In the parenthesis are a more concrete example.

Here is what you are given:

  • 2D array and its dimensions. (i.e. 3x4 grid)
  • Integer Random(Range) (i.e. Range: 0-11, Output: integer from 0-11)
  • Number of each type of tile (i.e. Desert: 2, Lake: 4, Forrest: 6)

How do I populate this array with the given tiles?


Example

3x4 map; 6 Forrest; 4 Lake; 2 Desert...

F F L
L D F
D F F
L F L


Postscript

I don't really care what language that it is implemented in; pseudo-code will be satisfactory.




Aucun commentaire:

Enregistrer un commentaire