[인공지능][전문가시스템][프롤로그][prolog]

어떤 컴퓨터 프로그래밍 언어를 먼저 배워야 할까?

아래 그림의 논리(logic:로직)으로 prolog (swi-prolog) 언어로 코딩된 전문가시스템 예제

expert-systems-master.zip expert-systems-master.zip

which-programming-language-should-i-learn-first-infographic.png

 

 

% Expert system should be started from here

 

main :-
  intro,
  reset_answers,
  find_language(Language),
  describe(Language), nl.
   
   
  intro :-
  write('Which programming language should I learn first?'), nl,
  write('To answer, input the number shown next to each answer, followed by a dot (.)'), nl, nl.
   
   
  find_language(Language) :-
  language(Language), !.
   
   
  % Store user answers to be able to track his progress
  :- dynamic(progress/2).
   
   
  % Clear stored user progress
  % reset_answers must always return true; because retract can return either true
  % or false, we fail the first and succeed with the second.
  reset_answers :-
  retract(progress(_, _)),
  fail.
  reset_answers.
   
   
  % Rules for the knowledge base
  language(python) :-
  why(for_my_kids).
   
  language(python) :-
  why(i_dont_know).
   
  language(java) :-
  why(make_money),
  which_platform(doesn_t_matter).
   
  language(cpp) :-
  why(make_money),
  which_platform(gaming).
   
  language(objectivec) :-
  why(make_money),
  which_platform(mobile),
  which_mobile_os(ios).
   
  language(java) :-
  why(make_money),
  which_platform(mobile),
  which_mobile_os(android).
   
  language(python) :-
  why(make_money),
  which_platform(facebook).
   
  language(python) :-
  why(make_money),
  which_platform(google).
   
  language(csharp) :-
  why(make_money),
  which_platform(microsoft).
   
  language(objectivec) :-
  why(make_money),
  which_platform(apple).
   
  language(javascript) :-
  why(make_money),
  which_platform(web),
  web(front_end).
   
  language(csharp) :-
  why(make_money),
  which_platform(web),
  web(back_end),
  want_to_work_for(corporate),
  think_about_microsoft(im_a_fan).
   
  language(java) :-
  why(make_money),
  which_platform(web),
  web(back_end),
  want_to_work_for(corporate),
  think_about_microsoft(not_bad).
   
  language(java) :-
  why(make_money),
  which_platform(web),
  web(back_end),
  want_to_work_for(corporate),
  think_about_microsoft(suck).
   
  language(javascript) :-
  why(make_money),
  which_platform(web),
  web(back_end),
  want_to_work_for(startup),
  try_something_new(yes).
   
  language(python) :-
  why(make_money),
  which_platform(web),
  web(back_end),
  want_to_work_for(startup),
  try_something_new(no),
  favourite_toy(lego).
   
  language(ruby) :-
  why(make_money),
  which_platform(web),
  web(back_end),
  want_to_work_for(startup),
  try_something_new(no),
  favourite_toy(play_doh).
   
  language(php) :-
  why(make_money),
  which_platform(web),
  web(back_end),
  want_to_work_for(startup),
  try_something_new(no),
  favourite_toy(old_ugly).
   
  language(csharp) :-
  why(make_money),
  which_platform(enterprise),
  think_about_microsoft(im_a_fan).
   
  language(java) :-
  why(make_money),
  want_to_work_for(enterprise),
  think_about_microsoft(not_bad).
   
  language(java) :-
  why(make_money),
  want_to_work_for(enterprise),
  think_about_microsoft(suck).
   
  language(python) :-
  why(just_for_fun),
  prefer_to_learn(easy_way).
   
  language(python) :-
  why(just_for_fun),
  prefer_to_learn(best_way).
   
  language(java) :-
  why(just_for_fun),
  prefer_to_learn(harder_way),
  car(auto).
   
  language(c) :-
  why(just_for_fun),
  prefer_to_learn(harder_way),
  car(manual).
   
  language(cpp) :-
  why(just_for_fun),
  prefer_to_learn(hardest_way).
   
  language(python) :-
  why(im_interested),
  prefer_to_learn(easy_way).
   
  language(python) :-
  why(im_interested),
  prefer_to_learn(best_way).
   
  language(java) :-
  why(im_interested),
  prefer_to_learn(harder_way),
  car(auto).
   
  language(c) :-
  why(im_interested),
  prefer_to_learn(harder_way),
  car(manual).
   
  language(cpp) :-
  why(im_interested),
  prefer_to_learn(hardest_way).
   
  language(python) :-
  why(improve_myself),
  prefer_to_learn(easy_way).
   
  language(python) :-
  why(improve_myself),
  prefer_to_learn(best_way).
   
  language(java) :-
  why(improve_myself),
  prefer_to_learn(harder_way),
  car(auto).
   
  language(c) :-
  why(improve_myself),
  prefer_to_learn(harder_way),
  car(manual).
   
  language(cpp) :-
  why(improve_myself),
  prefer_to_learn(hardest_way).
   
   
  % Questions for the knowledge base
  question(why) :-
  write('Why do you want to learn programming?'), nl.
   
  question(which_platform) :-
  write('Which platform/field?'), nl.
   
  question(which_mobile_os) :-
  write('Which OS?'), nl.
   
  question(web) :-
  write('Which "end"?'), nl.
   
  question(want_to_work_for) :-
  write('I want to work for...'), nl.
   
  question(think_about_microsoft) :-
  write('What do you think about Microsoft?'), nl.
   
  question(try_something_new) :-
  write('Do you want to try something new, with huge potential, but less mature?'), nl.
   
  question(favourite_toy) :-
  write('Which one is your favourite toy?'), nl.
   
  question(prefer_to_learn) :-
  write('I prefer to learn things...'), nl.
   
  question(car) :-
  write('Auto or Manual car?'), nl.
   
   
  % Answers for the knowledge base
  answer(for_my_kids) :-
  write('For my kids').
   
  answer(i_dont_know) :-
  write('I don\'t know').
   
  answer(make_money) :-
  write('Make money').
   
  answer(just_for_fun) :-
  write('Just for fun').
   
  answer(im_interested) :-
  write('I\'m interested').
   
  answer(improve_myself) :-
  write('Improve myself').
   
  answer(doesn_t_matter) :-
  write('Doesn\'t matter, I just want $$$').
   
  answer(gaming) :-
  write('3D/Gaming').
   
  answer(mobile) :-
  write('Mobile').
   
  answer(facebook) :-
  write('Facebook').
   
  answer(google) :-
  write('Google').
   
  answer(microsoft) :-
  write('Microsoft').
   
  answer(apple) :-
  write('Apple').
   
  answer(web) :-
  write('Web').
   
  answer(enterprise) :-
  write('Enterprise').
   
  answer(ios) :-
  write('iOS').
   
  answer(android) :-
  write('Android').
   
  answer(front_end) :-
  write('Front-end (web interface)').
   
  answer(back_end) :-
  write('Back-end ("brain" behind a website)').
   
  answer(startup) :-
  write('Startup').
   
  answer(corporate) :-
  write('Corporate').
   
  answer(im_a_fan) :-
  write('I\'m a fan!').
   
  answer(not_bad) :-
  write('Not Bad').
   
  answer(suck) :-
  write('Suck').
   
  answer(yes) :-
  write('Yes').
   
  answer(no) :-
  write('No').
   
  answer(lego) :-
  write('Lego').
   
  answer(play_doh) :-
  write('Play-Doh').
   
  answer(old_ugly) :-
  write('I\'ve an old & ugly toy, but I love it so much!').
   
  answer(easy_way) :-
  write('The easy way').
   
  answer(best_way) :-
  write('The best way').
   
  answer(harder_way) :-
  write('The slightly harder way').
   
  answer(hardest_way) :-
  write('The really hard way (but easier to pick up other languages in the future)').
   
  answer(auto) :-
  write('Auto').
   
  answer(manual) :-
  write('Manual').
   
   
  % Language descriptions for the knowledge base
  describe(python) :-
  write('Python'), nl,
  write('Widely regarded as the best programming language for beginners'), nl,
  write('Easiest to learn').
   
  describe(java) :-
  write('Java'), nl,
  write('One of the most in demand & highest paying programming languages'), nl,
  write('Slogan: write once, work everywhere').
   
  describe(c) :-
  write('C'), nl,
  write('Lingua franca of programming language'), nl,
  write('One of the oldest and most widely used language in the world').
   
  describe(cpp) :-
  write('C++'), nl,
  write('Complex version of C with a lot more features'), nl,
  write('Recommended only if you have a mentor to guide you').
   
  describe(javascript) :-
  write('JavaScript'), nl,
  write('Most popular clients-side web scripting language'), nl,
  write('A must learn for front-end web developer (HTML and CSS as well)').
   
  describe(csharp) :-
  write('C#'), nl,
  write('A popular choice for enterprise to create websites and Windows application using .NET framework'), nl,
  write('Similar to Java in basic syntax and some features').
   
  describe(ruby) :-
  write('Ruby'), nl,
  write('Mostly known for its popular web framework, Ruby on Rails'), nl,
  write('Focuses on getting things done').
   
  describe(php) :-
  write('PHP'), nl,
  write('Suitable for building small and simple sites within a short time frame'), nl,
  write('Supported by almost every web hosting services with lower price').
   
  describe(objectivec) :-
  write('Objective-C'), nl,
  write('Primary language used by Apple for MacOSX & iOS'), nl,
  write('Choose this if you want to focus on developing iOS or OSX apps only').
   
   
  % Assigns an answer to questions from the knowledge base
  why(Answer) :-
  progress(why, Answer).
  why(Answer) :-
  \+ progress(why, _),
  ask(why, Answer, [for_my_kids, i_dont_know, make_money, just_for_fun, im_interested, improve_myself]).
   
  which_platform(Answer) :-
  progress(which_platform, Answer).
  which_platform(Answer) :-
  \+ progress(which_platform, _),
  ask(which_platform, Answer, [doesn_t_matter, gaming, mobile, facebook, google, microsoft, apple, web, enterprise]).
   
  which_mobile_os(Answer) :-
  progress(which_mobile_os, Answer).
  which_mobile_os(Answer) :-
  \+ progress(which_mobile_os, _),
  ask(which_mobile_os, Answer, [ios, android]).
   
  web(Answer) :-
  progress(web, Answer).
  web(Answer) :-
  \+ progress(web, _),
  ask(web, Answer, [front_end, back_end]).
   
  want_to_work_for(Answer) :-
  progress(want_to_work_for, Answer).
  want_to_work_for(Answer) :-
  \+ progress(want_to_work_for, _),
  ask(want_to_work_for, Answer, [startup, corporate]).
   
  think_about_microsoft(Answer) :-
  progress(think_about_microsoft, Answer).
  think_about_microsoft(Answer) :-
  \+ progress(think_about_microsoft, _),
  ask(think_about_microsoft, Answer, [im_a_fan, not_bad, suck]).
   
  try_something_new(Answer) :-
  progress(try_something_new, Answer).
  try_something_new(Answer) :-
  \+ progress(try_something_new, _),
  ask(try_something_new, Answer, [yes, no]).
   
  favourite_toy(Answer) :-
  progress(favourite_toy, Answer).
  favourite_toy(Answer) :-
  \+ progress(favourite_toy, _),
  ask(favourite_toy, Answer, [lego, play_doh, old_ugly]).
   
  prefer_to_learn(Answer) :-
  progress(prefer_to_learn, Answer).
  prefer_to_learn(Answer) :-
  \+ progress(prefer_to_learn, _),
  ask(prefer_to_learn, Answer, [easy_way, best_way, harder_way, hardest_way]).
   
  car(Answer) :-
  progress(car, Answer).
  car(Answer) :-
  \+ progress(car, _),
  ask(car, Answer, [auto, manual]).
   
   
  % Outputs a nicely formatted list of answers
  % [First|Rest] is the Choices list, Index is the index of First in Choices
  answers([], _).
  answers([First|Rest], Index) :-
  write(Index), write(' '), answer(First), nl,
  NextIndex is Index + 1,
  answers(Rest, NextIndex).
   
   
  % Parses an Index and returns a Response representing the "Indexth" element in
  % Choices (the [First|Rest] list)
  parse(0, [First|_], First).
  parse(Index, [First|Rest], Response) :-
  Index > 0,
  NextIndex is Index - 1,
  parse(NextIndex, Rest, Response).
   
   
  % Asks the Question to the user and saves the Answer
  ask(Question, Answer, Choices) :-
  question(Question),
  answers(Choices, 0),
  read(Index),
  parse(Index, Choices, Response),
  asserta(progress(Question, Response)),
  Response = Answer.

 

 

