[Include] Maze Generator
#1

Maze Generator


Description:


This is a script I had done a long time ago and I didn't find any use for it. Hopefully, someone could use it to make some games or anything. It uses DFS, Prim's, backtrack algorithms.
Functions:

PHP код:

native CreateInGameMaze
(Float:origin_xFloat:origin_yFloat:origin_zlengthwidthwalls_color 0x000000FFspaces_color 0xFFFFFFFFstart_color 0xFF0000FFbool:use_backtrack truebool:use_prim falseboolno_dead_end false);
native CreateMazeBitmap(const filename[], lengthwidthwalls_color 0x000000FFspaces_color 0xFFFFFFFFstart_color 0xFF0000FFbool:use_backtrack truebool:use_prim falseboolno_dead_end false);
native CreateColorfulMaze(Float:origin_xFloat:origin_yFloat:origin_zlengthwidthspaces_color 0xFFFFFFFFstart_color 0xFFFFFFFFbool:use_backtrack truebool:use_prim falseboolno_dead_end false); 

Images:



share photo free



Bitmap:


Source code:

https://github.com/ThreeKingz/mazege...aster/maze.inc



Credits:
  • ThreeKingz
  • Crayder
  • Purpy Pupple for the original implementation in c++
  • ****** for y_bitmap
  • Incognito for streamer
Reply
#2

Nice!
Reply
#3

What is that `use_backtrack` and `use_prim`?
Reply
#4

Quote:
Originally Posted by Kaperstone
Посмотреть сообщение
What is that `use_backtrack` and `use_prim`?
If you enable them, you'll be using those algorithms to generate the mazes. You can't enable backtrack and prim at the same time though.
Reply
#5

Might be useful for mini games. Nice conversion from c++
Reply
#6

Amazing, I can already imagine how I'd use this creatively.
+REP!
Reply
#7

Nice
Reply
#8

I like it, but is there any way to delete the labyrinth?
Reply
#9

Where is start and end?

Quote:
Originally Posted by ThePhenix
Посмотреть сообщение
If you enable them, you'll be using those algorithms to generate the mazes. You can't enable backtrack and prim at the same time though.
Better:

PHP код:
enum e_maze_algorithm {
    
maze_algorithm_prim,
    
maze_algorithm_backtrack
}
CreateInGameMaze(Float:origin_xFloat:origin_yFloat:origin_zm_heightm_widthwalls_color 0x000000FFspaces_color 0xFFFFFFFFstart_color 0xFF0000FFe_maze_algorithm:algorithm maze_algorithm_backtrackboolno_dead_end false); 
Can add more and just only use one.
Reply
#10

Quote:
Originally Posted by OneDay
Посмотреть сообщение
Where is start and end?



Better:

PHP код:
enum e_maze_algorithm {
    
maze_algorithm_prim,
    
maze_algorithm_backtrack
}
CreateInGameMaze(Float:origin_xFloat:origin_yFloat:origin_zm_heightm_widthwalls_color 0x000000FFspaces_color 0xFFFFFFFFstart_color 0xFF0000FFe_maze_algorithm:algorithm maze_algorithm_backtrackboolno_dead_end false); 
Can add more and just only use one.
Not really, because you can use multiple algorithms at the same time.
Код:
CreateMazeBitmap("maze_test.bmp", 45, 45, 0x000000FF, 0xFFFFFFFF, 0xFF0000FF, true, false, true);
In this particular case, I'm using backtrack and no_dead_end at the same time.

Now using an enum to place all the available algorithms is not a bad idea.


The red colored object or cell is supposed to be the start, the end could be anywhere really.


Reply
#11

Good job i like this!
Reply
#12

whoa this actually rocks
Reply
#13

We really need to implement this into Texture Studio. I have looked at the code and yeah we would need to do some customizing. I am thinking the best way to do it would be like how the objectmetry system works by keeping a stack of objects then just applying them to Texture Studio when the results are desired.
Reply
#14

Quote:
Originally Posted by Pottus
Посмотреть сообщение
We really need to implement this into Texture Studio. I have looked at the code and yeah we would need to do some customizing. I am thinking the best way to do it would be like how the objectmetry system works by keeping a stack of objects then just applying them to Texture Studio when the results are desired.
Question, do you use the latest versions of TS?
Reply
#15

Amazing!
Reply
#16

Quote:
Originally Posted by Crayder
Посмотреть сообщение
Question, do you use the latest versions of TS?
I need to download it. I have been looking through this include and have a pretty good idea what to do. We need to move this and make it accessible as a global variable. The name should be changed to OBJStack as well.

Код:
static OBMStack[MAX_PLAYERS][MAX_OBM][OBMINFO];
The next part is rewriting the maze generator to work with Texture Studio. Right now it just does what it does fine but it needs to be able to interact with the object stack (easy stuff there). The pain in the ass stuff is creating the editing interface.

It has been such a long time since I have done anything to TS I am actually pretty excited to get this off the ground. Now I see that the objectmetry module has a feature that should be it's own support system.
Reply
#17

Yeah, and we also need to prevent infinite loops when putting models in before radius and stuff xD
Reply
#18

Quote:
Originally Posted by Pottus
Посмотреть сообщение
We really need to implement this into Texture Studio. I have looked at the code and yeah we would need to do some customizing. I am thinking the best way to do it would be like how the objectmetry system works by keeping a stack of objects then just applying them to Texture Studio when the results are desired.
I updated the code with an improved version. The code I originally published wasted a lot of memory and took a long time to compile. I optimized the code by storing all the required information into a single PAWN cell (4 bytes) including boolean information like up, in, left through bitwise operations. If you're going to use this include for Texture Studio, you should definitely check out the new code as it will drastically reduce compiling time and amx file size.

For example, for a 2000x2000 maze it originally used 94MB of amx file size, it uses 4MB now.
Reply
#19

Quote:
Originally Posted by ThePhenix
Посмотреть сообщение
I updated the code with an improved version. The code I originally published wasted a lot of memory and took a long time to compile. I optimized the code by storing all the required information into a single PAWN cell (4 bytes) including boolean information like up, in, left through bitwise operations. If you're going to use this include for Texture Studio, you should definitely check out the new code as it will drastically reduce compiling time and amx file size.

For example, for a 2000x2000 maze it originally used 94MB of amx file size, it uses 4MB now.
Well, if you recall correctly, that's how I did it when we were making this originally years ago.
Reply
#20

Quote:
Originally Posted by ThePhenix
Посмотреть сообщение
I updated the code with an improved version. The code I originally published wasted a lot of memory and took a long time to compile. I optimized the code by storing all the required information into a single PAWN cell (4 bytes) including boolean information like up, in, left through bitwise operations. If you're going to use this include for Texture Studio, you should definitely check out the new code as it will drastically reduce compiling time and amx file size.

For example, for a 2000x2000 maze it originally used 94MB of amx file size, it uses 4MB now.
Thanks a lot! The thing is once I update this include to work with TS it will make things a pain in the ass to update if you make any changes. Currently there isn't enough support for TS to use it out of the box so as I mentioned we need to break down the objectmetry modules player object stack system to handle the maze generator. Then the maze generator needs some updates to use the object stack system.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)