dictionary - Java: How to check if a generated level is possible? -


i've created text based game automatically generates map 10x10 rooms, few of rooms blocked various debris , couldn't work out efficient way check if player can still reach key , exit without them being cut off map.

currently there's low chance needed rooms cut off rest of map, making level impossible, thought checking each adjacent square start position, , repeat , repeat until of squares accessible set 'accessible' in variable , if 3 objects aren't reachable regen'ing map again until are. may slow if regens few times though.

does have thoughts on repetitive part keep fast, or better way of achieving this?

here's image of generated map: #'s blocked rooms. http://postimg.org/image/8oo88jxgb/

you can use dijkstra's algorithm, or other pathfinding algorithm, check if there way room entrance each object , discard invalid rooms. bit slow though, specially if rooms bigger or add more objects.

a better option guarantee construction each part of room can reached. can achieved using binary space partioning (bsp). can used create random dungeons while assuring rooms connected. can find more information in this tutorial.

there lot of material procedurally generated dungeons around. can check interesting tutorial here.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -