Page 1 of 2

PuzzleLabyrinth

Posted: Tue Aug 20, 2013 12:56 pm
by Xrott
Hello everyone!

My name is Daniel Grünwald a.k.a. Xrott and I finally decided to join this nice little forum.

I've been occasionally reading some of the threads but I've never had any reason to actually post something. But now that I've finished my first game I finally have something I want to share with you.

So here it is, my first finished game:
title.png
title.png (8.04 KiB) Viewed 7059 times
It has the rather simple title "PuzzleLabyrinth" and isn't too complicated either (Probably has been done before also). I just wanted to do something I know I'm able to do and also something I can finish in a reasonable amount of time.

The basic rules are:
In each level there is an entrance and exit. You have to find a path from the start to the finish while having visited every tile exactly once. You cannot visit a tile a second time and you can't move from one tile to another if there is a "wall" between them.

And that's it.
I know it doesn't sound that difficult but it can get really tricky depending on the level.

For now there are 60 levels with the difficulty increasing as they go on.

I've also made an editor, so I can easily add new levels later. I only stopped at 60 because it takes some time to make new levels.
It sounds a bit weird, I know, but one of the things I wanted to show the player is, how many solutions there are to a level. However, solving such a maze takes time and resources since the computer has to take every possible path there is.
I can't exactly tell you how many possible paths such a level can have but I can say that it's a bit less than 3^n, where n is the number of tiles of a level and 3 being the three directions one can take from any tile minus the one you came from (it's actually a lot less... One of the reasons being that from some tiles you can go only in, for example, 2 directions. This number is just to give you at least some idea on how many possible paths there can be. Also with numbers so big a difference of a few billion is almost nothing...)

If you are interested in making some levels I've also uploaded the editor. Currently there is no way to add your level to the game other than editing the level.lua in the .love but you can post the resulting line here and (if there is a reasonable amount) I'll implement something like "CommunityLevels." (If you don't want to wait until your computer solves the level, you can also post it without being solved. I'll just let my computer solve it.)

I know that's maybe a bit much for such a simple game but who knows? Maybe people will like the idea?
Or I might be just a little bit too excited...

Anyway, have fun!

If you have anything to say about the game, I am very open to constructive criticism! If you want, you can also take a look at the code, but I'll tell you right away that it's a biiiig mess... I mean, I'm not really a complete beginner to programming but I'm not experienced either... Also, English is not my native language so if you find a grammatical or spelling error, feel free to tell me!


I couldn't attach the .loves here so I uploaded it to MediaFire:

Here is the game
Here is the editor

Re: PuzzleLabyrinth

Posted: Tue Aug 20, 2013 1:13 pm
by Janywer
Have you ever thought about auto-generated levels?

What are your thoughts on it?

Also, your coding style is pretty good, no need to be ashamed or anything ;p

You should just think about using table[#table + 1] instead of table.insert.

A little addition:

You're using a bunch of if-statements where you could just do this:

Code: Select all

-- Define at top of code
local newBrushDefinitions = {
	empty,
	block,
	wallRight,
	wallDown,
	wallBoth,
	start,
	finish
}

-- When we need to access it
brush = newBrushDefinitions[newBrush]
Instead of your solution:

Code: Select all

if newBrush == 1 then brush = empty
elseif newBrush == 2 then brush = block
elseif newBrush == 3 then brush = wallRight
elseif newBrush == 4 then brush = wallDown
elseif newBrush == 5 then brush = wallBoth
elseif newBrush == 6 then brush = start
elseif newBrush == 7 then brush = finish
end

Re: PuzzleLabyrinth

Posted: Tue Aug 20, 2013 1:44 pm
by Xrott
Janywer wrote:Have you ever thought about auto-generated levels?

What are your thoughts on it?
I have, but not that much. The more I think about it now, though, the more I like this idea...

If you think about it, it actually doesn't sound that difficult. To make sure that it's solvable just let the generator run around the board and put the exit where the generator would stop. But then, how would you prevent it from generation just straight "corridors", where the player can immediately see the solution since the walls and empty spaces just guide the player instead of obscuring the correct path?

I don't know. Maybe I'll try it out later.

Oh you edited while I was writing my reply so I'll just edit this too...
Janywer wrote:You should just think about using table[#table + 1] instead of table.insert.
I actually know about table[#table + 1] and have used that a lot in some other "experiments". I don't exactly know why I used .insert here anymore, but I think I did it for a reason. But it's also very possible that I was wrong about that.
Janywer wrote:You're using a bunch of if-statements where you could just do this:
Didn't think about that. Thanks!

Re: PuzzleLabyrinth

Posted: Tue Aug 20, 2013 2:02 pm
by davisdude
I think this thread would be immensely revealing to you and your query: http://www.love2d.org/forums/viewtopic.php?f=5&t=19873
Also: You uploaded the file wrong and it shoes the pig with hearts around it. Sounds fun, though!

Re: PuzzleLabyrinth

Posted: Tue Aug 20, 2013 2:08 pm
by Janywer
davisdude wrote:Also: You uploaded the file wrong and it shoes the pig with hearts around it. Sounds fun, though!
Considering it works perfectly fine for me, the problem is probably on your side.

Re: PuzzleLabyrinth

Posted: Tue Aug 20, 2013 2:10 pm
by Xrott
davisdude wrote: Also: You uploaded the file wrong and it shoes the pig with hearts around it.
Not for me... I've checked the version on MediaFire and it runs just fine. Maybe something went wrong on your side? Are you sure your download wasn't just interrupted? The file is just a bit over 2MB.

Re: PuzzleLabyrinth

Posted: Tue Aug 20, 2013 3:03 pm
by davisdude
It was because of the LOVLINESS Chrome Extension. My bad. :P
Nice little game! I like the music and the graphics!

Re: PuzzleLabyrinth

Posted: Tue Aug 20, 2013 3:14 pm
by vladgalay
Xrott, thank you for that simple and very nice game!
The design of graphics in your game seems very well balanced to me. I have only some pieces of advice for your graphics. I think it would be nice, if your game will have a background, animated by graphical primitives ( rectangles, polygons etc. ). Also, smoothly changing color palette will probably look good =)

Re: PuzzleLabyrinth

Posted: Tue Aug 20, 2013 4:17 pm
by raidho36
You know, this is surprisingly fine made game. But I got bored pretty quick, to be honest.

Re: PuzzleLabyrinth

Posted: Tue Aug 20, 2013 9:06 pm
by davisdude
Okay. I played through all 60 levels now and have some feedback:
The 'Back to Main Menu' button after the final level doesn't actually bring you back to the main menu. Other than that, it's a pretty good game.
A bit to quick, though. I have been working on some levels, and hope to have some soon!