找回密码
 注册
搜索
楼主: kjrwd@tj

岛主提前搜索的实现方式

[复制链接]
门派:武当派
发表于 2018-12-21 22:47:37 | 显示全部楼层
function path_create()
    local l_set
    local l_num=0
    local l_cnt=1
        local l_cntt=1
    road.detail={}
    l_sett=0
        l_settt=0
    l_path=path_cal()
    --Note(l_path)
    if type(l_path)~='string' then
       if math.random(1,4)==1 then
          l_path='stand;out;northeast;northwest;southeast;southwest;south;south;south;south;south'
       elseif math.random(1,4)==2 then
          l_path='stand;out;northeast;northwest;southeast;southwest;east;east;east;east;east;east'
       elseif math.random(1,4)==3 then
          l_path='stand;out;northeast;northwest;southeast;southwest;west;west;west;west;west;west'
       else
          l_path='stand;out;northeast;northwest;southeast;southwest;north;north;north;north;north'
       end
    end
    l_set=utils.split(l_path,';')  --一个alias里有几个命令
        l_settt=table.getn(l_set)
        --print(l_path)
        if wdgostart==1 then
          if l_settt<= wd_distance then l_settt=wd_distance end
      for i=1,table.getn(l_set) do
                if i<l_settt-wd_distance-2 then
            if string.find(l_set[i],'#') then
                    if l_num>0 then
                      l_cnt=l_cnt+1
                end
                    road.detail[l_cnt]=l_set[i]
                    l_cnt=l_cnt+1
                    l_num=0
                else
                    if l_num==0 then
                      road.detail[l_cnt]=l_set[i]
                    else
                      road.detail[l_cnt]=road.detail[l_cnt]..';'..l_set[i]
                end
                    l_num=l_num+1
                    if l_num>road.steps then
                       l_cnt=l_cnt+1
                       l_num=0
                    end
            end
                else
           if string.find(l_set[i],'#') then
                    if l_num>0 then
                      l_cnt=l_cnt+1
                end
                    road.detail[l_cnt]=l_set[i]
                    l_cnt=l_cnt+1
                    l_num=0
                else
                    if l_num==0 then
                      road.detail[l_cnt]=l_set[i]
                    else
                      road.detail[l_cnt]=road.detail[l_cnt]..';'..l_set[i]
                end
                    l_num=l_num+1
                    if l_num>0 then
                       l_cnt=l_cnt+1
                       l_num=0
                    end
            end
                end
      end
        else
            for i=1,table.getn(l_set) do
          if string.find(l_set[i],'#') then
                if l_num>0 then
                  l_cnt=l_cnt+1
            end
                road.detail[l_cnt]=l_set[i]
                l_cnt=l_cnt+1
                l_num=0
              else
                if l_num==0 then
                  road.detail[l_cnt]=l_set[i]
                else
                  road.detail[l_cnt]=road.detail[l_cnt]..';'..l_set[i]
            end
                l_num=l_num+1
                if l_num>road.steps then
                   l_cnt=l_cnt+1
                   l_num=0
                end
          end
        end
        end
end

帮师兄转过来一起吧,这是lujing.lua里的
门派:武当派
发表于 2018-12-21 22:49:54 | 显示全部楼层
kjrwd@tj 发表于 2018-12-21 22:44
岛主很有想法的。。。。

嗯,我觉得我想把他用到官府那个寻路上去看看效果是不是更好点
门派:武当派
 楼主| 发表于 2018-12-21 22:56:11 | 显示全部楼层
mcyzcs@tj 发表于 2018-12-21 22:49
嗯,我觉得我想把他用到官府那个寻路上去看看效果是不是更好点

可以试试看嘛,官府job有时给的范围太大了,对了馆长的一个帖子说不定也有用。
门派:武当派
发表于 2018-12-22 01:11:29 | 显示全部楼层
kjrwd@tj 发表于 2018-12-21 22:38
这个是岛主写的代码。。

原来如此,好好好好的很啊
门派:武当派
发表于 2018-12-22 01:12:31 | 显示全部楼层
mcyzcs@tj 发表于 2018-12-21 22:35
你要??? 师兄写的部分我刚加进去了,正常运行,但我感觉好像没提前搜索,所以请教下

你慢慢调试,有什么优势功能发出来我来帮你一起实验
门派:武当派
 楼主| 发表于 2018-12-22 01:16:57 | 显示全部楼层
taot@tj 发表于 2018-12-22 01:11
原来如此,好好好好的很啊

找到了就研究研究吧。早日成功。。
门派:武当派
发表于 2018-12-22 02:25:05 | 显示全部楼层
kjrwd@tj 发表于 2018-12-22 01:16
找到了就研究研究吧。早日成功。。

是啊,这可花费了我好多时间呢      
门派:武当派
 楼主| 发表于 2018-12-22 09:10:31 | 显示全部楼层
taot@tj 发表于 2018-12-22 02:25
是啊,这可花费了我好多时间呢

这就叫成功不负有心人。。
门派:武当派
发表于 2018-12-22 09:18:23 | 显示全部楼层
kjrwd@tj 发表于 2018-12-22 09:10
这就叫成功不负有心人。。

师兄早呀,昨天把你那另一部分代码写进去就一切ok了
门派:武当派
发表于 2018-12-22 09:19:40 | 显示全部楼层
说的跑酷就是把road.wat 从0.2 改成0.1 吗???
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|书剑永恒MUD ( 闽ICP备14012032号|闽公网安备 35050202000162号 )

GMT+8, 2025-6-30 12:26 , Processed in 0.031151 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表