Jump to content

  • Log In with Google      Sign In   
  • Create Account

Robot University -- a 2D DirectX Puzzle

Hexadecagon Maze Day 6

Posted by , 27 August 2014 - - - - - - · 489 views

Day 6

I didn't do any programming.

Hexadecagon Maze Day 5

Posted by , 26 August 2014 - - - - - - · 545 views
Hexadecagon, Maze, Visual Studio and 2 more...
Day 5

I decided to make the center of the hexadecagons prohibited regions. The result is Figure (13).

Posted Image

The maze looks a little like another maze I wrote last year called Beads Maze but at least, it looks a little better than what I got yesterday in Figure (12).

Hexadecagon Maze Day 4

Posted by , 25 August 2014 - - - - - - · 480 views

Day 4

Today I spent most of my time refactoring. But I also wrote new code at the last minute. Figure (12) is my initial attempt at maze generation.

Posted ImagePosted Image

Admittedly, Figure (12) doesn't look as good as when all the walls were in, like Figure (7). I need to think of a way of improving this. If anybody has a good idea, please let me know.

Meanwhile, here’s a decent looking maze I wrote last year.

Hexadecagon Maze Day 3

Posted by , 24 August 2014 - - - - - - · 428 views
Hexadecagon, Maze, Visual Studio and 2 more...
Day 3

Today I wrote code to remove walls. The buttons 3, 2, 1, 0 you see on the toolbar move the blue dot in one of 4 directions, and is used for testing. When the blue dot, which denotes the current position, moves from one cell to another, the wall that separates those two adjacent cells is removed.

Posted Image

Tomorrow, I will write the maze constructor proper. For the algorithm, I intend to reuse the code I wrote during Amorphous Maze project.

Hexadecagon Maze Day 2

Posted by , 23 August 2014 - - - - - - · 470 views
Hexadecagon, Maze, Visual Studio and 2 more...
Day 2

Today I will establish a link between cells. To recap, although in Hexadecagon Maze the cell shapes are different, moving from left to right, at some point the pattern starts to repeat. Same holds for moving from bottom to top. The smallest collection of cells that repeat, I call it a "macro tile". In Hexadecagon Maze, the number happens to be 20 (figure (8)). This macro tile can be horizontally and vertically arrayed without gaps (figure (9)).
Posted Image
A cell is a triangle or a quadrilateral, so a cell has either 3 or 4 neighbors. The directions are assigned the numbers {0, 1, 2} or {0, 1, 2, 3}. For example, in figure (8), cell #12 has directions {0, 1, 2, 3}, which link to neighbors {16, 15, 8, 9} respectively. I call these movements "micro movements" because they stay within the macro tile. But some movements cross tile boundaries. For example, if we are currently inside of cell #19, then moving in the 0 direction puts us in cell #0 of the neighbor tile in the Northeast direction. Figure (9) defines the 9 possible directions we can travel between tiles. This I call "macro movements".
Posted Image

I hard-coded the micro and macro directions into the array that holds the coordinates of all line segments. To verify that I correctly entered them, I wrote a test program that displays all links as light blue lines (figure (10)).

Hexadecagon Maze

Posted by , 21 August 2014 - - - - - - · 605 views
maze, C++, MFC, Visual Studio and 1 more...
Yesterday I had an idea for a new maze. So I decided to code it. And share my experience in a Journal.

Day 1

