The Othello demo is a simple iOS app showing the basics of using LispWorks for iOS Runtime. It contains an Xcode project to run the GUI and some Lisp source code to play the game.
To try the demonstration, see the file
The 64 tiles on the board are represented by
UIImageView objects, created dynamically in the
viewDidLoad method. The contents of the tiles are the images "empty", "white" and "black" which are loaded from the
Images.xcassets asset catalog. The
viewDidLoad method also creates an instance of the class
OthelloServer, which is implemented in Lisp (see Notes about the Lisp code).
The Lisp evaluation pane is displayed by the
Lisp Panel scene and contains a text field for entering a Lisp form (the
formInputView outlet), a text field to display the evaluation results (the
textOutputView outlet) and toolbar.
init-othello-server is the main entry point of the Lisp code and is called when
LispWorksInitialize is called from
main.m. It initializes the LispWorks Objective-C interface and creates a helper object (
lispworks-main-threads-funcalls-object) used by
invoke-in-main-thread for making Lisp calls in the main thread of the application.
The Lisp code implements an Objective-C class
OthelloServer using the Lisp class
othello-server. This class implements the methods
initWithViewController for initialization and
undoMove for the Othello game GUI code to call into Lisp in response to user gestures.
The Lisp code also implements the functions
othello-user-print-diagnostics-message which the shared Othello logic calls to update the GUI. Most of these functions call methods on the
OthelloViewController object, taking care to invoke them in the main (GUI) thread of the application. This thread switching is needed because the Othello logic plays the game in a background thread to avoid hanging the GUI while considering its move (see
Finally, the Lisp code implements an Objective-C class
LispPanelServer using the Lisp class
lisp-panel-server, with a method
evaluate: to evaluate a Lisp form. This
evaluate: method is called by the
evaluate: action method in
LispWorks User Guide and Reference Manual - 13 Feb 2015