예제 #1
0
파일: Node.php 프로젝트: etcinit/snakes
 /**
  * Check whether another node is near by the their identifier
  *
  * @param Node $otherNode
  * @return bool
  */
 public function isNear(Node $otherNode)
 {
     $otherIdentifier = $otherNode->getIdentifier();
     if ($otherIdentifier->getSize() != $this->identifier->getSize()) {
         return false;
     }
     $differences = 0;
     for ($i = 0; $i < $this->dimensions; $i++) {
         if ($otherIdentifier[$i] != $this->identifier[$i]) {
             $differences++;
         }
         if ($differences > 1) {
             return false;
         }
     }
     return true;
 }