My new friend, 23.09.2017

This is my new entity buddy.
He can already do quite a lot of things, here are some examples:

(missing picture)

The Scan and Movement Methods:

  • move(range, modificator)
    • → scan
    • moves randomly until the player enters his scan area (→range, →modificator)
    • follows and attacks the player when in range
    • avoids most obstacles (see other methods below)
  • seek(range modificator)
    • → scan
    • moves according to a move route set by → add_step
    • starts event when the player is in range
  • scan(range, modificator)
    • scans the area for the player (see examples below)
  • add_step(direction, count)
    • adds count times the move direction to the move route
    • for example:
      add_step(“up”, 2)
      add_step(“down”, 2)
      add_step(“left”, 3)
    • result:
      up, up, down, down, left, left, left
  • retrace_steps
    • moves its route set with add_step backwards

Scan area examples:

Round view: scan(2, true)

Forward view: scan(2) or scan(2, false)

Expanded view: scan(2, 6)

(more missing pictures)

Note: The scan method has no use on its own, it is only used within the move and seek methods using the same parameters.
move(2) → scan(2, false)
seek(3, true) → scan(3, true)
Round and expanded view cannot be combined.

Other methods:

  • find_path(range)
    • → clear_temp
    • → declare_area
    • → write_path
    • A summary method to initialize the pathfinding algorithm
  • clear_temp
    • resets all temporary variables
  • declare_area(range)
    • → find_middle_position
    • locates all obstacles in range
    • locates the player and the entity
    • → div
  • find_middle_position
    • returns the position between the player and the entity to optimize pathfinding
  • div(obstacle_count)
    • adjusts the maximum path length in relation to the surroundings to optimize pathfinding
  • write_path(position, direction)
    • → recalc_pos
    • searches every possible path to reach the player and automatically filters the shortest one
  • recalc_pos(x, y, d)
    • recalculates the coordinates x and y if you move in direction d
  • to_command(direction)
    • converts move direction (“up”, “down”, “left”, “right”), into a move command
  • invert_step(direction)
    • returns the opposite of the direction
      • “right” → “left”
      • “up” → “down”

There’s still a lot more to do but I’m making great progress and it’s extremely funny to interact with this little guy. (I made him go through labyrinths to test his pathfinding skills) See ya.