expert-systems

A basic expert system, written in Prolog, that suggests what programming language one should learn first.

The system is based on the this infographic.

Instalation

In order to run this Prolog program you need to have...Prolog installed:

  • on Mac:

    brew install swi-prolog

Then, just clone this repo and you're good to go!

경축! 아무것도 안하여 에스천사게임즈가 새로운 모습으로 재오픈 하였습니다.
어린이용이며, 설치가 필요없는 브라우저 게임입니다.
https://s1004games.com

Running

Start a Prolog console loaded with main.pl:

swi-prolog -f main.pl

Then follow the on-screen instructions. Enjoy!

 

[출처] https://github.com/linkyndy/expert-systems

 

 

 

 

 

 

 

본 웹사이트는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
번호 제목 글쓴이 날짜 조회 수
1115 [ 一日30分 인생승리의 학습법] 2023 네이버 다이어리 굿노트 템플릿으로 심플하게 새해 계획 file 졸리운_곰 2023.01.07 15
1114 [ 一日30分 인생승리의 학습법] 프로그래밍 스킴 Scheme 1 다운로드부터 문법 대부분을 314초만에 알려줄게요 졸리운_곰 2023.01.05 5
1113 [ 一日30分 인생승리의 학습법] ROBOCOPY(로보카피) 사용법 file 졸리운_곰 2023.01.05 10
1112 [ 一日30分 인생승리의 학습법] PHP, VBA and SQL Useful Scripts PHP, VBA 및 SQL 유용한 스크립트 file 졸리운_곰 2023.01.01 7
1111 [ 一日30分 인생승리의 학습법] KoELECTRA로 기계독해(MRC) API 개발 file 졸리운_곰 2023.01.01 7
1110 [ 一日30分 인생승리의 학습법] 일 안 해도 생기는 수입? 그런 ‘패시브 인컴’은 없다 file 졸리운_곰 2023.01.01 6
1109 [ 一日30分 인생승리의 학습법] Qemu를 이용한 가상화 기초 file 졸리운_곰 2022.12.31 5
1108 [ 一日30分 인생승리의 학습법] 파이토치로 딥러닝해야 하는 5가지 이유 졸리운_곰 2022.12.31 6
1107 [ 一日30分 인생승리의 학습법] 왜 ‘한국어’의 자연어처리(NLP)는 유독 어려울까? file 졸리운_곰 2022.12.31 10
1106 [ 一日30分 인생승리의 학습법] MinIO Windows Service 등록 졸리운_곰 2022.12.24 7
1105 [ 一日30分 인생승리의 학습법] Apache 2.2에서 2.4로 마이그레이션 시 발생하는 에러 및 해결책 정리 졸리운_곰 2022.12.18 6
1104 [ 一日30分 인생승리의 학습법] Git 사용 방법 정리(commit, push, pull request, merge 등) 졸리운_곰 2022.12.04 18
1103 [ 一日30分 인생승리의 학습법] [웹 기획] 화면 설계 용어 - 와이어프레임, 스토리보드, 프로토타입의 차이점 file 졸리운_곰 2022.12.03 6
1102 [ 一日30分 인생승리의 학습법] REST API 설계 (네이밍) 졸리운_곰 2022.11.26 23
1101 [ 一日30分 인생승리의 학습법] REST API URI 규칙 졸리운_곰 2022.11.26 12
1100 [ 一日30分 인생승리의 학습법 ] REST API URL 규칙 졸리운_곰 2022.11.26 9
1099 [ 一日30分 인생승리의 학습법 ] prolog 문법 : Prolog Syntax 졸리운_곰 2022.11.21 3
1098 [ 一日30分 인생승리의 학습법 ] noVNC 작동원리 file 졸리운_곰 2022.11.16 8
1097 [ 一日30分 인생승리의 학습법 ] 프로젝트 만들고 GitHub에 첫 Commit하고 Push하기 file 졸리운_곰 2022.11.15 4
1096 [ 一日30分 인생승리의 학습법 ] 우분투(리눅스) 에서 EBS 라디오 자동녹음 만들기 졸리운_곰 2022.11.11 9
대표 김성준 주소 : 경기 용인 분당수지 U타워 등록번호 : 142-07-27414
통신판매업 신고 : 제2012-용인수지-0185호 출판업 신고 : 수지구청 제 123호 개인정보보호최고책임자 : 김성준 sjkim70@stechstar.com
대표전화 : 010-4589-2193 [fax] 02-6280-1294 COPYRIGHT(C) stechstar.com ALL RIGHTS RESERVED