2d games - PCG pseudomaze algorithm? -


i created set of tiles using photoshop:

enter image description here

i'm looking way fill screen of these 80x80 tiles, areas connected. game board pac man style game, not maze entry , exit.

my goal here never have opening facing wall.

i'm doing choosing next tile randomly subset based on last tile, if last tile has wall on left, next tile can't have opening on left. i'm limiting corners smaller subset. works first row.

my problem calculating rest of rows, have based on tile left, or right. think cumbersome build tables hand. (not there wrong hard work, inefficient work isn't good).

current output looks this:enter image description here

here code wrote getting allowed next tiles based on recent tile on left:

function getallowed(last_tile,x,y) object  cselect={u : ["u","r","v","rx"]             v : ["u","d","r","v","rx"]             l : ["u","d","v","rx"]             d : ["d","r","v","rx"]             lx :["u","d","r","v","rx"]             r : ["lx","ux","dx","h","c"]             h : ["lx","ux","dx","l","h","c"]             c : ["lx","ux","dx","l","h","c"]             ux :["lx","ux","dx","l","h","c"]             rx :["lx","ux","dx","l","h","c"]             dx :["lx","ux","dx","l","h","c"]             ul :["dx","br","ur","ux","lx","h","c"]             ur :["ul","bl","rx","d","r","u","v"]             bl :["ur","lx","ux","br","dx","c","h","l"]             br :["ul","bl","rx","r","u","v","d"]}   toprow=["d","r","h","l","dx","ul","ur"] 'toprow=["d","dx","l","r"] leftcol=["d","r","v","u","rx","ul","bl"] rightcol=["d","l","v","u","lx","ur","br"] bottomrow=["u","r","h","l","ux","bl","br"]    if x=0      if y=0         ?"leftcol , toprow",x,y,last_tile         selection=intersect(leftcol,toprow)     else if y=8         ?"leftcol , bottomrow",x,y,last_tile         selection=intersect(leftcol,bottomrow)     else if y > 0 , y < 8         ?"leftcol , floating y" ,x,y,last_tile         selection=leftcol 'intersect(initsel,leftcol)     end if else if x=15      if y=0         ?"rightcol , toprow",x,y,last_tile         selection=intersect(rightcol,toprow)     else if y=8         ?"rightcol , bottomrow",x,y,last_tile         selection = intersect(rightcol,bottomrow)     else if y>0 , y<8         initsel = cselect[last_tile]         ?"rightcol , floating y",x,y,last_tile         selection=intersect(initsel,rightcol)     end if      'x=1, y=0, last_tile= "ul" else if x > 0 , x < 15      if y=0         initsel = cselect[last_tile]         ?"floating x , toprow",x,y,last_tile         selection=intersect(initsel,toprow)         'selection=toprow     else if y=8          initsel = cselect[last_tile]         ?"floating x , bottom row",x,y,last_tile         selection=intersect(initsel,bottomrow)     else if y >0 , y < 8         ?"no conditions matched return full set last tile",x,y,last_tile         selection=cselect[last_tile]     end if end if return selection end function    function intersect(a, b)     d = {}     results = []      = 0 b.count()-1         d[b[i]] = true     end     j = 0 a.count()-1         if d[a[j]] <> invalid             if d[a[j]]                 results.push(a[j])             end if         end if     end     return results end function 

using current method have create table each of 4 directions, , hand.

does have suggestion or algorithm suggest?

if don't want use general maze-generation algorithms, can try wang tiles or more advanced herringbone wang tiles.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -