3

I want to implement missionaries and cannibals with python with different search algorithms. One of the algorithms is Greedy or A* that needs a heuristic function to work.

I cant think of any correct heuristic to work. Can you suggest a heuristic ?

Amirition
  • 328
  • 5
  • 22

2 Answers2

4

The correct heuristic function for missionaries and cannibals problem, we assume that in the first place, there are 3 missionaries and 3 cannibals on the left side, so :

h(x) = (cannibalsLeft + missionariesLeft) / 2 
Amirition
  • 328
  • 5
  • 22
0
heuristic = (no. of missionaries at right side + no. of cannibals at right side) – 1

The minus 1 (– 1) in the above expression is important to keep the heuristic function admissible

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103