如何绘制三个水壶水的问题? [英] How to draw the three jugs water problem?
问题描述
您好
我们有3个水壶,第一个水壶的容量是12个,第二个水壶的容量是8个,第三个水壶的容量是3个。
初始状态是:(0,0,0)
后继功能是:
1)添加ei
2)倒入另一个:[12,x,y],[x,8,z],[x,y,3]
3)空是:[0,y,z],[x,0, z],[x,y,0]
和目标状态是:(1,1,1)
----------- -
现在我想绘制它的状态树。我是自己做的,但我不确定它是否正确?
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)
现在子节点(12,0,0)为:(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)
其中(12,0,0),(0,0,0)==>因为它是在root中,(12,8,0)==>因为相同
是失败节点,我们不会扩展它们。
i如果我展开(0,0,3),我会达到我的目标状态:
节点的孩子(0,0, 3):( 3,0,0),(0,3,0),(0,0,3),(1,1,1)(1,1,1)是我的目标状态吗?
虚假粗体删除,代码块添加 - OriginalGriff [/ edit]
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]
推荐答案
你的问题陈述非常混乱,难以理解。
我的理解和形式化如下:
假设您处于州[x,y,z]
。以下是可能的转换:
Your problem statement is very messy and difficult to follow.
My understanding and formalization are as follows:
Assume you are in state[x, y, z]
. Here are the possible transitions:
Fill 12 -> [12, y, z]
Fill 8 -> [x, 8, z]
Fill 3 -> [x, y, 3]
Empty 12 -> [0, y, z]
Empty 8 -> [x, 0, z]
Empty 3 -> [x, y, 0]
12 to 8 -> [x + y - 8, 8, z] or [0, x + y, z], depending on x + y >< 8
8 to 12 -> [12, x + y - 12, z] or [x + y, 0, z], depending on x + y >< 12
12 to 3 -> [x + z - 3, y, 3] or [0, y, x + z], depending on x + z >< 3
3 to 12 -> [12, y, x + z - 12] or [x + z, y, 0], depending on x + z >< 12
8 to 3 -> [x, y + z - 3, 3] or [x, 0, y + z], depending on y + z >< 3
3 to 8 -> [x, 8, y + z - 8] or [x, y + z, 0], depending on y + z >< 8
有可能存在13 x 9 x 4种不同的状态(可能并非都可以实现)。考虑到可以有循环,你应该考虑一个状态图而不是一个状态树。
你可以从状态[0,0开始构建完整的图形, 0]并递归地尝试所有12个转换,首先是深度优先或广度优先。
There are potentially 13 x 9 x 4 different states (maybe not all achievable). You should consider a state graph rather than a state tree, given that there can be loops.
You can build the complete graph, starting from state [0, 0, 0] and trying all 12 transitions recursively, depth first or breadth first.
这篇关于如何绘制三个水壶水的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!