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

岛主提前搜索的实现方式

[复制链接]
门派:武当派
发表于 2018-12-21 21:13:11 | 显示全部楼层
kjrwd@tj 发表于 2018-12-21 21:08
那个没有上一句?不是都有注释吗?

我要对着文件才看的懂,等明天再看看
门派:武当派
 楼主| 发表于 2018-12-21 21:27:14 | 显示全部楼层
taot@tj 发表于 2018-12-21 21:13
我要对着文件才看的懂,等明天再看看

当然要对着文件来改呀。。
门派:武当派
发表于 2018-12-21 22:25:49 | 显示全部楼层
师兄,你这个加得思路很完美!   
但我想问问,你这里一直在找周围几里以内, 然后为wd_distance变量赋值, 但赋值之后好像没调用这个变量???
门派:武当派
发表于 2018-12-21 22:29:47 | 显示全部楼层
kjrwd@tj 发表于 2018-12-21 21:27
当然要对着文件来改呀。。

休息一下丽丽思绪明天接着改哈哈
门派:武当派
发表于 2018-12-21 22:30:31 | 显示全部楼层
mcyzcs@tj 发表于 2018-12-21 22:25
师兄,你这个加得思路很完美!   
但我想问问,你这里一直在找周围几里以内, 然后为wd_distance变量赋值, ...

你拿个现成的来            
门派:武当派
 楼主| 发表于 2018-12-21 22:35:11 | 显示全部楼层
mcyzcs@tj 发表于 2018-12-21 22:25
师兄,你这个加得思路很完美!   
但我想问问,你这里一直在找周围几里以内, 然后为wd_distance变量赋值, ...

这个在lujing里调用了,那段岛主的代码我没贴出来。。
门派:武当派
发表于 2018-12-21 22:35:41 | 显示全部楼层

你要??? 师兄写的部分我刚加进去了,正常运行,但我感觉好像没提前搜索,所以请教下
门派:武当派
发表于 2018-12-21 22:37:47 | 显示全部楼层
kjrwd@tj 发表于 2018-12-21 22:35
这个在lujing里调用了,那段岛主的代码我没贴出来。。

哦,是说好像差点啥,呵呵
门派:武当派
 楼主| 发表于 2018-12-21 22:38:08 | 显示全部楼层
mcyzcs@tj 发表于 2018-12-21 22:35
你要??? 师兄写的部分我刚加进去了,正常运行,但我感觉好像没提前搜索,所以请教下

这个是岛主写的代码。。
  1. function path_create()
  2.     local l_set
  3.     local l_num=0
  4.     local l_cnt=1
  5.         local l_cntt=1
  6.     road.detail={}
  7.     l_sett=0
  8.         l_settt=0
  9.     l_path=path_cal()
  10.     --Note(l_path)
  11.     if type(l_path)~='string' then
  12.        if math.random(1,4)==1 then
  13.           l_path='stand;out;northeast;northwest;southeast;southwest;south;south;south;south;south'
  14.        elseif math.random(1,4)==2 then
  15.           l_path='stand;out;northeast;northwest;southeast;southwest;east;east;east;east;east;east'
  16.        elseif math.random(1,4)==3 then
  17.           l_path='stand;out;northeast;northwest;southeast;southwest;west;west;west;west;west;west'
  18.        else
  19.           l_path='stand;out;northeast;northwest;southeast;southwest;north;north;north;north;north'
  20.        end
  21.     end
  22.     l_set=utils.split(l_path,';')  --一个alias里有几个命令
  23.         l_settt=table.getn(l_set)
  24.         --print(l_path)
  25.         if wdgostart==1 then
  26.           if l_settt<= wd_distance then l_settt=wd_distance end
  27.       for i=1,table.getn(l_set) do
  28.                 if i<l_settt-wd_distance-2 then
  29.             if string.find(l_set[i],'#') then
  30.                     if l_num>0 then
  31.                       l_cnt=l_cnt+1
  32.                 end
  33.                     road.detail[l_cnt]=l_set[i]
  34.                     l_cnt=l_cnt+1
  35.                     l_num=0
  36.                 else
  37.                     if l_num==0 then
  38.                       road.detail[l_cnt]=l_set[i]
  39.                     else
  40.                       road.detail[l_cnt]=road.detail[l_cnt]..';'..l_set[i]
  41.                 end
  42.                     l_num=l_num+1
  43.                     if l_num>road.steps then
  44.                        l_cnt=l_cnt+1
  45.                        l_num=0
  46.                     end
  47.             end
  48.                 else
  49.            if string.find(l_set[i],'#') then
  50.                     if l_num>0 then
  51.                       l_cnt=l_cnt+1
  52.                 end
  53.                     road.detail[l_cnt]=l_set[i]
  54.                     l_cnt=l_cnt+1
  55.                     l_num=0
  56.                 else
  57.                     if l_num==0 then
  58.                       road.detail[l_cnt]=l_set[i]
  59.                     else
  60.                       road.detail[l_cnt]=road.detail[l_cnt]..';'..l_set[i]
  61.                 end
  62.                     l_num=l_num+1
  63.                     if l_num>0 then
  64.                        l_cnt=l_cnt+1
  65.                        l_num=0
  66.                     end
  67.             end
  68.                 end
  69.       end
  70.         else
  71.             for i=1,table.getn(l_set) do
  72.           if string.find(l_set[i],'#') then
  73.                 if l_num>0 then
  74.                   l_cnt=l_cnt+1
  75.             end
  76.                 road.detail[l_cnt]=l_set[i]
  77.                 l_cnt=l_cnt+1
  78.                 l_num=0
  79.               else
  80.                 if l_num==0 then
  81.                   road.detail[l_cnt]=l_set[i]
  82.                 else
  83.                   road.detail[l_cnt]=road.detail[l_cnt]..';'..l_set[i]
  84.             end
  85.                 l_num=l_num+1
  86.                 if l_num>road.steps then
  87.                    l_cnt=l_cnt+1
  88.                    l_num=0
  89.                 end
  90.           end
  91.         end
  92.         end
  93. end
复制代码
门派:武当派
 楼主| 发表于 2018-12-21 22:44:02 | 显示全部楼层
mcyzcs@tj 发表于 2018-12-21 22:37
哦,是说好像差点啥,呵呵

岛主很有想法的。。。。        
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-6-30 04:18 , Processed in 0.020491 second(s), 23 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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