COP4020 Programming Languages

Slides:



Advertisements
Similar presentations
9 x9 81 4/12/2015 Know Your Facts!. 9 x2 18 4/12/2015 Know Your Facts!
Advertisements

Prolog The language of logic. History Kowalski: late 60’s Logician who showed logical proof can support computation. Colmerauer: early 70’s Developed.
1 x0 0 4/15/2015 Know Your Facts!. 9 x1 9 4/15/2015 Know Your Facts!
1 x0 0 4/16/2015 Know Your Facts!. 1 x8 8 4/16/2015 Know Your Facts!
3 x0 0 7/18/2015 Know Your Facts!. 4 x3 12 7/18/2015 Know Your Facts!
AI for Connect-4 (or other 2-player games) Minds and Machines.
Factoring Trinomials Using the Tic-Tac-Toe Method
TIC-TAC-TOE FELIX CHEN CLUSTER 5: Computers in Biophysics and Robotics.
1 Prolog’s Lists, Negation and Imperative Control Flow COMP 144 Programming Language Concepts Spring 2003 The University of North Carolina at Chapel Hill.
Presented by : Ashin Ara Bithi Roll : 09 Iffat Ara Roll : 22 12th Batch Department of Computer Science & Engineering University of Dhaka.
MIS 451 Building Business Intelligence Systems Logical Design (5) – Aggregate.
The Potential Method. Deque with stacks size=7 13 S1S1 S2S2 push(x,D): push(x,S 1 ) push(2,D)
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 28: Prolog’s Lists, Negation and Imperative Control Flow COMP 144 Programming Language.
1 Codes, Ciphers, and Cryptography-Ch 3.1 Michael A. Karls Ball State University.
Copyright © 2009 Elsevier Chapter 11 :: Logic Languages Programming Language Pragmatics Michael L. Scott.
Copyright © 2009 Elsevier Chapter 11 :: Logic Languages Programming Language Pragmatics Michael L. Scott.
CISC 235: Topic 6 Game Trees.
Minimax.
Multiplication Mania Let’s practice your multiplication facts.
COP4020 Programming Languages Logical programming with Prolog Prof. Xin Yuan.
4 x1 4 10/18/2015 Know Your Facts!. 5 x /18/2015 Know Your Facts!
3 x0 0 10/18/2015 Know Your Facts!. 11 x /18/2015 Know Your Facts!
Fundamental Digital Electronics (Spring 2014) Martino Poggio.
Инвестиционный паспорт Муниципального образования «Целинский район»
COP4020 Programming Languages Functional Programming Prof. Xin Yuan.
(x – 8) (x + 8) = 0 x – 8 = 0 x + 8 = x = 8 x = (x + 5) (x + 2) = 0 x + 5 = 0 x + 2 = x = - 5 x = - 2.
Prolog Kyle Marcotte. Outline What is Prolog? Origins of Prolog (History) Basic Tutorial TEST!!! (sort of…actually not really at all) My example Why Prolog?
Polina Alex Eviatar Roey Andrea Erez.  For those that heard but don’t know exactly:  Scrabble is a word game for two and more players on a square board.
COP4020 Programming Languages Functional Programming Prof. Xin Yuan.
Outline Intro to Representation and Heuristic Search Machine Learning (Clustering) and My Research.
Multiplication Squares Unit 3 Activity 2. Multiplication Squares Resource Sheet
Multiplication Facts X 3 = 2. 8 x 4 = 3. 7 x 2 =
Math Jeopardy Chapters 9-12 Measurement Geometry.
C. Varela1 Logic Programming Prolog: Arithmetic, Equalities, Operators, I/O. (PLP 11) Databases: assert, retract. (CTM 9.6) Carlos Varela Rennselaer Polytechnic.
COP4020 Programming Languages Prolog Prof. Robert van Engelen (modified by Prof. Em. Chris Lacher)
 Synthesis means combining separate elements to form a coherent whole.  A synthesis paragraph will bring together  your research and  your analysis.
