Prolog Arithmetic Operations within Function?

AI Thread Summary
The discussion revolves around implementing rules for the "Wumpus World" in Prolog, specifically focusing on the relationship between pits and breezes. The user initially defines a knowledge base where breezes are felt at specific locations surrounding a pit at (2,2). However, they encounter an issue where querying for the pit returns false for all locations. The problem is identified as a need to assert the breeze locations correctly and to adjust the arithmetic operations outside the function. This realization leads to a solution that aligns the Prolog code with the intended logic of the Wumpus World.
tangodirt
Messages
51
Reaction score
1
So, I'm trying to learn prolog, and since it's used a lot in the AI community, I thought I would try my hand at implementing a few of the simple "wumpus world" rules.

The rule for a "pit" existing at location (2,2) means that a breeze is felt at locations (1,2), (2,1), (2,3), and (3,2). So, by telling the knowledge base that breezes are felt at those locations, means that querying pit(2,2) should return true, while all other locations should return false.

My prolog code looks like this:

Code:
breeze(1,2).
breeze(2,1).
breeze(2,3).
breeze(3,2).

pit(X,Y) :- breeze(X + 1,Y) , breeze(X,Y + 1) , breeze(X - 1,Y) , breeze(X,Y - 1) .

However, all locations for pit(X,Y) return false. Any ideas?
 
Technology news on Phys.org
Nevermind, I've figured it out. The breeze locations need to be asserted, and the arithmetic operations should be extracted from within the function.
 
Thread 'Star maps using Blender'
Blender just recently dropped a new version, 4.5(with 5.0 on the horizon), and within it was a new feature for which I immediately thought of a use for. The new feature was a .csv importer for Geometry nodes. Geometry nodes are a method of modelling that uses a node tree to create 3D models which offers more flexibility than straight modeling does. The .csv importer node allows you to bring in a .csv file and use the data in it to control aspects of your model. So for example, if you...
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

Back
Top