Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by SilverStaff · Apr 09, 2015 at 04:31 AM · c#errorproceduralroguelike

Errors in Procedurally Generated Dungeon

I am making a procedurally generated dungeon with rooms and pathways (for a roguelike). My GameController code is basically my whole game right now. It successfully generates the dungeon most of the time, but I have two errors, likely in the methods "UnifyDungeon" and "ConnectStuff":

1) ArgumentOutOfRange exception occurs about 25% of the time and breaks the program. I think I just have a bad line of code somewhere, this only started occurring today.

2) Algorithmic problem that always occurs but does not impede the program's function. Of course I would still like to fix it.

I explain my program below, but I am almost exactly following the steps on: http://journal.stuffwithstuff.com/2014/12/21/rooms-and-mazes/

Explanation of my program: DesignRooms -> PlacePaths -> ERRORS: UnifyDungeon -> PlaceGrid

DesignRooms: Generates a lot of randomly sized "rooms" then tries to place them on the map (stored as a 2D array of integers as "finalGridArray"). Successfully placed rooms get stored in "roomsFinalArray" list. This works fine.

PlacePaths: Uses Prim's algorithm to generate a maze structure in between the rooms. This also works fine.

ERRORS: UnifyDungeon: Goal is to place "doorways" so that all the rooms are reachable. This is where I am getting errors. I already have each tile of the map stored in "finalGridArray". I made a list of "Connector"s which are wall tiles between room/pathway or room/room. I assigned a room as the "merged" region into which I merge everything else. I pick a random Connector adjacent to the merged area, turn it into a doorway, then remove all the connectors connecting that same new room to the merged area. This step is generating the problems. Somehow I am not removing all of the connectors between the new room and the merged area. Then I add the new room to the merged area and repeat until all the rooms are in the merged area (and all the connectors should be gone). ConnectStuff is a function only used in UnifyDungeons and is likely where the problems are.

PlaceGrid: Places blocks on the game world using "floorGridArray" as the map. This works fine.

My project is here: https://www.dropbox.com/s/zpdwoops4imc73z/ProjectBuild.unitypackage?dl=0

I really appreciate any help you guys can give. I'm really stuck. I only took a short introductory CS class and am trying to learn more on my own so I apologize if my code is ugly. :)

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Error CS0029: Cannot implicitly convert type to UnityEngine.UI.Transform 1 Answer

Filling area under linerenderer 2 Answers

[Solved]List.FindIndex error C# 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges