Knight-Path 1.0.D018
|
00001 // 00002 // knight-path - shortest knight path between two squares 00003 // Copyright (C) 2011 Peter Miller 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 3 of the License, or (at 00008 // your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License along 00016 // with this program. If not, see <http://www.gnu.org/licenses/>. 00017 // 00018 00019 #ifndef KNIGHT_PATH_TAXI_DISTANCE_H 00020 #define KNIGHT_PATH_TAXI_DISTANCE_H 00021 00022 #include <knight-path/position.h> 00023 00035 class taxi_distance 00036 { 00037 public: 00042 ~taxi_distance() { } 00043 00050 taxi_distance(const position &agoal) : goal(agoal) { } 00051 00061 bool 00062 operator()(const position &lhs, const position &rhs) 00063 { 00064 return (goal.distance(lhs) < goal.distance(rhs)); 00065 } 00066 00073 taxi_distance(const taxi_distance &rhs) : 00074 goal(rhs.goal) 00075 { 00076 } 00077 00084 taxi_distance &operator=(const taxi_distance &rhs) 00085 { 00086 if (this != &rhs) 00087 { 00088 goal = rhs.goal; 00089 } 00090 return *this; 00091 } 00092 00093 private: 00099 position goal; 00100 00104 taxi_distance(); 00105 }; 00106 00107 #endif // KNIGHT_PATH_TAXI_DISTANCE_H