PDA

View Full Version : Mazer - procedural maze generator in Lazarus using Castle Game Engine



eugeneloza
03-09-2015, 04:58 AM
A maze generator created using Lazarus + Castle Game Engine
No much game at the moment, just walk around a crooked 9-level maze to find a rose http://forum.lazarus.freepascal.org/Smileys/ExcellentSmileys1/smile.gif
https://github.com/eugeneloza/Mazer
http://www.pascalgamedevelopment.com/attachment.php?attachmentid=1368&stc=1
(https://github.com/eugeneloza/Mazer)
https://www.youtube.com/watch?v=aYq4KGaLKE8

Ñuño Martínez
07-09-2015, 09:02 AM
I must take Castle Game Engine seriously. But I need some more motivation. Can you add some lighting? Pleeeeeeeeeease? ::)

eugeneloza
07-09-2015, 09:17 AM
But I need some more motivation. Can you add some lighting? Pleeeeeeeeeease? ::)
Soon... I hope I'll make dynamic lighting with by-pixel shadows, normal maps and anisotropic smoothing in the nearest 1-4 weeks. It's all in the Castle Game Engine, I just have to figure out how to turn it on :)
Right now I'm working on tile manager & placeholders, which will change the maze logic from 90s 'Eye of the beholder' to a powerful level.

eugeneloza
09-09-2015, 10:43 AM
Anisotropic smoothing & normal map. No lighting yet...
http://www.pascalgamedevelopment.com/attachment.php?attachmentid=1369&stc=1

pitfiend
18-09-2015, 01:14 AM
That's aMAZEing!!!

eugeneloza
18-09-2015, 08:18 AM
Improved anisotropic smoothing & increased FPS.
Latest release&source: https://github.com/eugeneloza/Mazer/releases/tag/v.150917-1_Win32%26Linux
http://www.pascalgamedevelopment.com/attachment.php?attachmentid=1375&stc=1

paul_nicholls
18-09-2015, 09:29 AM
Nice work mate :)

eugeneloza
25-09-2015, 12:28 AM
A step towards the light... still buggy...
http://www.pascalgamedevelopment.com/attachment.php?attachmentid=1376&stc=1

Carver413
25-09-2015, 11:44 PM
looking really good,what's buggy ?

eugeneloza
26-09-2015, 03:59 AM
That's a fine screenshot. Walls&floor&ceiling are not always correctly lit (e.g. you can see that the floor is too bright in the screenshot). I suggest I'm doing something wrong with blender export. Anyway, I need some time to understand and implement by-pixel shadows (there's a tutorial I didn't study yet).

eugeneloza
18-10-2015, 07:23 PM
Finally I'm done with Tile Manager (or, rather one of its parts). Plus some works on light management (still buggy).
http://www.pascalgamedevelopment.com/attachment.php?attachmentid=1377&stc=1
http://www.pascalgamedevelopment.com/attachment.php?attachmentid=1378&stc=1

paul_nicholls
18-10-2015, 10:42 PM
Keep up the great work mate :)

eugeneloza
27-10-2015, 08:16 PM
Fresh video:

https://www.youtube.com/watch?v=CPxa9If__8s

Super Vegeta
29-10-2015, 06:36 PM
Looks really fine. Now just stick a Xenomorph or Slenderman in there and you've got a nice survival horror. :P

paul_nicholls
29-10-2015, 10:01 PM
Awesome work mate :)
+1 what Super Vegeta said :D
cheers,
Paul

Ñuño Martínez
02-11-2015, 10:32 AM
That looks much better. :yes:

Please, keep the sources with a ton of comments explaining every bit, will you? I want to learn once you finish it.

[edit] Put some skeletons and arcane treausres and you have your Roge done. :D

eugeneloza
02-11-2015, 08:41 PM
A (failed) test of the new unfinished cave tileset. I don't like the way the cave looks. However, it provided a good test for 'curved faces' and 'composite tiles' modeling.
I should make something more anthropomorphic for now (e.g. a library to test placeholders at their max)... But that one's gonna be a hell of texturing :o