Invention Convention A Project for the Creative Mind— Humanities Level 5.
Multiplication Facts © Math As A Second Language All Rights Reserved next 1 to 9 3.OA#7.
6.6 Factoring Quadratics with Composite Leading Coefficients Objective: Be able to factor quadratics that start with a composite number.
Topic 3 Exponents.  Each group is responsible a block of problems  Find the answers  Draw the matching picture on the poster.  If you notice a mistake.
COP4020 Programming Languages Logic Programming Prof. Xin Yuan.
When the king is being attacked directly by an opponent’s piece we say the king is in check.
Logic Programming Lecture 2: Unification and proof search.
照片档案整理 一、照片档案的含义 二、照片档案的归档范围 三、 卷内照片的分类、组卷、排序与编号 四、填写照片档案说明 五、照片档案编目及封面、备考填写 六、数码照片整理方法 七、照片档案的保管与保护.
공무원연금관리공단 광주지부 공무원대부등 공적연금 연계제도 공무원연금관리공단 광주지부. 공적연금 연계제도 국민연금과 직역연금 ( 공무원 / 사학 / 군인 / 별정우체국 ) 간의 연계가 이루어지지 않고 있 어 공적연금의 사각지대가 발생해 노후생활안정 달성 미흡 연계제도 시행전.
Жюль Верн ( ). Я мальчиком мечтал, читая Жюля Верна, Что тени вымысла плоть обретут для нас; Что поплывет судно громадней «Грейт Истерна»; Что.
Algebra 2 cc Section 3.3 Relate zeros (roots), factors, and intercepts of polynomial functions Consider the quadratic function f(x) = x 2 – 2x - 8 Zeros.
1 Lecture 16: Prolog’s Lists, Negation and Imperative Control Flow (Section 11.3) CSCI 431 Programming Languages Fall 2002 A modification of slides developed.
Reasoning About Code.
Reasoning about code CSE 331 University of Washington.
Lesson 5 Functions I A function is a small program which accomplishes a specific task. For example, we invoke (call) the function, sqrt(x), in the library.
Chapter 12 :: Logic Languages
Carlos Varela Rensselaer Polytechnic Institute November 28, 2017
Blockbusters!!! Writing Equations.
COP4020 Programming Languages
CS 3304 Comparative Languages
0C kN/m
Gradient Bingo Rules Draw a table 3 by 3.
Learn Your 2x Facts.
Grid Files (Another example)
Blockbusters!!! Graphing Lines.
STORE MANAGER RESPONSIBILITIES.
Carlos Varela Rennselaer Polytechnic Institute November 22, 2016
Laws of Exponents: Multiplication.
LANGUAGE EDUCATION.
' · · ,.-.., '' !'",. -,..._ ·-.·-...;.· -
2019 SAIMC Puzzle Challenge General Regulations
Presentation transcript:

COP4020 Programming Languages Logic Programming with Prolog Prof. Xin Yuan

Topic Tic-Tac-Toe in Prolog 4/15/2017 COP4020 Spring 2014 COP4020 Fall 2006

Example: Tic-Tac-Toe Cells on the grid are numbered Facts: 1 2 3 4 5 6 ordered_line(1,5,9). ordered_line(3,5,7). ordered_line(1,2,3). ordered_line(4,5,6). ordered_line(7,8,9). ordered_line(1,4,7). ordered_line(2,5,8). ordered_line(3,6,9). 1 2 3 4 5 6 7 8 9 4/15/2017 COP4020 Spring 2014

Example: Tic-Tac-Toe Rules to find line of three (permuted) cells: 1 2 line(A,B,C) :- ordered_line(A,B,C). line(A,B,C) :- ordered_line(A,C,B). line(A,B,C) :- ordered_line(B,A,C). line(A,B,C) :- ordered_line(B,C,A). line(A,B,C) :- ordered_line(C,A,B). line(A,B,C) :- ordered_line(C,B,A). 1 2 3 4 5 6 7 8 9 4/15/2017 COP4020 Spring 2014

Example: Tic-Tac-Toe How to make a good move to a cell: move(A) :- good(A), empty(A). Which cell is empty? empty(A) :- \+ full(A). Cell has an X or O placed in it? full(A) :- x(A). full(A) :- o(A). 4/15/2017 COP4020 Spring 2014

Example: Tic-Tac-Toe Which cell is best to move to? (check this in this order good(A) :- win(A).        % a cell where we win good(A) :- block_win(A).  % a cell where we block the opponent from a win good(A) :- split(A).      % a cell where we can make a split to win good(A) :- block_split(A).% a cell where we block the opponent from a split good(A) :- build(A).      % choose a cell to get a line good(5).               % choose a cell in a good location good(1). good(3). good(7). good(9). good(2). good(4). good(6). good(8). 4/15/2017 COP4020 Spring 2014

Example: Tic-Tac-Toe How to find a winning cell: split win(A) :- x(B), x(C), line(A,B,C). Choose a cell to block the opponent from choosing a winning cell: block_win(A) :- o(B), o(C), line(A,B,C). Choose a cell to split for a win later: split(A) :- x(B), x(C), \+ (B = C), line(A,B,D), line(A,C,E), empty(D), empty(E). Choose a cell to block the opponent from making a split: block_split(A) :- o(B), o(C), \+ (B = C), line(A,B,D), line(A,C,E), empty(D), empty(E). Choose a cell to get a line: build(A) :- x(B), line(A,B,C), empty(C). split 4/15/2017 COP4020 Spring 2014

Example: Tic-Tac-Toe O X Board positions are stored as facts: Move query: ?- move(A). A = 9 O X 4/15/2017 COP4020 Spring 2014