Author Topic: Random Maze Generation (Grammer)  (Read 3245 times)

0 Members and 2 Guests are viewing this topic.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Random Maze Generation (Grammer)
« on: February 23, 2013, 04:07:51 pm »
I started working on a maze generating thingy after seeing KermM's BASIC algorithm (using the DCS7 AnsStack command). I have coded this in Grammer and I am still working on optimising it more. If you want to edit the size of the path (2 pixels wide, 3 pixels wide, et cetera), open the source and change the value for →S. 2 makes a 1-pixel wide path, 6 makes a 5 pixel wide path, for example. On my actual calc, I have an actual game started, but I haven't been able to transfer my programs.

Here is the code:
Code: [Select]
:.0:Return
:Full
:3→S
:Fix 16
:96/S
:*64/S→A
:Send(+A,"VYπ→θ+A→Z
:π86EC→W
:π9340→V
:Lbl "BTR→T
:Lbl "pxl-Test(NEIGHBORS→U
:Fill(0→N→X→Y
:ClrDrawZ
:Disp W
:ClrDraw
:64/S→A
:96/S→B
:Horizontal A
:Vertical B
:Line(S*B-1,S*A-1,S,,0,V
:Pxl-On(A-1,B-1
:!Repeat N
:int(Z+N,X
:int(θ+N,Y
:Pxl-On(Y,X
:Line(1+S*X,1+S*Y,S-1,,0,V
:If 15=prgmU
:prgmT
:!Repeat and A
:e^(randInt(0,4
:End
:→A=2
:+X-A=1→X*S
:+1+A=1
:-A=2→B
:Y+A=4
:-A=8→Y*S
:+1+A=8
:-A=4→A
:Line(B,A,S-1,,0,V
:IS>(N
:Disp V:DispGraph:Disp W
:End
:Stop
:.BTR
:Repeat 15≠prgmU
:N-1→N
:If θ'
:Stop
:(+Z→X
:(θ+N→Y
:End
:End
:.pxl-Test(NEIGHBORS
:pxl-Test(Y-1,X
:+Ans+pxl-Test(Y+1,X
:+Ans+pxl-Test(Y,X+1
:+Ans+pxl-Test(Y,X-1→A
:End

That creates a maze that is guaranteed to have a path from the upper left corner to the lower right of the screen.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Random Maze Generation (Grammer)
« Reply #1 on: February 23, 2013, 04:59:27 pm »
Wow, that is pretty awesome, great job xeda! :D

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Random Maze Generation (Grammer)
« Reply #2 on: February 23, 2013, 09:26:14 pm »
I have a program on my calculator where you try to navigate through the maze. I inflated the pixels to 4x4 so you can only see a portion of the maze, and that should make it more challenging. Unfortunately, I cannot send anything from my calculator to my computer, so I will have to find time to type it into either WabbitEmu or SourceCoder later.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Random Maze Generation (Grammer)
« Reply #3 on: February 23, 2013, 09:49:24 pm »
For some reasons I kinda thought this would happen after I saw Kerm's program. :P

By the way, this could be handy to have such program in Axe or ASM (so that it can be launched from BASIC programs without an extra APP installed) for use in games, if for example someone was making an RPG with random dungeons. :P
« Last Edit: February 23, 2013, 09:50:27 pm by DJ_O »

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Random Maze Generation (Grammer)
« Reply #4 on: February 24, 2013, 07:47:42 am »
This is actually a type of algorithm that would be much better in Axe or Assembly, so I was thining of porting it later today. Luckily all three languages are similar enough that porting won't b too difficult.

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Random Maze Generation (Grammer)
« Reply #5 on: February 24, 2013, 10:18:20 am »
Cool stuff Xeda! ^^

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Random Maze Generation (Grammer)
« Reply #6 on: February 24, 2013, 03:58:32 pm »
This is actually a type of algorithm that would be much better in Axe or Assembly, so I was thining of porting it later today. Luckily all three languages are similar enough that porting won't b too difficult.
Assembly being similar to axe? O.O
I never felt that way when trying, and failing, to learn asm.

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Random Maze Generation (Grammer)
« Reply #7 on: February 25, 2013, 12:52:15 am »
It's just the higher level commands that look similar (eg Pxl-On, Pxl-test, etc). Otherwise Axe is pretty low level. ASM syntax looks weird compared to such language in general, which, I think, is what turns some people away, along with the way ASM in 28 days teaches it.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Random Maze Generation (Grammer)
« Reply #8 on: February 26, 2013, 06:52:10 am »
I finally have the program all typed up and everything :) By changing the starting values:
S = Size of square
A is the height   (max=32)
B is the width    (max=48)

The larger the playing field, the longer it takes to create the maze and it takes so much longer to get through it o.o I am also working on another algorithm (slower, probably), that will hopefully make more complicated mazes.

Offline blue_bear_94

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 801
  • Rating: +25/-35
  • Touhou Enthusiast / Former Troll / 68k Programmer
    • View Profile
Re: Random Maze Generation (Grammer)
« Reply #9 on: February 26, 2013, 08:37:15 am »
Why not make the character something other than a black square?
Due to dissatisfaction, I will be inactive on Omnimaga until further notice. (?? THP hasn't been much success and there's also the CE. I might possibly be here for a while.)
If you want to implore me to come back, or otherwise contact me, I can be found on GitHub (bluebear94), Twitter (@melranosF_), Reddit (/u/Fluffy8x), or e-mail (if you know my address). As a last resort, send me a PM on Cemetech (bluebear94) or join Touhou Prono (don't be fooled by the name). I've also enabled notifications for PMs on Omnimaga, but I don't advise using that since I might be banned.
Elvyna (Sunrise) 4 5%
TI-84+SE User (2.30 2.55 MP 2.43)
TI-89 Titanium User (3.10)
Casio Prizm User? (1.02)
Bag  東方ぷろの

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Random Maze Generation (Grammer)
« Reply #10 on: February 26, 2013, 08:40:34 am »
You can change the size of the of the squares, so it was just easier than scaling a sprite to fit the size of the path. I did have a version that used a built in sprite when the path size was 5 pixels wide, but I got rid of it :/

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Random Maze Generation (Grammer)
« Reply #11 on: February 26, 2013, 05:31:34 pm »
yeah, a different sprite for the character would be cool, but it is already awesome, your maze program O.O

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Random Maze Generation (Grammer)
« Reply #12 on: February 26, 2013, 05:39:52 pm »
Earlier I tried making the sprite grayscale, but it was pretty laggy when the screen scrolled. I know how to fix it, but it would be a bit of a pain to implement it XD