https://www.youtube.com/watch?v=PsFleC1KBe8


Please, keep the sources with a ton of comments explaining every bit, will you? I want to learn once you finish it.
Yes, I try to comment almost everything for this reason. However, this is the first bunch of code (maybe the second) I actually comment, so, perhaps not everything will be clear... But I hope I'll be there to answer any questions ;)
P.S. the code at github is severely outdated because the game actually 'lost' a little of visual - I've cut down the tileset from 40 to 15 tiles to make and test serious modifications to the core. As soon as I finish implementing the placeholders with subplaceholders and make a decent tileset it'll be there. Or... maybe I just have to put myself together, stop being lazy and make an 'inaccessible' logic chunk before making a new tileset to show all the power of the idea. It's not that hard after all but will provide for windows, balconies, and partially-pregenerated maps (i.e. to meet the game demands to have a specific structure generated - just a week of devoted work or even less.


Put some skeletons and arcane treausres and you have your Roge done.
Yep. That's actually the 'close goal' (and not extremely hard to make - Castle has it all ready, I just have to stop being soooo lazy at least for a couple of weekends). However, my plans stretch much much further.

Thank you all for the comments!!!

Ñuño Martínez
03-11-2015, 09:09 AM
A (failed) test of the new unfinished cave tileset. I don't like the way the cave looks. But... but... but... It looks great! May be because I don't like the "photorealistic" graphics from today AAA games (It is just a game, d*mnit!) but I think that cave looks nice. And if you put what Super Vegeta suggested I'll sh*t my pants for sure!

pitfiend
03-11-2015, 11:48 PM
Pretty AWESOME!!!

farcodev
09-11-2015, 02:52 AM
You could do a Dungeon Master remake :D

eugeneloza
26-12-2015, 05:32 PM
Well, practically I've failed the self-set deadline to finish the tileset by the end of the year. I lacked just maybe a few hours. In the very end when almost everything was ready, I've come across an evil bug, that stopped the progress. I already know how to fix it (and it'll be even better, than I've planned)... but that's for the next year...
I've had a possibility to run around the new tileset and really liked it. 93 tiles and ~100 map objects. That's gonna be cool. :)
Moreover, I'm really impressed how Castle Game Engine keeps FPS without the planned optimizations.
https://decoherencestudio.files.wordpress.com/2015/12/2015-12-25-065038_1366x768_scrot.png?w=640
https://decoherencestudio.files.wordpress.com/2015/12/2015-12-25-073046_1366x768_scrot.png?w=640
https://decoherencestudio.files.wordpress.com/2015/12/2015-12-25-073124_1366x768_scrot.png?w=640
https://decoherencestudio.files.wordpress.com/2015/12/151224.png?w=640
https://decoherencestudio.files.wordpress.com/2015/11/untitled4.jpg?w=350
https://decoherencestudio.files.wordpress.com/2015/11/untitled21.jpg?w=302https://decoherencestudio.files.wordpress.com/2015/11/untitled3.jpg?w=660
https://decoherencestudio.files.wordpress.com/2015/11/untitled2.jpg?w=990

Ñuño Martínez
28-12-2015, 09:58 AM
Fix the bug fix the bug fix the bug fix the bug... :o

eugeneloza
08-02-2016, 08:44 AM
FINALLY!!!
Shorter demo:

https://www.youtube.com/watch?v=PvqhzvSNByU
Longer demo:

https://www.youtube.com/watch?v=_B_LD6OP9U

I hope I'll be able to post the source to GIT today... and give more details on the projects. I'll also try to post screenshots tomorrow.

SilverWarior
08-02-2016, 07:08 PM
Nice!

Is it intended for color of the light source to keep shifting while you are moving?

eugeneloza
09-02-2016, 02:02 PM
No, light source color should be constant... but the shader seems to have it's own opinion on that question :)

