title: Using Linear Coordinates to Check Against AI
body: <p>I'm working on some artificial intelligence, and I want to be able for my AI not to run into given coordinates as these are references of a wall/boundary.</p>
  
  <p>To begin with, every time my AI hits a wall, it makes a reference to that position (x, y). When it hits the same wall three times, it uses linear check points to 'imagine' there is a wall going through these coordinates.</p>
  
  <p>I want to now prevent my AI from going into that wall again.</p>
  
  <p>To detect if my coordinates make a straight line, I use:</p>
  
  <pre><code>private boolean collinear(double x1, double y1, double x2, double y2, double x3, double y3) {
      return (y1 - y2) * (x1 - x3) == (y1 - y3) * (x1 - x2);
  }
  </code></pre>
  
  <p>This returns true is the given points are linear to one another.</p>
  
  <p>So my problems are:</p>
  
  <ol>
  <li><p>How do I determine whether my robot is approaching the wall from its current trajectory?</p></li>
  <li><p>Instead of Java 'imagining' there's a line from 1, to 3. But to 'imagine' a line all the way through these linear coordinantes, until infinity (or close).</p></li>
  </ol>
  
  <p>I have a feeling this is going to require some confusing trigonometry?</p>