当前位置: 首页 > 知识库问答 >
问题:

PCG伪马泽算法?

江光明
2023-03-14

我使用photoshop创建了一组瓷砖:

我正在寻找一种方法来填充这些80x80瓷砖的屏幕,其中大多数区域是相连的。这是一个吃豆人风格游戏的游戏板,而不是一个有入口和出口的迷宫。

我唯一的目标是永远不要有一个面向墙壁的开口。

我目前通过从基于上一个瓷砖的子集中随机选择下一个瓷砖来实现这一点,因此如果最后一个瓷砖左侧有墙,那么下一个砖就不能左侧有开口。我还将拐角限制为较小的子集。这只适用于第一行。

我的问题是计算其余的行,这将不得不基于立即向左或立即向右的磁贴。我认为手工构建表格会变得很麻烦。(不是说努力工作有什么问题,而是低效的工作不好)。

这是我编写的代码,用于根据左侧的最新磁贴获取允许的下一个磁贴:

function getallowed(last_tile,x,y) as 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 then 
    if y=0 then
        ?"LEFTCOL AND TOPROW",x,y,last_tile
        selection=intersect(leftcol,toprow)
    else if y=8 then
        ?"LEFTCOL AND BOTTOMROW",x,y,last_tile
        selection=intersect(leftcol,bottomrow)
    else if y > 0 and y < 8 then
        ?"LEFTCOL AND FLOATING Y" ,x,y,last_tile
        selection=leftcol 'intersect(initsel,leftcol)
    end if
else if x=15 then 
    if y=0 then
        ?"RIGHTCOL AND TOPROW",x,y,last_tile
        selection=intersect(rightcol,toprow)
    else if y=8 then
        ?"RIGHTCOL AND BOTTOMROW",x,y,last_tile
        selection = intersect(rightcol,bottomrow)
    else if y>0 and y<8 then
        initsel = cselect[last_tile]
        ?"RIGHTCOL AND FLOATING Y",x,y,last_tile
        selection=intersect(initsel,rightcol)
    end if

    'x=1, y=0, last_tile= "ul"
else if x > 0 and x < 15 
    if y=0 then
        initsel = cselect[last_tile]
        ?"FLOATING X AND TOPROW",x,y,last_tile
        selection=intersect(initsel,toprow)
        'selection=toprow
    else if y=8 
        initsel = cselect[last_tile]
        ?"FLOATING X AND BOTTOM ROW",x,y,last_tile
        selection=intersect(initsel,bottomrow)
    else if y >0 and y < 8 then
        ?"NO CONDITIONS MATCHED RETURN FULL SET FOR LAST TILE",x,y,last_tile
        selection=cselect[last_tile]
    end if
end if
return selection
end function



function intersect(a, b)
    d = {}
    results = []

    for i = 0 to b.count()-1
        d[b[i]] = true
    end for
    for j = 0 to a.count()-1
        if d[a[j]] <> invalid then
            if d[a[j]] then
                results.push(a[j])
            end if
        end if
    end for
    return results
end function

使用我目前的方法,我将不得不为四个方向中的每一个创建一个表,并手动完成。

有人有其他建议或算法要建议吗?

共有1个答案

狄天逸
2023-03-14

如果你不想使用一般的迷宫生成算法,你可以尝试王瓦片或更高级的人字形王瓦片。

 类似资料:
  • 一面(0830) 先是自我介绍,然后深挖论文 然后问了一些多模态大模型的八股(感觉他们还是比较在意大模型) 没有问比较基础的东西 手撕题目比较简单leetcode.20 整个流程就50分钟不到,不知道结果会咋样😂,别是kpi面啊 (最近还面了京东,百度,都比较复杂,还在整理面经,算法岗太难了)

  • 最长塔的长度为6,从上到下包括: 下面是书中的解决方案: “当我们把这个问题的绒毛都剪掉的时候,我们就能明白问题其实是下面的了。

  • 第一题签到题秒杀。 第二题手撕cnn卷积层,不让切本地ide,本人太水了记不清楚numpy操作,输入字符串看起来也很难处理,直接放弃 第三题骗分就能拿40%多,硬撕了半个小时提到了69。 考到一半收到携程约面试,考完发现全约满了😵

  • 面完一小时内流程结束,挂

  • 100%, 0% 第二题快结束的时候想出来的思路,可惜结尾的 stack[:n - k] 写成 stack[:k] 了。。。 T2 题目 第一行输入两个整数 num 和 k,要求从 num 中删去 k 个数字,使得剩下的数字组成的数最小,并输出最小的整数。数据范围:k <= num.length <= 10^5 示例 输入:10200 1 输出:200 分析 本题考查贪心算法,每次优化可优化的最高

  • 1. 项目难点是什么 怎么解决 2. 3个看代码输出(作用域) 3. 数组去重 4.防抖 节流 5. 浏览器缓存 6.cookie localstorage区别 7.http和https 8.浏览器输入url过程 9.类的继承方式有哪些 10.apply call bind区别 11.vue的双向绑定 12.设计模式有哪些 13.display的属性有哪些 14.行内块和行内元素区别 15.自己写