Latest version uploaded to GitHub:
Source: https://github.com/eugeneloza/Mazer
Release (Win/Linux): https://github.com/eugeneloza/Mazer/releases/tag/v.160208

P.S. If anybody could look at my code and say if it's properly commented, I'd be very grateful, because it's the first time I write the code intended not only for my eyes :D

Ñuño Martínez
10-02-2016, 01:02 PM
No, light source color should be constant... but the shader seems to have it's own opinion on that question :)

That's why I don't want to use something older than OpenGL 2, and I'm really disappointed with the non retro-compatibility of OpenGL 4.

Shaders are a good idea if you want to do something complex, but is a pain if you want to do something small or simple (or may be I'm missing something).

eugeneloza
11-02-2016, 10:13 AM
New version with increased & optimized FPS and several additional improvements.


https://www.youtube.com/watch?v=ZKeMQah3sEA

https://github.com/eugeneloza/Mazer
https://github.com/eugeneloza/Mazer/releases/tag/v.160211

eugeneloza
03-03-2016, 10:13 AM
New release. Now FPS does not depend on map size and it may be as huge as memory allows :)
https://github.com/eugeneloza/Mazer/releases/tag/v.150303
https://github.com/eugeneloza/Mazer

A little outdated demo of a huge map.

https://www.youtube.com/watch?v=dTQQbGtGSMY

eugeneloza
14-03-2016, 09:08 AM
One tiny step for mankind, but a giant leap for Mazer :)
Overworld generation algorithm is up and working!!! Still not much to see, mostly Perlin noise by TTerrainNoise :) And far-land chunks still have no “fringe” to link them to normal chunks...
And lot's of work to do to prove that data organization structure theoretically supports huge worlds at hopefully normal FPS. The presented area is approximately 1x1 km (100x100 m high-resolution area).
Plus not very sure if it's the right overall idea, because I need semi-limited paths for my game.
Rather strange result that world generation is slow. Maybe I should use simpler alrorithms? Because my goal is 10x10 km which might take up to 10 days to generate :D at present speed.

https://www.youtube.com/watch?v=OH3OyzEhpyg&feature=youtu.be
http://www.pascalgamedevelopment.com/attachment.php?attachmentid=1401&stc=1

de_jean_7777
14-03-2016, 10:26 AM
Rather strange result that world generation is slow. Maybe I should use simpler alrorithms? Because my goal is 10x10 km which might take up to 10 days to generate :D at present speed.

Does seem extremely slow. Some tools I played with that generated terrain of that size took way less time. Depends on how complex your algorithms are, but still seems too much.

eugeneloza
14-03-2016, 10:55 AM
Well, I use the best quality algorithm out there (spline)... so, that might be the problem. However, it really produces 'best' results. I'll play with TTerrainNoise settings anyway...

Carver413
14-03-2016, 10:32 PM
I think you need to smooth it out some

eugeneloza
15-03-2016, 01:15 PM
Absolutely. Hopefully I'll fix this soon (maybe, till weekends).
More problem for me now is limiting player movement to a specific map routes... Not just open world, but to add plot and gameplay elements... E.g. create strategical points, etc...

phibermon
15-03-2016, 03:26 PM
I'm currently working on thermal and hydraulic erosion techniques to improve my terrains - I highly recommend you look into them - they produce excellent results

de_jean_7777
15-03-2016, 03:34 PM
Played a bit. Some improvements to movement could be made. Not sure if you could, but make the player not stick to things when moving, but move to the side if something is just blocking the path a bit. For example, a protrusion on the wall prevents moving forward, the player should move to the side and still move forward. You can test for this by making a few collision tests in the direction the player is moving, and placing the player at an appropriate spot where it's not colliding. Some games do this for more fluid movement. Also, when running and going up stairs, the player will move deeper into the stairs and the movement will become jagged.

eugeneloza
16-03-2016, 09:21 AM
de_jean_7777 (http://www.pascalgamedevelopment.com/member.php?830-de_jean_7777), thanks for the feedback! Yes, I am aware of the problem, but fixing it requires playing with Castle Game Engine internals... It doesn't seem too complex, and Michaelis explained me how-to, but still I'm a little "afraid" to start making the patch... And as it's not too critical I put some more effort in something more interesting, like developing new generation mechanics or tilesets... But I'll surely fix it in some time.
phibermon (http://www.pascalgamedevelopment.com/member.php?1653-phibermon), thank you! I've been thinking of implementing my own erosion (and extrusion) algorithm... but if there is something available and tested it's perfect! I'll definitely look into it.

eugeneloza
23-08-2016, 10:56 AM
A few days ago I've recorded a 15-minutes maze run :) (2x speed)

https://www.youtube.com/watch?v=xzVrhYZT0u4

Ñuño Martínez
26-08-2016, 11:04 AM
I had to take a look to your maze generator. I think it is perfect to create dungeons.

I hope you can fix that lighting glitch. It's a bit annoying.

eugeneloza
26-08-2016, 12:04 PM
I had to take a look to your maze generator.
At this moment I'm buisy with interface creation for my RPG game... As soon as I've finished I have several major upgrades pending:

Render and no-collision elements to reduce getting stuck and improve preformance
Memory optimization (thanks to Lazarus forum) will enable almost infinite maps generation
Better controls (requires to make a few changes to Castle Game Engine source) to prevent getting stuck at different map elements
Overworld map generation by Height Map (not Mesh)



I hope you can fix that lighting glitch. It's a bit annoying.
I wish I could make that quickly. But still I didn't study shaders so well to use them properly... I've tried srAlways mode (which provides shaders for me) and it gives much smoother results for lights, but there is flickering (at least in my defect graphics card)... I can't promise I'll fix this issue quickly... But I also wish I could do it as soon as possible :)

SilverWarior
26-08-2016, 02:14 PM
Memory optimization (thanks to Lazarus forum) will enable almost infinite maps generation



I assume that your maze generator algorithm internally uses some kind of a random number generator right. Have you ever thought about using a pseudorandom algorithm for this?
By using pseudorandom algorithm you could be generating your mazes on demand since such algorithm would always return same results if its initial state is the same. This would require only a fraction of the memory that you need now.
Also using of pseudorandom algorithm you would literally get possibility for true endless mazes. Well depending on your overall maze generation algorithm they might begin to repeat after lots and lots of kilometers but then again no one would probably notice that.

eugeneloza
30-08-2016, 06:44 AM
Have you ever thought about using a pseudorandom algorithm for this?
Well.. the things are not as easy in this issue. Mazer is not the final goal of this maze generation algorithm. I'm working on a RPG game Decoherence, where each maze would be not as huge, but will represent a location full with items, enemy spawn points, waypoints for AI, interactable objects like doors, switches, secret passages and so on. So, basically I need to generate the map in advance and store its current state in save files.
The same stuff with the overworld generation. It will be a 2D maze of the similar sort for the player to explore fighting monsters, solving puzzles, making epic quests to save the Galaxy :)
So... I don't really need an infinite map. Just at the moment a 33x33x15 map consumes all the RAM for a 32 bit app. And after optimizing, I can drop this amount 10 to 100 times lower (at this time the required RAM is ~n^3, and it will become ~n). Moreover, a 33x33x15 map takes 40 minutes just to explore 70%... and twice that to get 100%. Basically hardly anybody but me likes such (and even longer) maze-solving experience :) A new video I've recorded took me 35 minutes to solve the maze and I've felt really lost in the end. If it wasn't for luck to find the rose I'd have very hard time finding my way back to other maze branches.

And another video (this time 35 minutes run accelerated 2.5 times)

https://www.youtube.com/watch?v=1Rp0f5keuZ8

Ñuño Martínez
05-09-2016, 09:04 AM
And another video (this time 35 minutes run accelerated 2.5 times)

https://www.youtube.com/watch?v=1Rp0f5keuZ8

This is insanely huge! :o