Gorebei's Code So Far / Stones

Sub-page of GorebeisCodeSoFar

Stones seem pretty easy: we make three global objects that represent any black stone, any white stone, or no stone at all. We give each type a character so it can print nicely using ASCII:

 (defclass Stone ()
   ((PChar :accessor PChar :initarg PChar )))
 (defvar *Black*)
 (defvar *White*)
 (defvar *Empty*)
 (setq *Black* (make-instance 'Stone 'PChar #\X ))
 (setq *White* (make-instance 'Stone 'PChar #\O ))
 (setq *Empty* (make-instance 'Stone 'PChar #\. ))

Maybe we'll need this, I'm not sure:

 (defmethod other ((s Stone))
   (if (eq s *Black*) *White* *Black*))

This is a copy of the living page "Gorebei's Code So Far / Stones" at Sensei's Library.
(OC) 2014 the Authors, published under the OpenContent License V1.0.
[Welcome to Sensei's Library!]
StartingPoints
ReferenceSection
About