Skip to content

Instantly share code, notes, and snippets.

@azolotko
Last active December 19, 2015 07:09
Show Gist options
  • Save azolotko/5916639 to your computer and use it in GitHub Desktop.
Save azolotko/5916639 to your computer and use it in GitHub Desktop.
Write the rules of the rock-paper-scissors game
(ns rock-paper-scissors.core
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defrel beats hand1 hand2)
(facts beats [[:rock :scissor] [:paper :rock] [:scissor :paper]])
(defn play [hand1 hand2]
(run* [result]
(conde
((beats hand1 hand2) (== result :victory))
((beats hand2 hand1) (== result :loss))
((== hand1 hand2) (== result :tie)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment