Questions tagged [water-jug-problem]

The water jug problem is a classical AI problem involving various search techniques.

The water jug problem is a classical AI problem involving various search techniques.

External page

See also .

28 questions
0
votes
0 answers

Water Jug Problem in Prolog with Best First Search

I failed to write a Prolog program using RBFS algorithm to solve a task - how to measure exactly 3 liters of water using 5-liter and 9-liter water jugs? I have a solution, but it does not use best-first search algorithm and works blindly (without…
Nick Reshetinsky
  • 447
  • 2
  • 13
0
votes
0 answers

Water Jug Problem in python to fill equal amount of water in same capacity of jugs

write a program to simulate water jug problem with 2 empty jugs having capacity of 4 gallons each. the program must enlist series of steps that can consequently fill both jugs with 2 gallon water
user13827359
0
votes
0 answers

Three water jugs puzzle using BFS by C++ work on MacOS, but not on Ubuntu

Problem: Let’s say that we have 3 jugs, namely A, B, and C. Jug C will always start out completely full. Furthermore, we will define a goal state where jug A will contain a gallons, B will contain b gallons, and C will contain c gallons upon…
0
votes
1 answer

7 liter and 5 liter jugs to 4 liter jug puzzle with depth-first search

I want to use any kind of depth-first search to solve the 7 Liter and 5 Liter to 4 Liter Puzzle in SWI-Prolog I have no idea how I could start.. I want to get 4 Liters in a Jug at the end solve(JUG1, JUG2) :- fill(JUG1, JUG2), swap(JUG1,…
0
votes
2 answers

Format minimal path

So I've been working on something to help me understand Prolog better. I took the traditional water jug problem but added a bit of difficulty. Thus, my code is working pretty good. The only thing left to do would be to do some nice formatting for…
0
votes
1 answer

Swi Prolog - Implementing water Jug Program with Lists

sorry about before, new to posting in this, trying to get this list to recurse through each one of the actions, keeping it's visited list items and then check in a recursion if the element is not in the list that state would be changed to. I need to…
0
votes
1 answer

Prolog query question

I am new to prolog, and I have to write a program about the water jugs. My problem is regarding the initial state of jugs and the query formation. The query will be of the form: ?- myPredicate(args), filled(j1,1) Meaning j1 filled with 1 gallon…
0
votes
0 answers

AttributeError: 'JugPuzzle' object has no attribute 'current'

class Jug: def __init__(self, current, highest): self.current = current self.highest = highest def spill(self, jug, jug_1): """ :return: The new values of the jug spilled from and the jug spilled to …
0
votes
1 answer

Depth First Search Prolog

I'm trying to solve a water, jug problem (one 7L, one 4L, get 5L in the 7L jug) using dept first search. However something keeps going wrong whenever I try to get a new state back from one of my actions. Prolog Code I can't figure out what is going…
Zombie
  • 27
  • 3
0
votes
1 answer

Functions change values in list even though list is not passed to functions

I'm trying to implement a I.A. breadth-first-search-like algorithm to solve the Water Jugs problem but I encountered this problem: Every time I add a new element to the array, it changes all elements inside the array to be like it. In other…
0
votes
1 answer

2-Water jug in prolog

I'm trying to solve the 2-water jug problem in swi-prolog: Given 2 jugs of capacities 4 and 3 gallons respectively, I want to find the steps to obtain 2 gallons in jug of capacity 4 and 0 in the other. I wrote programs for this problem in C++ using…
-2
votes
1 answer

Prolog Jugs Solution

I have the current solution for the jugs problem in Prolog but I am having a problem in how to run the program. Can someone help me please. Thanks in advance. Error Undefined procedure: state/1, However, there are definitions for: state/2 …
user3558118
  • 133
  • 2
  • 8
-3
votes
1 answer

jug filling in LISP

Starting with an empty 5-gallon jug and an empty 11-gallon jug, how can we end up with exactly 3 gallons of water in the 11-gallon jug and with the 5-gallon jug empty? I want to write a function in Lisp that computes a list of successor states for…
nesreen
  • 33
  • 1
  • 6
1
2