Win a copy of Programmers Guide to Apache Thrift this week in the Open Source forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

How do i code for neighbour links for a maze creation program  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 def initialize
   super MAP_WIDTH, MAP_HEIGHT, false
   self.caption = "Map Creation"
   @path = nil

   x_cell_count = MAP_WIDTH / CELL_DIM
   y_cell_count = MAP_HEIGHT / CELL_DIM

   @columns = Array.new(x_cell_count)
   column_index = 0

   # first create cells for each position
   while (column_index < x_cell_count)
     row = Array.new(y_cell_count)
     @columns[column_index] = row
     row_index = 0
     while (row_index < y_cell_count)
       cell = Cell.new()
       @columns[column_index][row_index] = cell
       row_index += 1
     end
     column_index += 1
   end

   # now set up the neighbour links
   # You need to do this using a while loop with another
   # nested while loop inside.

 end
 
"I know this defies the law of gravity... but I never studied law." -B. Bunny Defiant tiny ad:
ScroogeXHTML - small and flexible RTF to HTML converter library
https://coderanch.com/t/710903/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!