Author Topic: Maze Generator  (Read 2942 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Maze Generator
« Reply #15 on: June 09, 2020, 10:48:07 pm »
There it is! What did you do to get rid of dots?

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Maze Generator
« Reply #16 on: June 10, 2020, 12:13:11 am »
I did what you said mostly and just made a double loop. :)

Code: QB64: [Select]
  1. FOR checkx = 50 TO 750
  2.     FOR checky = 50 TO 575
  3.         IF POINT(checkx, checky) = _RGB32(0, 0, 0) AND POINT(checkx + 1, checky) = _RGB32(255, 255, 255) AND POINT(checkx, checky + 1) = _RGB32(255, 255, 255) AND POINT(checkx - 1, checky) = _RGB32(255, 255, 255) AND POINT(checkx, checky - 1) = _RGB32(255, 255, 255) THEN PSET (checkx, checky), _RGB32(255, 255, 255)
  4.     NEXT checky
  5. NEXT checkx
  6.  

Offline Virtusoroca

  • Newbie
  • Posts: 24
    • View Profile
Re: Maze Generator
« Reply #17 on: June 10, 2020, 12:22:37 am »
@bplus thanks for the link regarding mazes. Im going to look into it for sure. Working in text mode here, so there is always some different trick to explore. ;)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Maze Generator
« Reply #18 on: June 10, 2020, 09:59:17 am »
@SierraKen ha! I skimmed over your code too quickly glad the 4 points worked.

@Virtusoroca yeah, I don't know if I could have figured out maze building on my own, nice that every cell is accessible to every other cell, it might be a little better if one could do the maze with one array instead of 2. I have worked out some pathfinder code to find shortest route from one cell to another.

Offline Virtusoroca

  • Newbie
  • Posts: 24
    • View Profile
Re: Maze Generator
« Reply #19 on: June 10, 2020, 10:11:34 am »
@bplus great! I will look for it in you maze game. Downloaded it yesterday. Ive looked up some pathfinding algorithms. After the backtrack for the maze I will probably start with the wave propagation (Dijkstra's algorithm) for the pathfinding. A* algorithm seems to be a more complex implementation to me.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Maze Generator
« Reply #20 on: June 10, 2020, 10:20:45 am »
@bplus great! I will look for it in you maze game. Downloaded it yesterday. Ive looked up some pathfinding algorithms. After the backtrack for the maze I will probably start with the wave propagation (Dijkstra's algorithm) for the pathfinding. A* algorithm seems to be a more complex implementation to me.

Yeah I started by reading about A* someone else posted about and then went my own way here:
B+ Pathfinder is a sort of study
https://www.qb64.org/forum/index.php?topic=410.msg2878#msg2878

Later I did some code for running a mouse through a maze and later a Smart snake for the Classic Snake Game.