At first, I wasn't sure what kind of maze it is going to be. I just had a vague concept that the cells will consist of a mixture of hexagons, squares, and triangles. So I took out a pen and a notebook and did a sketch (1).
Posted Image
After looking at (1), it seemed implementable, but too ordinary, so I did another sketch (2). This also looked implementable, but rather too simple, so I did a third sketch (3). This looked sufficiently complex, but didn't seem implementable. Specifically, the outer-most triangles encircling the left ring didn't seem repeatable in the right ring. Doable or not, this was becoming too complicated to continue by hand. So I started up a CAD program and started drawing (3). After making several adjustments to (3), I came up with (4).
Posted Image
This looks implementable. But I didn't like the fact that (4) contains right triangles in some of its cells. So I went back to design # (2) and drew it as (5) in CAD. After taking a good look at (5), it seemed to me that (5) is more aesthetically pleasing than (4) and less work to implement. So I decided to proceed with design # (2). As the next step, I found "the basic unit of repetition" (macro tile) and assigned ID numbers from 0 to 19 to every cell. This is shown in CAD drawing (6).
Posted Image
The next step was to print out (6) on paper and write down the vertex coordinates I obtained from the CAD program. Then I started up Visual Studio and wrote a quick and dirty program that plots on the screen the content of an array of line segments stored as a pair of coordinates (x1,y1)-(x2,y2). This was useful for visually checking for entry errors. Diagram (7) is a screen capture of a couple of tiles drawn by the C++ program. The lines show where the walls of the maze are going to be placed. So far so good.

But I need a name. The rings look like 16-sided polygons. Looked up Internet. They call it Hexadecagon. Try “Hexadecagon Maze” Not taken. Good. It's mine Posted Image Next task: Construct the maze.

Eight Way Maze

Posted by , 07 July 2013 - - - - - - · 604 views
labyrinth, maze, php, online and 1 more...
Eight Way Maze I decided to write a maze drawing program where the paths extend in eight directions. So I first designed the appearance with a free CAD program, as I did with Beads Maze, a program I wrote about 2 weeks ago.
Posted Image
Next I wrote the low level display routine, which draws the paths according to the internal connectivity. At first I was planning to round the center bends, but I decided to leave the corners pointy for simplicity. I also wrote a test page in PHP that increments a counter each time I click on a button. Since there are 256 patterns to test, this really came in handy while debugging my code. At one point it showed me that a trim intersection function I wrote was fundamentally flawed. I spent a whole day rewriting it.
Posted Image
The final step was to cut and paste a maze generating code I wrote before and tailor it to this one. This step wasn't too difficult except for a perplexing bug -- it was not until I broke up a long conditional expression into many small steps that I realized that in PHP, == has a higher precedence than &. I wonder if I'm the only person who finds it counterintuitive that a bitwise AND operation is performed after equality comparison.
Posted Image
Above image is the final result. All in all, there were places in the code that felt heavy and laborious but chipping away on it every day eventually got me to the finish. Here is the link to the Eight Way Maze program. Thank you for reading.

Beads Maze

Posted by , 21 June 2013 - - - - - - · 732 views

I decided to write a maze drawing program with cells shaped like donuts. So I first designed the appearance with a free CAD program. I like to start my projects with a very solid visual design because (1) appearance is important, especially in games, (2) I will have a point of reference while coding, and (3) a detailed picture may even suggest a new way to play the game.
Posted Image

Next I wrote the so-called OnDraw routine for an empty maze in PHP. When it comes to developing games, I like the bottom-up approach. I like to jump right into coding, get instant feedback, and design as I code. And I run IIS locally so that I don't have to upload my code to a remote server each time I make a code change. I also rely heavily on error_reporting(E_ALL); and error_log("x=$x\n",3,"output.txt"); for debugging.
Posted Image
Next I retrofitted an old maze drawing program for a square maze I wrote quite some time ago over the donut rings. This step took much longer than I anticipated for many reasons, one of which was that I could not comprehend it because almost all variables were single letter alphabets. My bad.
Posted Image
Then I constructed the walls inside the donuts based on the square maze. I was also trying to pick a good color for the walls. While visualizing what it would look like if every donut had a different color, I got the idea that I should call it beads maze.
Posted Image

While staring at the numbers I printed inside the small circles for debugging purpose, a great idea hit me -- why not show alphabets instead of numbers? When a player solves the maze properly, the letters he or she has visited will spell out a word or a sentence containing a secret message. What serendipity!
Posted Image
Above is what the final program looks like. Please visit http://www.puz.com/sw/phpmaze/index.php and try it out!

January 2017 »

15161718 19 2021

Recent Entries

Recent Comments

Recent Entries

Recent Comments