October 19, 2018, 11:10:04 AM

Author Topic: Crazy Dram - Code a game competition - Sep 1st to Oct 14th  (Read 467 times)

Offline Holzchopf

  • Full Member
  • ***
  • Posts: 112
Crazy Dram - Code a game competition - Sep 1st to Oct 14th
« on: September 16, 2018, 10:13:11 AM »
I'm trying this worklog thing too :)

So the game I'm planning to complete is a rail maze game with pre-placed but rotatable rail tiles. There will different game modes, including Connect, where the wagon waits on the start tile until you made a complete path to the finish tile, Action, where the wagon proceeds for one tile after every turn, and Hurry, where the wagon constantly but slowly goes on and you have to prevent it from crashing. I'm almost certain there will be gems to collect for points or some to avoid, but I'll finally decide on that once the Connect mode alone runs and see how much fun to play it already is.

So far there's not much to show, because all I did so far was mostly working on the concept. Well, here's the image I posted in the official compo thread which I drew to visualize the maze element and how tile rotation is intended to take place: There will be small driving gears (freely placeable) that will rotate the four touching rails.



Next step is to come up with a clever idea how to generate always solvable levels and - if possible - classify them automatically from easy to hard.

Offline chalky

  • Jr. Member
  • **
  • Posts: 33
Re: Crazy Dram - Code a game competition - Sep 1st to Oct 14th
« Reply #1 on: September 16, 2018, 11:42:36 AM »
Is this inspired by Crazy Train from the early eighties (I loved that game and was the first person in my Student Union Bar to get over 1,000,000 points during a single 10p attempt!)? Looking forward to seeing how it develops.

Offline Holzchopf

  • Full Member
  • ***
  • Posts: 112
Re: Crazy Dram - Code a game competition - Sep 1st to Oct 14th
« Reply #2 on: October 01, 2018, 01:48:58 PM »
I haven't worked much on this. I wanted to spread my work evenly over the whole comp duration, but last week was, well, not very productive. So again, most work will be done in the last two weeks. Starting today: I came up with a maze generator fitting my games possibilities and it seems to work! I wanted something where I can "control" the complexity of the maze. It still fails for very complex mazes, but I guess this is something I can sort out. What I won't be able to sort out though is the possibility to find a short cut in a complex maze and actually solving it faster than intended. But whatever...

Offline Holzchopf

  • Full Member
  • ***
  • Posts: 112
Re: Crazy Dram - Code a game competition - Sep 1st to Oct 14th
« Reply #3 on: October 02, 2018, 01:00:15 PM »
Hell.


After more than 8 hours, I'm finally happy with my results. 8 long and hard hours of making the impossible possible (literally, but more on that later). I think it's my third or fourth attempt that finally made it to the state where I call it stable.

As I wrote, I needed a clever idea how to generate always solvable levels with the possibility of "controllable" difficulty. It took me days to come up with an idea that I even considered testing if it could work. I knew that I basically needed a maze generator that generates a more or less complex maze with one valid path from start to end, then shuffle around the tiles a bit before presenting the level to the player. The latter bit will be easy. But that maze generation..! I was clueless TILL LAST FRIDAY. Can you imagine?! It took me over two weeks only thinking about a solution. I'm not a slow thinker but to be honest I couldn't ponder 24/7 on that, that's why it took me incredibly long.

What I'm (or my algo is) doing now: it sends a virtual figure over the map with no constraints and tracks its movements. That virtual figure always goes towards the next target on shortest route (last target is the maze end, for more complex levels I just set random intermediate targets). After every step, it checks if the last movement created a possible rail configuration or not: I have bends, straight pieces, crossings, there can even be two bends on one tile if they're connecting opposite corners, u-turns and switches (e.g. coming from straight across, going back to left or right). When it encounters an impossible configuration, e.g. to many different connections on one tile, it reduces the number of connections by short-circuiting an earlier "inlet" with the latest "outlet" until the tile is in a state with a possible configuration again. That's literally making the impossible possible. And ohhhhh this exact function took me quite some hours till it worked flawlessly. After that, the generator traces the path and removes unvisited pieces of rail, because one short-circuit at one point could turn whole sections of railway obsolete and if they were left in, it could later short-circuit from a dead inlet, cutting off the alive path. I know it sounds complicated but it can't sound complicated enough because THIS S**T IS F*****G COMPLICATED. My brain is bleeding. Nightmare!

The only downside right now is, that even with a huge amount of intermediate goals (which should make the maze more complicated) it can occur that the final path is pretty straight forward. This happens when a late rail short-circuits a way from early on. But I'm going to test two strategies against that now. One where I restrict the intermediate goals to certain areas of the map (starting closer to the start, ending closer to the end). The other would be measuring the final path's length and just redo the whole thing if it was too short.

After that, I'll add a second stage where some pieces are "upgraded" (single bend tiles to double bends, straight pieces to crossings and switches that just lead the right way) and a third where unused cells are filled with garbage.

In the mean time you can gaze at what my generator randomly came up with when told to create a rather complicated way (no dead ends, that thing at 0,2 is a u-turn). The circles indicate in which direction a tile is left.

Offline STEVIE G

  • Full Member
  • ***
  • Posts: 237
Re: Crazy Dram - Code a game competition - Sep 1st to Oct 14th
« Reply #4 on: October 02, 2018, 05:10:44 PM »
Hell.


After more than 8 hours, I'm finally happy with my results. 8 long and hard hours of making the impossible possible (literally, but more on that later). I think it's my third or fourth attempt that finally made it to the state where I call it stable.

As I wrote, I needed a clever idea how to generate always solvable levels with the possibility of "controllable" difficulty. It took me days to come up with an idea that I even considered testing if it could work. I knew that I basically needed a maze generator that generates a more or less complex maze with one valid path from start to end, then shuffle around the tiles a bit before presenting the level to the player. The latter bit will be easy. But that maze generation..! I was clueless TILL LAST FRIDAY. Can you imagine?! It took me over two weeks only thinking about a solution. I'm not a slow thinker but to be honest I couldn't ponder 24/7 on that, that's why it took me incredibly long.

What I'm (or my algo is) doing now: it sends a virtual figure over the map with no constraints and tracks its movements. That virtual figure always goes towards the next target on shortest route (last target is the maze end, for more complex levels I just set random intermediate targets). After every step, it checks if the last movement created a possible rail configuration or not: I have bends, straight pieces, crossings, there can even be two bends on one tile if they're connecting opposite corners, u-turns and switches (e.g. coming from straight across, going back to left or right). When it encounters an impossible configuration, e.g. to many different connections on one tile, it reduces the number of connections by short-circuiting an earlier "inlet" with the latest "outlet" until the tile is in a state with a possible configuration again. That's literally making the impossible possible. And ohhhhh this exact function took me quite some hours till it worked flawlessly. After that, the generator traces the path and removes unvisited pieces of rail, because one short-circuit at one point could turn whole sections of railway obsolete and if they were left in, it could later short-circuit from a dead inlet, cutting off the alive path. I know it sounds complicated but it can't sound complicated enough because THIS S**T IS F*****G COMPLICATED. My brain is bleeding. Nightmare!

The only downside right now is, that even with a huge amount of intermediate goals (which should make the maze more complicated) it can occur that the final path is pretty straight forward. This happens when a late rail short-circuits a way from early on. But I'm going to test two strategies against that now. One where I restrict the intermediate goals to certain areas of the map (starting closer to the start, ending closer to the end). The other would be measuring the final path's length and just redo the whole thing if it was too short.

After that, I'll add a second stage where some pieces are "upgraded" (single bend tiles to double bends, straight pieces to crossings and switches that just lead the right way) and a third where unused cells are filled with garbage.

In the mean time you can gaze at what my generator randomly came up with when told to create a rather complicated way (no dead ends, that thing at 0,2 is a u-turn). The circles indicate in which direction a tile is left.

Interesting concept - I like this kind of game.  There's nothing better than coming up with a complex algorithm that works.  ;D  I think the second option of redoing the whole thing if the final path is too short sounds like the best based on your description of the issue.  I'd imagine the regeneration overheads are next to zero for this option too.

Offline Holzchopf

  • Full Member
  • ***
  • Posts: 112
Re: Crazy Dram - Code a game competition - Sep 1st to Oct 14th
« Reply #5 on: October 02, 2018, 06:00:27 PM »
I think the second option of redoing the whole thing if the final path is too short sounds like the best based on your description of the issue.

Yep that's exactly what I figured too. I made a lot of measurements and found that 1st) there's a path length cap at around 50 (well, mathematically it could be more, but the statistics show a steep drop in occurrences there) and 2nd) with "only" 27 intermediate goals the random chances for different path lengths are most evenly distributed. So I packed the whole generator in a function that generates mazes with 27 intermediate goals until the resulting path is close enough to the desired length (assuming longer = more difficult, then that's what I wanted). Still runs at an acceptable speed (less than 50ms in more than 80% of the cases on the HTML5 target - acceptable for me).

Offline Holzchopf

  • Full Member
  • ***
  • Posts: 112
Re: Crazy Dram - Code a game competition - Sep 1st to Oct 14th
« Reply #6 on: October 04, 2018, 04:25:03 PM »
Just a quick picture showing the progress of the last two days  :)

Offline Holzchopf

  • Full Member
  • ***
  • Posts: 112
Re: Crazy Dram - Code a game competition - Sep 1st to Oct 14th
« Reply #7 on: October 08, 2018, 10:05:34 AM »
The graphics are still WIP. But the pathfinding works


Online Derron

  • Hero Member
  • *****
  • Posts: 1359
Re: Crazy Dram - Code a game competition - Sep 1st to Oct 14th
« Reply #8 on: October 08, 2018, 11:50:30 AM »
Ahh these u-turn-wheels. I can feel how my brain will wobble restlessly around in my head once I play such a level. I am pretty sure it will be a funny little puzzle game! Think this could interest more people than just our little forum community.


bye
Ron

Offline Holzchopf

  • Full Member
  • ***
  • Posts: 112
Re: Crazy Dram - Code a game competition - Sep 1st to Oct 14th
« Reply #9 on: October 10, 2018, 03:53:11 PM »
Since the last update I've been working mainly on the user interface.

Offline Holzchopf

  • Full Member
  • ***
  • Posts: 112
Re: Crazy Dram - Code a game competition - Sep 1st to Oct 14th
« Reply #10 on: October 14, 2018, 07:17:30 AM »
Quick update: I'm not done yet. My goal was to have all the functionality in by yesterday night, so I could already send a functioning version to Google Play and then use today to update the graphics and add sounds for the Windows version. But I got really tired and had to stop. Knowing that there are still some major tasks to be done didn't help. That's car derailment, game over screens, the possibility to reset a level and saving/reading the score to be exact. But I'm back now and will continue to work.

Offline Holzchopf

  • Full Member
  • ***
  • Posts: 112
Re: Crazy Dram - Code a game competition - Sep 1st to Oct 14th
« Reply #11 on: October 14, 2018, 07:50:34 AM »
✔ derailment

Offline Holzchopf

  • Full Member
  • ***
  • Posts: 112
Re: Crazy Dram - Code a game competition - Sep 1st to Oct 14th
« Reply #12 on: October 14, 2018, 11:16:35 AM »
✔ the other stuff

Yep, I'm done. Sound effects would be nice, but before I do that, I'll go out a bit. It's such a lovely day here :)