Mechanical Survival

Set

I’ve been working on a ClojureScript simulation of Set.

targets

If you’re not familiar with the rules of Set, the aim of the game is to collect “sets”. A set is 3 cards where each attribute of colour, shape, fill and number is the same for all three cards or different for all 3 cards:

(defn makes-set? [cards]
  (let [attrs [:colour :fill :shape :number]]
    (and (= 3 (count cards))
         (every? (fn [prop]
                   (let [vs (map #(get % prop) cards)
                         variations (count (distinct vs))]
                     (or (= variations 1) ; all the same
                         (= variations 3)))) ; all different
                 attrs))))

You can play the game here: https://duncanjbrown.github.io/set/

So far it’s not networked or anything, and there are a couple of bugs around the end of the game, but the basic mechanics are working.

Now in my house we have a rule to make Set more interesting, which we call Nelly’s rule after our friend Nelly, who always insists on it. Nelly’s rule is that if you call “SET!” and then fail to identify a set, you have to give up one of your existing sets. This tends to make things a little bit more tense and more interesting.

There’s also a rule to Set which to my mind works in the opposite direction, which is that if you all feel like there are no sets on the table, then you’re allowed to put out 3 extra cards. I don’t really like doing this because if there’s a hard-to-find set on the table, I don’t want to cop out if we don’t have to.

That’s why on the left there is a checkbox called “Highlight Sets”. This lights up all the cards on the table which can form sets with the others, so it can let you know if the table has any sets at all on it.

This feature isn’t really intended for use in the simulation. What I want is to be able to press “Highlight sets” in real life. My assumption is that doing this via a smartphone photo is going to be good enough. & the shadow purpose of this simulation to test-drive the UX for this feature.

My criteria are

I’ll post updates here as I make progress.

The source code for Set is here: https://github.com/duncanjbrown/set

#Programming #Clojurescript #Set