December 07, 2019, 03:17:34 PM

Author Topic: The Amazing Project  (Read 406 times)

Offline TomToad

  • Sr. Member
  • ****
  • Posts: 451
The Amazing Project
« on: October 30, 2019, 08:44:40 PM »
Started a project called "The Amazing Project."  Basically I am writing programs that randomly generates mazes in different programming languages.  Here is what I have so far.http://www.tomtoad.com/amazingproject/index.html
Over time, I will add new languages as I learn more.  Feel free to use any of the code from the project if you have a need for generating mazes in your own game.
------------------------------------------------
8 rabbits equals 1 rabbyte.

Offline Xerra

  • Hero Member
  • *****
  • Posts: 767
    • Retro Evolved
Re: The Amazing Project
« Reply #1 on: October 30, 2019, 09:20:01 PM »
Interesting stuff, this. How many languages do you plan to do this in?


Offline grindalf

  • Jr. Member
  • **
  • Posts: 87
Re: The Amazing Project
« Reply #2 on: October 30, 2019, 09:44:19 PM »
Could you add Blitz3D?

Offline blinkok

  • Full Member
  • ***
  • Posts: 129
Re: The Amazing Project
« Reply #3 on: October 30, 2019, 10:08:01 PM »
AGK Basic too please

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1020
Re: The Amazing Project
« Reply #4 on: October 31, 2019, 07:11:37 AM »
and Blitzmax ?
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline Pakz

  • Full Member
  • ***
  • Posts: 171
    • My homepage
Re: The Amazing Project
« Reply #5 on: October 31, 2019, 08:37:19 AM »
There is this book called "mazes for programmers" Maybe every maze algorithm is in there. The language used was not that difficult to convert to monkey.

Online Steve Elliott

  • Hero Member
  • *****
  • Posts: 2117
  • elgol developer
Re: The Amazing Project
« Reply #6 on: October 31, 2019, 08:40:42 AM »
Thanks for sharing.   :)
Windows 10, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
MacOS Mojave, 64-bit, 8Gb RAM, CPU Intel i5, 2.3 Ghz, Intel Iris Plus Graphics 640 1536 MB.
Linux Mint 19.1, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
Raspberry pi4 4Gb RAM

Offline iWasAdam

  • Hero Member
  • *****
  • Posts: 1412
Re: The Amazing Project
« Reply #7 on: October 31, 2019, 08:59:20 AM »
Here's a slightly different approach, but gives nice mazes with lots of dead ends :)
It's for mx2/monkey2
Code: [Select]

Namespace myMojoApp

#Import "<std>"
#Import "<mojo>"
Using std..
Using mojo..

Const Size := New Vec2i( 950, 720 )
const Name:string = "FontSprite"
const Ver:string = "V1.17"

Function Main()
New AppInstance
New MyWindow
App.Run()
End


Class MyWindow Extends Window

Method New()
Super.New( "FontSprite Editor "+Ver, Size.X, Size.Y, WindowFlags.Resizable|WindowFlags.HighDPI )
SetMinSize( Size.X, Size.Y )

Layout = "fill"

ClearColor = Color.Black
End method

protected
'MUST be an odd number
const _mWidth:int = 17
const _mHeight:int = 13
field _maze:bool[, ] = New bool[_mWidth, _mHeight]
field _startX:ubyte = 0
field _startY:ubyte = 0
field _posX:ubyte
field _posY:ubyte
field _mMax:int = ((_mWidth-1) * 0.5) * ((_mHeight-1)*0.5)
field _mCount:int = 0

Method OnRender( canvas:Canvas ) Override
' canvas.DrawText( "Hello World",Width/2,Height/2,.5,.5 )
local size:int = 25
local x:int
local y:int
local xp:int
local yp:int
canvas.Color = Color.Brick * 0.9
For y = 0 To _mHeight-1
xp = 0
For x = 0 To _mWidth-1
If _maze[x, y] Then
Else
canvas.DrawRect( xp, yp, size, size )
canvas.DrawFrame( xp, yp, size, size )
End if
xp += size
Next
yp += size
Next

If _startX = 0 Then return

canvas.Color = Color.Green
canvas.DrawRect( _posX*size+2, _posY*size+2, size-4, size-4 )
End

'x and y MUST be odd and within borders
method GetPosition()
_posX = (int(Rnd((_mWidth-1) * 0.5))*2)+1
_posY = (int(Rnd((_mHeight-1) * 0.5))*2)+1
End method

method ZeroMaze()
local x:int
local y:int
For y = 0 To _mHeight-1
For x = 0 To _mWidth-1
_maze[x, y] = False
Next
Next
_startX = 0
_startY = 0
_mCount = 0
End method

method CreateMaze()
'first pick a start both MUST be odd and within borders
Repeat
If _startX = 0 And _startY = 0 Then
GetPosition()
_startX = _posX
_startY = _posY
Else
'pick a direction
local dir:int = int(Rnd(4))
local newx:int = _posX
local newy:int = _posY
local newPos:bool = False
' Print dir+" "+_mCount
Select dir
Case 0 'left
newx = _posX-2
If newx > 0 And not _maze[ newx, _posY ] Then
_maze[ _posX-1, _posY ] = true
Else
newPos = True
End If
Case 1 'right
newx = _posX+2
If newx < _mWidth-1 And not _maze[ newx, _posY ] Then
_maze[ _posX+1, _posY ] = True
Else
newPos = True
End If
Case 2 'up
newy = _posY-2
If newy > 0 And not _maze[ _posX, newy ] Then
_maze[ _posX, _posY-1 ] = True
Else
newPos = True
End If
Case 3 'down
newy = _posY+2
If newy < _mHeight-1 And not _maze[ _posX, newy ] Then
_maze[ _posX, _posY+1 ] = true
Else
newPos = True
End If
End Select

'check and repeat if not valid
If newPos Then
Repeat
Repeat
GetPosition()
Until _maze[ _posX, _posY ] = True
until Not (_maze[ _posX-1, _posY ] and _maze[ _posX+1, _posY ] and _maze[ _posX, _posY-1 ] and _maze[ _posX, _posY+1 ])
Else
_posX = newx
_posY = newy
End If

End If
If Not _maze[ _posX, _posY ] Then _mCount += 1
_maze[ _posX, _posY ] = True
Until _mCount = _mMax
end method

Method OnKeyEvent( event:KeyEvent ) Override
Select event.Type
case EventType.KeyDown
ZeroMaze()
CreateMaze()

RequestRender()
End select
End method

End



Offline 3DzForMe

  • Hero Member
  • *****
  • Posts: 826
Re: The Amazing Project
« Reply #8 on: October 31, 2019, 11:24:05 PM »
@iWasAdam, nice work, I dabbled a little with Monkey2, although I was a pretty strong MonkeyX advocate, mainly the HTML5 variant. The forums being culled was a bit rubbish though. You've inspired me to revisit MonkeyX2 - a little.

You've inspired me to download CerburusX - I always had 32-bit OS until recently, yeah I know.

Offline GaborD

  • Sr. Member
  • ****
  • Posts: 322
Re: The Amazing Project
« Reply #9 on: November 01, 2019, 07:29:08 PM »
Very cool! Really useful to have a code collection like this.
Now I want to make a maze based oldschool dungeon crawler. :)