Accentually yes, but I just want it too make a really hard maze that is possible.
Maybe even have the difficulty able to be made easier/harder in the script with a “local Difficulty = 1” the higher it is the harder it is.
That “local Difficulty = 1” doesn’t have too be done since I should be able todo that.
local dif = 0
while true do
dif = dif +1
if dif == 1 then
local Map1 = game.ServerStorage.Map1:Clone()
Map1.Parent = workspace
elseif dif == 2 then
local Map2 = game.ServerStorage.Map2:Clone()
Map2.Parent = workspace
-- so on
local dif = 0
local Pos = 0.5 -- sample
local a = 0
while a <= 50 do
local Part = Instance.new("Part", workspace)
Part.Position = Vector3.new(0,Pos,0,0)
Part.Size = Vector3.new(Pos,0,0,0)
Part.Anchored = true
a = a +1
@Kamlkaze_Kid did you like not read the post?? While yeah that can be helpful, it’s not helpful in this case
I’d recommend reading up on maze generation algorithms, a few I’ve found to be helpful are on wikipedia
I wouldn’t recommend using pre made parts, simply because it is harder to create a maze with pre made parts than it is to create a maze with dynamic parts.
If you must use premade parts, use the primarypart and :SetPrimaryPartCFrame and a loop, pseudo code below:
for x = -10,10 1 do -- loop 20 times
for y = -10,10,1 do
local RandomModel = randomModel
RandomModel:SetPrimaryPartCFrame(CFrame.new(x * gridSize, 0, y * gridSize))
RandomModel.Parent = workspace
This maze doesn’t always turn out solvable, nor does it have walls (You can add these with other parts though), all it does it choose random parts and creates a grid with them.
If I am right, you want to have features like a randomly generated maze with the parts you have given in the Post right?
My approach to this would be making a good maze generation algorithm, because if you just randomly keep placing models on a map then it would be an unsolvable maze (atleast 80% of the time if I am sure).
As for the algorithms there are different ones, one of the maze generation algorithms I have known about is, the Randomized Prim’s algorithm:
Start with a grid full of walls.
Pick a cell, mark it as part of the maze. Add the walls of the cell to the wall list.
While there are walls in the list:
Pick a random wall from the list. If only one of the two cells that the wall divides is visited, then:
1. Make the wall a passage and mark the unvisited cell as part of the maze.
2. Add the neighboring walls of the cell to the wall list.
Remove the wall from the list.
@Kamlkaze_Kid This isn’t something that random part generations will do the work, because he wants to create a random maze but it also needs to be solvable.
Random is not hard, the problem is ensuring you can get from the start to the end.
A bit map for NxN rooms is 2*N*(N+1) bits
(Each bit being a wall.)
Or if you assume each exterior wall is existent it is 2*N*(N-1)
The second lets you make a 5x5 map from just a single 32bit random number
Try to explain without picture
So for a simple map you draw 2x2 boxes
the top wall there are 2, for the side walls of the top two boxes there are 3, the bottoms have 2 and then 3 then 2 again.
each of your models has a bit map,
1110 for the single entrance
1010 for the straight path
1100 for the corner
1000 for the 3way
0000 for 4way
Edit: you can’t check these directly, so it can get fuzzy
You just check which one to use and rotate to fit.
After that you can manually check for a good path and make one if there isn’t
Edit2: This lets you effectively have a seed to regenerate a maze if you want to have two people compete in times or just re-challenge. Just need to make sure your path solver is consistent.
It will be hard, but Algorithms are a good one to go with because if you want to make the maps unique and random all the time then the algorithms will be the only things that work out in this case.
But if you can make about like 5-6 different maps, its not that bad either, its just that once a player has played all those combinations of maps they might get bored. And it wont be random after that anymore, I believe.