The goal for the Hanoi domain is to have all disks ordered in the rightmost tower, that is, the tower with the highest index in simulator::towers_. In Plansim, the object that captures this concept is plansim::goal. Goals may be evaluated or not, evaluated goals must define an evaluation function.
We will call this class hanoi::all_disks_in_rightmost_tower. Since it will be evaluated, it is derived from plansim::evaluated_goal. We will take as basis the evaluated_goal_template.hpp and evaluated_goal_template.cpp files under the examples/templates directory. These files will be used to create the all_disks_in_rightmost_tower.hpp and all_disks_in_rightmost_tower.cpp, respectively. All occurrences of $domain$ in these files are replaced by 'hanoi', and all occurrences of $object$ in these files are replaced by the class name, in our case 'all_disks_in_rightmost_tower'. For the Hanoi domain we have this single goal.
Every plansim::goal object (and plansim::evaluated_goal is a plansim::goal) must indicate if the current simulator state satisfy it. This is done by implementing the goal::is_satisfied_by_current_simulator_state method. In our case, the implementation looks like:
bool all_disks_in_rightmost_tower:: is_satisfied_by_current_simulator_state() const { // Check here if goal is satisfied // We simply check if the number of disks in the rightmost tower // is equal to the total number of disks in the instance return s_->towers_[ s_->towers_.size() - 1 ].size() == s_->total_number_of_disks_; }
We also make hanoi::all_disks_in_rightmost_tower a friend from hanoi::simulator, for the same reason described in Section 3.