Non-associative commutative binary operation

Here is an example with identity element and inverses. On $\mathbb{R}_{\geq 0}$, define $a*b = \left| a-b \right|$. Then $*$ is clearly commutative, $0$ is its identity and the inverse of any $a$ is itself. Yet, it is not associative, since for instance $2*(1*1) = 2$ while $(2*1)*1 = 0$.


Consider the "rock-paper-scissors" operation $\ast$ on the set $\{R, P, S\}$ where we declare each element to be idempotent and declare the product of two distinct elements to be the winner according to the usual rules of Rock, Paper, Scissors: \begin{array}{r|ccc} \ast & R & P & S\\ \hline R & R & P & R\\ P & P & P & S\\ S & R & S & S . \end{array} The Cayley diagram is symmetric, so $\ast$ is commutative, but $$(R \ast P) \ast S = P \ast S = S \neq R = R \ast S = R \ast (P \ast S),$$ so $\ast$ is not associative.


Consider $\Bbb R$ endowed with the commutative arithmetic mean operation $$a \oplus b := \frac{a + b}{2}.$$ It is not associative, as $$(a \oplus b) \oplus c = \frac{a + b + 2c}{4}$$ but $$a \oplus (b \oplus c) = \frac{2a + b + c}{4} .$$ (The operation $\oplus$ has no identity, and hence no inverse, but it defines a quasigroup structure on $\Bbb R$, which means that for any $a, b \in \Bbb R$ there is $z \in \Bbb R$ such that $a \oplus z = b$.)

In fact, this construction seems to work just as well if we replace $\Bbb R$ by any (unital) ring in which $2$ is invertible.