⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 animal.pro

📁 用turbo prolog编写的小型动物识别系统
💻 PRO
字号:
database 
       	xpositive(symbol,symbol)
       	xnegative(symbol,symbol)
predicates
       	run
       	animal_is(symbol)
       	it_is(symbol)
	positive(symbol,symbol)
	negative(symbol,symbol)
	clear_facts
	remember(symbol,symbol,symbol)
	ask(symbol,symbol)
goal
        run.
clauses
	run:-
	animal_is(X),!,
	write("\nYour animal may be a(n)",X),nl,nl,clear_facts.
	run:-
	write("\nUnable to determine what"), 
	write("your animal is. \n\n"), clear_facts.
	positive (X,Y):-xpositive (X,Y),!.
	positive (X,Y):-not(xnegative(X,Y)),ask(X,Y).
	negative (X,Y):-xnegative (X,Y),!.
	negative (X,Y):-not(xpositive(X,Y)),ask(X,Y).
	ask(X,Y):-
		write(X,"it",Y,"\n"),
		readln(Reply), 
		remember(X,Y,Reply).
	remember(X,Y,yes):-asserta(xpositive(X,Y)).
	remember(X,Y,no):-asserta(xnegative(X,Y)),fail.
	clear_facts:-retract(xpositive(_,_)),fail.
	clear_facts:-retract(xnegative(_,_)),fail.
	clear_facts:-write("\n\nPlease press the space bar to Exit!"), readchar(_).
	animal_is(cheetah):-
		 it_is(carnivore),
		 positive(has,tawny_color),									 positive(has,black_spots).
	animal_is(tiger):-
		it_is(carnivore), 
 		positive(has,tawny_color), 
		positive(has,black_stripes).
	animal_is(giraffe):-	 
		it_is(ungulate), 
 		positive(has,long_neck),
 		positive(has,long_legs), 
 		positive(has,tawny_color),
 		positive(has,dark_spots).
	animal_is(zebra):- 
 		it_is(ungulate),
	 	positive(has,white_color), 
 		positive(has,black_stripes).
	animal_is(ostrich):- 
		it_is(bird), 
 		negative(does,fly), 
		positive(has,long_neck), 
 		positive(has,long_legs),
		positive(has,black_and_white_color).
	animal_is(penguin):- 
 		it_is(bird), 
		negative(does,fly),
		positive(does,swim), 
		positive(has,black_and_white_color).
	animal_is(salangane):- 
 		it_is(bird), 
 		positive(does,fly_well).
	it_is(mammal):-
		positive(has,hair).
	it_is(mammal):- 
		positive(does,give_milk).
	it_is(bird):- 
		positive(has,feathers).
	it_is(bird):- 
		positive(does,fly),
		positive(does,lay_eggs).
	it_is(carnivore):- 
		positive(does,eat_meat).
	it_is (carnivore):- 
		positive(has,pointed_teeth), 
		positive(has,claws), 
		positive(has,forward_eyes).
	it_is (ungulate):- 
		it_is (mammal), 
		positive(has,hooves).
	it_is (ungulate):- 
		it_is (mammal), 
		positive(does,chew_cud).			

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -