📜 ⬆️ ⬇️

Labyrinths of Bilbo Beggins



There is no common noun in Russian that would not be suitable for the name of a Jew.
And there is no article on Habré that could not be made a toy for the iPad.

To prove this, I took the first publication ( link ) and made an application from it.
The product has been uploaded and approved in the App Store.
I decided to bring the result of my work to the public. The Habra-Habra court is, of course, not the most humane, but courts are more terrible in the homeland.
')
Eller's algorithm, thanks to the author of the publication deadkrolik , is described in detail and clearly.
Being a careless person, I programmed him without thinking and forgot.
And in vain.


As a design, I chose the theme of illustrations by M. Belomlinsky to the Hobbit.
My favorite book in the translation of Rakhmanova so far.

An old trick with random mixing of all cells of the maze is taken as the idea of ​​the game.
Before the start of the next round, each cell of the maze randomly rotates 90, 180 or 270 degrees.
The task of the player is to think and restore the original maze, generated by the Eller algorithm.

Below the function text, the color [] array is the incarnation of the maze 7 to 7.
The larger field is not suitable for games on the iPhone.

initBoard function text
-(int) initBoard:(int) num { int row1_numb[16]; int row1_edge[16]; int row1_down[16]; int rw_e[256]; int rw_d[256]; num_x = 7; num_y = 7; num_xy = num_x*num_y; for (int i=0; i<num_x; i++) { row1_numb[i] = 0; row1_edge[i] = 0; row1_down[i] = 0; } for (int j=0; j<num_y; j++) { for (int i=0; i<num_x; i++) { rw_e[i+j*num_x] = 0; rw_d[i+j*num_x] = 0; } } for (int j=0; j<num_y; j++) { for (int i=0; i<num_x; i++) { if (row1_numb[i]==0) row1_numb[i] = i + 1; } for (int i=0; i<num_x-1; i++) { // int mm = arc4random()%10; int mm = [self microsoft_rand:10]; int k = (mm<7) ? 0 : 1; if (row1_numb[i]==row1_numb[i+1]) k = 1; if (k>0) { row1_edge[i] = 1; row1_numb[i+1] = row1_numb[i]; } } row1_edge[num_x-1] = 1; for (int i=0; i<num_x; i++) { // int mm = arc4random()%10; int mm = [self microsoft_rand:10]; int k = (mm<7) ? 0 : 1; row1_down[i] = (k>0) ? 1 : 0; } int r_open = 0; int i_start = 0; for (int i=0; i<num_x; i++) { int r1 = row1_edge[i]; i_start++; if (row1_down[i] == 0) r_open = 1; if(r1) { if (r_open==0) row1_down[i-i_start+1] = 0; r_open=0; i_start = 0; } } for (int i=0; i<num_x; i++) { rw_e[i+j*num_x] = row1_edge[i]; rw_d[i+j*num_x] = row1_down[i]; } for (int i=0; i<num_x; i++) { row1_edge[i] = 0; if ( row1_down[i] == 1) row1_numb[i] = 0; row1_down[i] = 0; } } int j = num_y-1; for (int i=0; i<num_x; i++) { rw_e[i+j*num_x] = (i==num_x-1) ? 1 : 0; rw_d[i+j*num_x] = 1; } for (int j=0; j<num_y; j++) { for (int i=0; i<num_x; i++) { int r1 = rw_e[i+j*num_x]; int r2 = rw_d[i+j*num_x]; int r3 = (i) ? rw_e[i - 1 +j*num_x] : 1; int r4 = (j) ? rw_d[i+(j-1)*num_x] : 1; int r = (1-r1) + (1-r2)*2 + (1-r3)*4 + (1-r4)*8; color[i+j*num_x] = r; } } } 




The application turned out quickly. Design, I hope, not very nasty.

Never hesitate to ask what's not clear


It is terrible that in preparing this article, I re-read the publication about Eller's algorithm and found 2 errors in my text.
First, I apparently did not finish the translation to the end (or the author added the changes later) and made the last line of the labyrinth in my own way, leading a horizontal drift through all the cells.
I even wanted to complain about this in the comments, but I was ashamed.
And in vain. Never hesitate to ask what is incomprehensible.

And the second mistake - my labyrinths have loops. Who will find the bug or rewrite the code more beautifully, respect and personal gratitude in the next version of the application.

Here is an example of a jumbled and almost (find the last irregular cell) of the assembled mazes. Errors, alas, there is.

Nevertheless, it is quite interesting to play, especially those who remember the game NetWalk.

In a corporate blog, you can do advertising


The app is free.
Link here .
Current rating of players can be found here .
The presence of Americans is surprising, because it is difficult to play and this game will not bring success. In addition to a couple of hundred dollars on advertising.

Conclusion


Algorithm publications are very useful.
Often they help to find their own mistakes.
Write more often. Reread more often. Publish less often.

Source: https://habr.com/ru/post/182980/


All Articles