查看: 2150|回复: 0

[已经过期] 空心菱形问题

[复制链接]
梦石
0
星屑
9292
在线时间
2504 小时
注册时间
2011-5-20
回帖
14521

开拓者

发表于 2013-10-19 18:38:25 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
[pre lang="ruby" line="1"]#环菱形
    when 4
      delete = []
      p delete
      for i in more_step
        x = position[0]
        y = position[1]
        # 无视障碍物的场合
        if through
          # 下
          if !position.include?([x, y + 1])
            position.push([x, y + 1])
            route.push(route + [2])
            if route.size + 1 < max
              more_step.push(route.index(route + [2]))
              if route.size + 1 < max-1
                delete.push(position.push([x, y + 1]),route.index(route + [2]))
              end
            end
          end
          # 左
          if !position.include?([x - 1, y])
            position.push([x - 1, y])
            route.push(route + [4])
            if route.size + 1 < max
              more_step.push(route.index(route + [4]))
              if route.size + 1 < max-1
                delete.push(position.push([x - 1, y]),route.index(route + [4]))
              end
            end
          end
          # 右
          if !position.include?([x + 1, y])
            position.push([x + 1, y])
            route.push(route + [6])
            if route.size + 1 < max
              more_step.push(route.index(route + [6]))
              if route.size + 1 < max-1
                delete.push(position.push([x - 1, y]),route.index(route + [6]))
              end
            end
          end
          # 上
          if !position.include?([x, y - 1])
            position.push([x, y - 1])
            route.push(route + [8])
            if route.size + 1 < max
              more_step.push(route.index(route + [8]))
              if route.size + 1 < max-1
                delete.push(position.push([x, y - 1]),route.index(route + [8]))
              end
            end
          end
          p delete
          for i in delete
            position.delete(i)
          end
          return position
         
        # 非无视障碍物的场合
        else
          # 下
          if !position.include?([x, y + 1]) and !on_area?(x, y, type) and
            (@battler.passable?(x, y, 2) or (on_area?(x, y + 1, type) and type != 4))
            position.push([x, y + 1])
            route.push(route + [2])
            if route.size + 1 < max
              more_step.push(route.index(route + [2]))
            end
            end
          # 左
          if !position.include?([x - 1, y]) and !on_area?(x, y, type) and
            (@battler.passable?(x, y, 4) or (on_area?(x - 1, y, type) and type != 4))
            position.push([x - 1, y])
            route.push(route + [4])
            if route.size + 1 < max
              more_step.push(route.index(route + [4]))
            end
          end
          # 右
          if !position.include?([x + 1, y]) and !on_area?(x, y, type) and
            (@battler.passable?(x, y, 6) or (on_area?(x + 1, y, type) and type != 4))
            position.push([x + 1, y])
            route.push(route + [6])
            if route.size + 1 < max
              more_step.push(route.index(route + [6]))
            end
          end
          # 上
          if !position.include?([x, y - 1]) and !on_area?(x, y, type) and
          (@battler.passable?(x, y, 8) or (on_area?(x, y - 1, type) and type != 4))
            position.push([x, y - 1])
            route.push(route + [8])
            if route.size + 1 < max
              more_step.push(route.index(route + [8]))
            end
          end
        end
      end[/pre]

脚本是这样···正常效果是要获得一个空心的菱形,可是实际应用效果却是无论怎么定义都获得一个最小的菱形···
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部