Better Programming

Advice for programmers.

Member-only story

4 Ways to Build an AI Agent

--

Photo by Jason Abdilla on Unsplash

If we think back to the primary difference between synthetic intelligence and artificial intelligence, AI agents are purpose built. Meaning, we engineer AI to address problems narrow in scope. Yet, not all problems are the same type. This is why we have 4 ways to build our AI agents. Let’s check those out right now!

Rule-Based Agents

These agents make decisions based on a set of predefined rules or conditions. They match inputs to specific rules and execute corresponding actions. Rule-based agents are widely used in expert systems and decision-making domains.

Here’s a simple code example demonstrating a rule-based agent in the context of a lumberjack problem. The agent follows a set of predefined rules to decide its actions based on the current state of the environment.

class RuleBasedLumberjack:
def __init__(self, environment):
self.environment = environment
self.position = (0, 0)

def make_decision(self):
if self.environment.has_tree(self.position):
self.chop_tree()
else:
self.explore()

def chop_tree(self):
print("Chopping down the tree!")
# Code for chopping down the tree goes here

def explore(self):
possible_moves = ['up', 'down', 'left', 'right']
valid_moves = []
for move in…

--

--

Jason M. Pittman
Jason M. Pittman

Written by Jason M. Pittman

I am a forward-leaning innovator committed to solving tomorrow’s grand challenges by developing cutting-edge research and technology today.

Responses (1)