Click here to Skip to main content
15,895,256 members

How to draw the three jugs water problem?

Hussein399 asked:

Open original thread
hi there
we have 3 water jugs that the capacity of first jug is 12 and capacity of second jug is 8 and capacity of third jug is 3.
the initial state is: (0,0,0)
the successor function is:
1) add e i
2)pour to another one: [12,x,y],[x,8,z],[x,y,3]
3)empty is: [0,y,z],[x,0,z],[x,y,0]
and the goal state is: (1,1,1)
-------------
now i want to draw its state tree. i did it by myself but i'm not really sure that it is right or not?
          (0,0,0)
     /       |      \
(12,0,0)  (0,8,0)   (0,0,3)

now the child node for(12,0,0) is: (12,0,0),(12,8,0),(12,8,3),(0,8,3),(0,0,3),(0,0,0),(9,8,3),(12,8,0),(4,8,3),(12,0,3),(12,5,3),(12,5,3),(12,8,0)

which (12,0,0),(0,0,0)==>because it is in root,(12,8,0)==>cause same
are fail node and we don't expand them.


i think if i expand (0,0,3), i will reach to my goal state:
the child for the node (0,0,3): (3,0,0),(0,3,0),(0,0,3),(1,1,1) (1,1,1) is the goal state am i right?

[edit]Spurious bold removed, Code block added - OriginalGriff[/edit]
Tags: Algorithms

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900