![]() StartingPoints Referenced by
|
The Code So Far - Stones
Keywords: Software
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 "The Code So Far - Stones" at Sensei's Library. ![]() |