Navigation

    forum

    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    1. Home
    2. TheIncredibleWheelOfCheese
    • Flag Profile
    • block_user
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Groups
    • Blog

    TheIncredibleWheelOfCheese

    @TheIncredibleWheelOfCheese

    2
    Posts
    1636
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    TheIncredibleWheelOfCheese Follow

    Posts made by TheIncredibleWheelOfCheese

    • RE: RoomPosition.isWalkable

      @poma This is just a rewrite of OP's code. It has the same features and defects, but it performs better.

      @ayrtep said in RoomPosition.isWalkable:

      https://gist.github.com/anonymous/bc4ccac0cea464d0e98a9a176035808f#file-gistfile1-txt

      posted in Feature Requests
      TheIncredibleWheelOfCheese
    • RE: RoomPosition.isWalkable

      I know this is quite old, but the code @ayrtep came up with can be simplified a lot using lodash, and made more efficient by creating a lookup of obstacle types. This makes the function time complexity linear over the number of entities at the position (O(n)) instead of quadratic over the number of entities and the number of obstacle types (O(n2)).

      const isObstacle = _.transform(
          OBSTACLE_OBJECT_TYPES,
          (o, type) => { o[type] = true; },
          {}
      );
      
      function isEnterable(pos) {
          return _.every(pos.look(), item =>
              item.type === 'terrain' ?
              item.terrain !== 'wall' :
              !isObstacle[item.structureType]
          );
      }
      
      posted in Feature Requests
      TheIncredibleWheelOfCheese