Code Monkey home page Code Monkey logo

prolog-examples's Introduction

prolog-examples

Some simple examples for new Prolog programmers. Varying degrees of polish. Have fun.

finished examples

detective problem

These are two approaches to solving a detective's problem. She's interrogated three witnesses to a murder, all of whom are also suspects. The problem is to determine which of the suspect's testimony is inconsistent with the others.

  • detectivepuzzle.pl - My original solution, written when I was new to Prolog. It now feels very 'imperative'
  • newdetective.pl - I recently rewrote it
  • adriandetective.pl - Adrian King's solution

talespin2.pl

Implementation of a classic story generator (note that a far better implementation is at https://github.com/SWI-Prolog-Education/talespin-annie)

tictactoe.pl

Implementation of tic tac toe

birds.pl

The birds example from the 'expert systems in Prolog' tutorial by Amzi (on the web)

cannibals2.pl

A well commented example of the cannibals/missionaries problem

This was used as an example for a talk whose notes are in may15version.txt

cannibals2nocomments.pl has fewer comments, but has some additional capabilities

cuttutorial.pl

A little story analogy to help understand cut and cut, fail

emoticons.pl

A joke. I'm known for my happy array of 'smiley' emoticons. Sometimes others have trouble understanding my smileys. This program purports to help.

familytree.pl

The classic familytree example. This one has two separate families in it. (left as exercise for the reader to find the two disconnected groups).

socketdemo.pl

Demonstration of reading from a socket

Constraint examples

Examples of CLPFD

addlists.pl

Constrains two lists to pairwise add to a third.

children.pl

A fully worked problem involving seating children in a classroom

constraintolist.pl

A fully worked problem, constraining a variable to be a member of a list.

sudoku.pl

Solves a Sudoku puzzle by CLPFD

loops.pl

Demo of various ways to do in Prolog what you'd do with loops in an imperative language.

nqueens.pl

Implementation of the generalized version of the classic 8-queens problem.

techtree2.pl

solve game 'tech tree' problems using CHR.

prolog-examples's People

Contributors

anniepoo avatar ian-andrich avatar jessealdridge avatar rynsy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

prolog-examples's Issues

Emoticons.pl returning too many results on mismatch

We have a critical bug here in emoticons.pl. It seems when a query doesn't find a valid match, it returns everything in the database.

EXPECTED BEHAVIOR: emoticons(fdjkfdj, Eng) where Eng = darned if I know, half the time they confuse me too.

OBSERVED BEHAVIOR: Eng = all possibilities.

Tutorial on using Tictactoe

Hi, my name is Ridho. I want to promote tictactoe using prolog in my class but I know nothing about prolog and about your code. Could anyone help me on what is the first step on running this program till the game end? Thank you in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.