Ahmed Nasser Saleh
Welcome 
PROBLEM STATEMENT
• A FARMER WITH HIS WOLF, GOAT, AND CABBAGE COME TO THE EDGE OF A
RIVER THEY WISH TO CROSS. THERE IS A BOAT AT THE RIVER’S EDGE, BUT, OF
COURSE, ONLY THE FARMER CAN ROW. THE BOAT ALSO CAN CARRY ONLY
TWO THINGS (INCLUDING THE ROWER) AT A TIME. IF THE WOLF IS EVER LEFT
ALONE WITH THE GOAT, THE WOLF WILL EAT THE GOAT; SIMILARLY, IF THE
GOAT IS LEFT ALONE WITH THE CABBAGE, THE GOAT WILL EAT THE CABBAGE.
WRITE A PROLOG TWO PROGRAMS TO FIND THE SEQUENCE OF CROSSINGS
OF THE RIVER SO THAT ALL FOUR CHARACTERS ARRIVE SAFELY ON THE
OTHER SIDE OF THE RIVER
The initial state and goal
state
Initial statue we start with state go(Farmer , left wolf , left goat , left cabbage , left wolf , left goat ,
left cabbage
And farmer will take value with 1 or 0 , zero mean the farmer is in the left side
and one mean that the farmer is in the right side
And the number of wolf , goat , cabbage in the left and in the right
The start state with all the farmer, wolf , cabbage and goat in the left side and the
goal state that all the number of farmer, wolf , cabbage and goat move to left.
All possible move
s.I can move to goat , cabbage , wolf to right or to the left but I can’t leave wolf with
goat without farmer and can’t leave goat with cabbage without also farmer .
So I will make all possible move .
so the Start state and the path :
:
Get Children of the node and add node to be visited and remov
e it function ::
Move State ::
The Moves and How To Print Solution
Thanks
I am sorry if there was any
Mistake .
CPR :: SNGV
ahmednasser1993@gmail.com

farmer , Cabbage , Goat , Wolf Assignment

  • 1.
  • 2.
    PROBLEM STATEMENT • AFARMER WITH HIS WOLF, GOAT, AND CABBAGE COME TO THE EDGE OF A RIVER THEY WISH TO CROSS. THERE IS A BOAT AT THE RIVER’S EDGE, BUT, OF COURSE, ONLY THE FARMER CAN ROW. THE BOAT ALSO CAN CARRY ONLY TWO THINGS (INCLUDING THE ROWER) AT A TIME. IF THE WOLF IS EVER LEFT ALONE WITH THE GOAT, THE WOLF WILL EAT THE GOAT; SIMILARLY, IF THE GOAT IS LEFT ALONE WITH THE CABBAGE, THE GOAT WILL EAT THE CABBAGE. WRITE A PROLOG TWO PROGRAMS TO FIND THE SEQUENCE OF CROSSINGS OF THE RIVER SO THAT ALL FOUR CHARACTERS ARRIVE SAFELY ON THE OTHER SIDE OF THE RIVER
  • 3.
    The initial stateand goal state Initial statue we start with state go(Farmer , left wolf , left goat , left cabbage , left wolf , left goat , left cabbage And farmer will take value with 1 or 0 , zero mean the farmer is in the left side and one mean that the farmer is in the right side And the number of wolf , goat , cabbage in the left and in the right The start state with all the farmer, wolf , cabbage and goat in the left side and the goal state that all the number of farmer, wolf , cabbage and goat move to left.
  • 4.
    All possible move s.Ican move to goat , cabbage , wolf to right or to the left but I can’t leave wolf with goat without farmer and can’t leave goat with cabbage without also farmer . So I will make all possible move .
  • 5.
    so the Startstate and the path : :
  • 6.
    Get Children ofthe node and add node to be visited and remov e it function ::
  • 7.
  • 8.
    The Moves andHow To Print Solution
  • 9.
    Thanks I am sorryif there was any Mistake . CPR :: SNGV ahmednasser1993@gmail.com