Greetings Puppies,
You have a number of tiles and a number of values that can be assigned to those tiles. It doesn't matter where those tiles are. As a skeleton how about something like(I'm in work and can't test right now):
The basic concept is there and I'll correct it later this evening if necessary. This *should* randomly allocate a tile value to a tile. However, it won't ensure that the game is solvable.
Hope that helps some.
Peace,
Jes
You have a number of tiles and a number of values that can be assigned to those tiles. It doesn't matter where those tiles are. As a skeleton how about something like(I'm in work and can't test right now):
Type TileType field id field x,y field tile_value end type global Tile.TileType dim Tiles.TileType(NUM_TILES) Type TileValuesType Field id Field value End Type global tilevalue.TileValuesType dim TileValues.TileValuesType(NUM_TILES) restore TileValueData delete each TileValuesType for i = 0 to NUM_TILES-1 Read value TileValues(i) = new TileValuesType TileValue = TileValues(i) TileValue\id = i TileValue\value = value Next seedrnd(Millisecs()) delete each TileType num_left = NUM_TILES for i = 0 to NUM_TILES-1 tiles(i) = New TileType tile = tiles(i) tile\id = i tile\x = rand(X_SIZE) tile\y = rand(Y_SIZE) randomtileno = rand(numleft) ; Not too sure about the syntax being used here, you'll have to check. TileValue = First TileValuesType for j = 0 to randomtileno TileValue = After TileValuesType next tile\value = TileValue\value delete tilevalue numleft = numleft -1 next
The basic concept is there and I'll correct it later this evening if necessary. This *should* randomly allocate a tile value to a tile. However, it won't ensure that the game is solvable.
Hope that helps some.
Peace,
Jes