You are on page 1of 11

434:

(20082009)

:




.
: ()
.
(
(..,BubbleSort

B bbl S t .)

)
:

: ()
( )
.
(.., [..., , , ...], < .)
(..,[...,,,...],<.)
08/09/2008

434(20082009)


=+(Kowalski)
+ (Kowalski)


.

(C,Java,):
(C Java ):
().
(Prolog,):
().
08/09/2008

434(20082009)

Prolog
Prolog
Prolog
g


,
.
Prolog
(clauses):
(clauses):
(facts).
(.., .)
(..,.)
(rules).
(..,.)
08/09/2008

434(20082009)

human(socrates)
human(socrates).
:socrates human.
mortal(X) : human(X).
mortal(X):
human(X)
: X,
X
X mortal

t l X
X human.

h
/ .
(queries).
08/09/2008

434(20082009)

human(socrates)
human(socrates).
mortal(X): human(X).
?mortal(aristotle).
:aristotle mortal;
?human(Y).
: human;
, Y;
08/09/2008

434(20082009)

load_bullet(3).
load
bullet(3)
shoot(fred,5).
dead(X,T): dead(X,T1).
dead(X,T):
( , ) ggun_loaded(T1),shoot(X,T1).
( ),
( ,
)
gun_loaded(T): load_bullet(T1).
gun loaded(T) : gun_loaded(T1),\+shoot(X,T1).
gun_loaded(T):
gun loaded(T1) \+ shoot(X T1)
? d d(f d 8)
?dead(fred,8).
08/09/2008

434(20082009)

evaluate_and_choose([Move|Rest],Board,Player,D,MaxMin,Record,Best):
make_move(Move,Board,NextBoard),
minimax(D,NextBoard,Player,MaxMin,_MoveX,Value),
p
(
,
,
,
),
update(Move,Value,Record,NewRecord),
evaluate_and_choose(Rest,Board,Player,D,MaxMin,NewRecord, Best).
minimax(0,Board,Player,MaxMin,_Move,Value):
minimax(0
Board Player MaxMin Move Value):
value(Board,Player,V),ValueisV*MaxMin.
minimax(D,Board,Player,MaxMin,Move,Value):
D>0 D1 is D 1 MinMax is
D>0,D1isD1,MinMax
is MaxMin,opponent(Player,Opponent),
MaxMin opponent(Player Opponent)
find_all_moves(Board,Player,Moves),write(D),write(Move),nl,
evaluate_and_choose(Moves,Board,Opponent,D1,MinMax,
(
(nil,1000),
) (Move,Value)).
(
))
08/09/2008

434(20082009)

course(

course_code(CS(100)),
course_info(
title(ComputingMachineryandIntelligence),
credits(4),semester_offered(winter)),
professor_info( name(A.),surname(Turing),title(Professor)),
teaching_info(
h
f (
teaching_days_time_rooms([
lesson(day(Monday),from(1030),to(1159),room(123)),
lesson(day(Thursday)
lesson(day(
Thursday ),from(1030),to(1159),room(123)),
from(1030) to(1159) room(123))
]), lab_days_time_rooms([])),
other_info(obligatory(yes),prerequisites([MATH(001)]))).

available_course(CompletedCourses,Semester,Course): %definesothat
%alltheprerequisitesofCourseareinCompletedCourses
% and Course is offered in Semester
%andCourseisofferedinSemester
08/09/2008

434(20082009)

action(Agent,raise_bid(Auction,Bid)):
preconditions([
object(Auction),
value(Auction,highest_bid,CurrentBid),
atleast(Bid,CurrentBid+1)]),
l
( d
d ) ])
effects([
set(Auction,highest_bid,Bid),
set(Auction highest bidder Agent)
set(Auction,highest_bidder,Agent),
set(Auction,last_bid_time,Time)where
value(clock,happened_at,Time)]).
execute(Action,Agent): %definesothattheeffectsoftheaction
%areinstantiatedexactlywhenthepreconditionsoftheactionhold.

08/09/2008

434(20082009)

10

ConsoleI/O,loops,client
Console
I/O loops clientserver
servercommunication,
communication
caninvokeandbeinvokedfromprogramsinC,
transmit(Host,Port):
socket(internet,stream,Channel),
connect(Channel,Host/Port),
repeat,
write(Enter
write(
Enteramessage:
a message: )),
read(Message),
send(Channel,Message),
f il
fail.
08/09/2008

434(20082009)

11

You might also like