I have been trying to produce an exploration game, so naturally I started with a world generator. I am stuck, however, on populating my list of biomes. The "biome_map" list is essentially an array that is equal in width and height to whatever size the user requested. Here is the code I have written:
EWbiome_map = [] #produces an empty row that is E_W_Size km wide for chunk1 in range (1, (E_W_Size + 1)): EWbiome_map = EWbiome_map + ["empty"] biome_map = [] for chunk2 in range (1, (N_S_Size + 1)): biome_map = biome_map + [EWbiome_map] print ("Map Initialized") print ("Assigning Biomes...") # produces an empty array print (biome_map) Seed1 = Seed random.seed (Seed) x = 0 for element in biome_map: y = 0 for chunk3 in element: (biome_map[x])[y] = random.choice (biome_list) y = y + 1 x = x + 1 print ("Biomes Assigned") print (biome_map) The error shows up in the result, where each list is a copy of the last.
Modules Successfully Imported Biomes Initialized Map Initialized Assigning Biomes... [['empty', 'empty', 'empty'], ['empty', 'empty', 'empty'],['empty', 'empty', 'empty']] Biomes Assigned [['tundra', 'tundra', 'plateaus'], ['tundra', 'tundra', 'plateaus'], ['tundra', 'tundra', 'plateaus']]
print('hi')instead ofprint ('hi')