What is the significance of Bresenhams Line of Sight algorithm in chasing and evading in games?

As far as i know and implemented this algorithm calulates the straight line between two given points. However while implementing it in game development i stored the points calculated using this algorithm in an array.Then im traversing this array for chasing and evading purpose. This looks to be working good with some angles only.In an pixel based environment/tile based.

What if there are some obstacles added in the paths of the two points? then this algorithm will not work right?

How well can we use the Bresenhams Line algorithm in game development?

  • \$\begingroup\$ wouldn't a cone be a better primitive than a line? \$\endgroup\$
    – Will
    Commented Mar 1, 2011 at 11:06
  • \$\begingroup\$ i dint understand \$\endgroup\$
    – GamDroid
    Commented Mar 1, 2011 at 11:11
  • \$\begingroup\$ line drawing is not the same as line of sight. The question is about a non-existent algorithm. Sounds like the questioner is not using the line drawing algorithm to draw lines, but instead plot "steps" for an AI. For this, there are many better solutions than using a line drawing algorithm. \$\endgroup\$ Commented Mar 1, 2011 at 16:22

1 Answer 1


Bresenhams line algorithm was very useful in history (history of computer graphics), where was need of drawing lines without using floating point operations, because integer operations are faster (was faster). This is not today problem. In cpu is integrated math co-procesor (till intel 486), there is SSE unit and also GPU computes floatng points. There are not many useful usages of Bresenham today. But still. It is very interesting historicaly and it is beatiful algorithm to study.

  • 2
    \$\begingroup\$ Actually, I'd say that Bresenham still has its share of uses, though they're admittedly more sparse. It's easy to modify the algorithm to iterate over all the 'pixels' covered by a line, and this can actually be immensely useful for things like the original poster's 2d line-of-sight raycasting question, if your object data is organized in a simple spatial grid and you need to know which grid cells to check for possible colliding objects. \$\endgroup\$ Commented Mar 1, 2011 at 20:16
  • \$\begingroup\$ Yeah. Also for 3D grid traversal (if edited to 3D) and we can continue. But there is no big (but there is question what is big) performance benefit in comparison to using vector abstraction with float operations. \$\endgroup\$
    – Notabene
    Commented Mar 1, 2011 at 21:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .