I'm not very good in programming, and this tough algorithm is really killing me. I have no idea on how to program this nor to write an algorithm. please help me!!

I would be very grateful if u could help me to write the source code. thank you very much.

function SIMPLE-PLANNING-AGENT (PERCEPT) returns an action
static: KB, a knowledge base (includes action descriptions)
p, a plan, initially No plan
t, a counter, initially 0, indicating time
local varibales: G, a goal
current, a current state description

TELL (KB, MAKE-PERCEPT-SENTENCE(percept, t)
current <- STATE-DESCRIPTION (KB, t)
if p=NoPlan then
G <- ASK (KB, MAKE-GOAL-QUERY(t))
p <- IDEAL-PLANNER (current, G, KB)

if p=NoPlan or p is empty then action <- NoOp
else
action <- FIRST(p)
p <- REST(p)
TELL (KB, MAKE-ACTION-SENTENCE(action, t)
t <- t+1
return action