TreacherousDev/Treacherous

how can i set a seed and reproduce?

Closed this issue · 19 comments

I want to use the seed to create a map and a minimap...
unfortunately even when the seed is the same for the randomdumber generator the result is not the same.

Can you tell me how to set the seed correctly?

ah wait... i may have found it myself

nope... still no clue

Hi! The default _ready() function of map_generator.gd containts this bit of code:

set_seed(randi())

set it to a constant integer or overwrite it and you should be good

this is what i thought but the results are slightly different every time

i decided to change the way i create the minimap so i'm not really needing this right now, but it didn't generate the same dungeon with the same seed ... wanted to let you know

is the expand mode the same on both?

yes it is

tried it out again a bit, settings are the same, but the end result is not

Heya! Still trying to understand what's wrong here.

When you said "slightly different", what do you mean by that?

They look similar but are not quite the same, and this is consistent with each production?

What is the map size that you use? What is the tile set's tile size configuration for both the minimap and the map itself?

Any further information, photos or videos you can send, please do.

Thanks,
~ TreacherousDev

grafik
slightly different like this... most of the rooms are right, but these two are not
grafik
its like the base is the same but some outer rooms are not

map size is 5 and the incrementing by 1
the tiles itself are 360x360

Okay, just to clarify:

The map generated for the same seeds are the same each time, but the map and minimaps do not match?

Let me check this...
yes, used the seed 4247764327 and both maps generate the same each time but do not match
what am i doing wrong?

How did you implement your minimap?
That must be where things got conflicted.

my ui with the minimap
grafik
it is included in a subviewport
grafik

The structure of the main Dungeon:
grafik

i've extended the map generator class:

extends TDMapGenerator

@export var map_seed:int

func make_random():
	randomize()
	map_seed = rng.randi()
	#map_seed = 4247764327

func _ready():
	pass

func _input(_event):
	pass

func create(_map_size):
	rng.set_seed(map_seed)
	map_size = _map_size
	start()

so when creating a new map i call:

basemap.make_random()
basemap.create(map_size)

and for the minimap i call:

map.map_seed = main_map.map_seed
map.create(main_map.map_size)

i already separated the randomize to only call it once, now added the rng. to the randomize...
trying this out,

but it still makes different maps... will try this a bit more and give you feedback

controlled my scripts and the randomize is only called once in the whole game

Edit:
this is the map message for the generation
Map completed in 2 iterations and 0 expansions
Map completed in 3 iterations and 0 expansions

added some debugging text to find somehtin but... no idea right now:

create_new_seed
create
7
3508047187
Map completed in 2 iterations and 0 expansions
create
7
3508047187
Map completed in 4 iterations and 0 expansions

the 7 is the map size and the big number the generated seed... somehow it takes 2 iterations in the first and 4 for the minimap
and what i noticed: the first dungeon always matches, but the second does not... i make a new instance for the new dungeon but no new instance for the minimap when the player leaves the finished stage...

oooooooook....
so i changed the minimap creation... it now deletes the old map, makes a new instance and sets the values and it looks like it works now...

func set_map(_map):
	for c in map_container.get_children():
		c.queue_free()
	var new_map = map_prefab.instantiate()
	map_container.add_child(new_map)
	new_map.rng = _map.rng
	new_map.map_seed = _map.map_seed
	new_map.create(_map.map_size)

if you want to see it in action:
ListQuester on itch.io

Aight thank you!

(And sorry for deleting my messages earlier, wasnt sure if it was really the right approach hahaha)

It's on my todo list right now to make a tutorial for setting everything up and hopefully it wouldnt be as difficult for newer users :))