Skip to main content

What is CLIPS?

CLIPS (C Language Integrated Production System) is a forward-chaining rule-based programming language designed for building expert systems. It was developed at NASA’s Johnson Space Center and is particularly well-suited for implementing AI game logic. The Mouse and Cats game leverages CLIPS’ pattern matching and rule-based inference engine to create intelligent cat AI that can trap the mouse player.

Version Requirement

This game requires CLIPS 6.4 to run properly. Make sure you have the correct version installed.

Basic CLIPS Syntax

Comments

; Single line comment starts with semicolon

; Multi-line documentation comments
; are just multiple single-line comments

Facts and Templates

Facts are the basic data units in CLIPS. Templates define the structure of facts:
(deftemplate person
  "Defines a person"
  (slot name (type STRING))
  (slot age (type NUMBER))
)

; Creating a fact
(assert (person (name "John") (age 30)))

Rules

Rules define conditional logic that fires when patterns match:
(defrule example-rule
  "Rule documentation"
  ?fact <- (condition-pattern)
  =>
  (printout t "Action executed" crlf)
  (retract ?fact)
)

Functions

Functions encapsulate reusable logic:
(deffunction my-function (?param1 ?param2)
  "Function documentation"
  (+ ?param1 ?param2)
)

Running CLIPS Commands

Once you have CLIPS 6.4 installed and the game loaded:

Starting the Game

; View instructions first
(instrucciones)

; Or jump straight into playing
(jugar)

Common CLIPS Commands

; Load the game file
(load "raton_y_gatos.clp")

; Reset the environment
(reset)

; Run all activated rules
(run)

; View all facts
(facts)

; View all rules
(rules)

; Clear the screen
(clear-window)

Interactive Game Commands

During gameplay:
  • Enter row number (1-8) when prompted for mouse movement
  • Enter column number (1-8) to complete the move
  • The cats will automatically respond with AI-calculated moves

Official CLIPS Documentation

For comprehensive CLIPS language reference:

CLIPS Documentation

Official CLIPS 6.4 documentation, user guide, and reference manual

CLIPS Expert System

Main CLIPS website with downloads and resources

Key CLIPS Features Used in This Game

  • Pattern Matching: Matching board states to trigger appropriate AI moves
  • Forward Chaining: Rules automatically fire when conditions are met
  • Salience: Priority levels for rules (e.g., endgame detection has highest priority)
  • Fact Modification: Updating board state by modifying casilla facts
  • Procedural Functions: Game setup and instruction display functions

Build docs developers (and LLMs) love