This Prolog project aims to simulate a farm environment where agents (animals) interact with objects (foods) within a given state. The project consists of several predicates to perform various actions such as calculating the value of the farm, finding food coordinates, locating nearest agents and food, moving agents to specific coordinates or nearest food, and consuming food items.
To run the project, follow these steps:
-
Open SWI-Prolog:
swipl
-
Consult the
main.pro
file:consult('main.pro').
-
Use the provided predicates to perform actions on the farm. Below are the available predicates and their usage:
-
Calculating the Agents Distance (
agents_distance/3
)agents_distance(Agent1, Agent2, Distance)
Computes the Manhattan distance between two agents.
-
Calculating the Number of Agents (
total_agents/2
):total_agents(State, Total)
Counts the total number of agents in the farm.
-
Calculating the Value of the Farm (
value_of_farm/2
):value_of_farm(State, Value)
Calculates the total value of all products on the farm.
-
Finding Food Coordinates (
find_food_coordinates/3
):find_food_coordinates(State, AgentId, Coordinates)
Finds the coordinates of foods consumable by a specific agent.
-
Finding Nearest Agent (
find_nearest_agent/4
):find_nearest_agent(State, AgentId, Coordinates, NearestAgent)
Finds the nearest agent to a given agent.
-
Finding Nearest Food (
find_nearest_food/5
):find_nearest_food(State, AgentId, Coordinates, FoodType, Distance)
Finds the nearest consumable food by an agent.
-
Moving to Coordinate (
move_to_coordinate/6
):move_to_coordinate(State, AgentId, X, Y, ActionList, DepthLimit)
Finds actions to move an agent to a specific coordinate.
-