/clos-sweeper

Primary LanguageCommon LispThe UnlicenseUnlicense

clos-sweeper

screenshot-won.png

A toy mine sweeper written in Common Lisp. Left mouse click uncovers the boxes. Right mouse click toggles the mine state. There are two different colours for right clicked boxes. Pink if there is a mine in that field and purple for flagged field without mine. This makes it helpful to solve even the large grid.

I can not find the way to create a small zipped folder to distribute Windows executable. If you happen to know how to do it please provide advice.

License

Public Domain

Libraries

https://github.com/bohonghuang/cl-gtk4

https://lispcookbook.github.io/cl-cookbook/clos.html

Setup

Make sure SBCL is installed

Make sure you have quicklisp and ultralisp installed.

https://www.quicklisp.org/beta/

https://ultralisp.org/

Make sure you have gtk4 libraries installed.

Linux

On Ubuntu like Linux you run:

sudo apt install libgtk-4-dev

Windows

First I installed Emacs from using the installer from https://www.gnu.org/software/emacs/download.html#nonfree

Then I installed SBCL 2.3.2 http://www.sbcl.org/platform-table.html

Then I installed MSYS2 https://www.msys2.org/

On Windows 11 with MSYS2 run MINGW64 terminal and execute:

pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-gtk4 mingw-w64-x86_64-cairo mingw-w64-x86_64-gobject-introspection

Cmd files

I have a *.cmd c=script that starts Emacs with correct environment setting

set PATH=c:/msys64/mingw64/bin;c:/msys64/usr/bin;%PATH%

C:\"Program Files"\Emacs\emacs-29.1\bin\runemacs.exe

Also I have a similar powershell_launcher.cmd that starts Windows powershell and allows me to run the tests and compile the executable from the shell

set PATH=c:/msys64/mingw64/bin;c:/msys64/usr/bin;%PATH%

powershell

Running

Terminal

Use the cd command to go to the root of the project and run:

sbcl --load ./launch.lisp

Windows REPL

(push #p"c:/Users/jacek/Programming/Lisp/clos-sweeper/" asdf:*central-registry*)
(ql:quickload :clos-sweeper)
(clos-sweeper::main)

Linux REPL

(push #p"~/Programming/Lisp/clos-sweeper/" asdf:*central-registry*)
(ql:quickload :clos-sweeper)
(clos-sweeper::main)

Testing

in the terminal

sbcl --load  ~/Programming/Lisp/clos-sweeper/testing.lisp

in the REPL

(push #p"~/Programming/Lisp/clos-sweeper/" asdf:*central-registry*)
(ql:quickload :clos-sweeper)
(ql:quickload :clos-sweeper/tests)
(asdf:test-system :clos-sweeper/tests)

Some tests may write a snapshot of the canvas. It goes to tmp on Linux and on Windows it goes to: C:\Users\jacek\AppData\Local\Temp. That folder does not get cleared on reboot as tmp on Linux. You have to clear the *.png files manually.

Linting

(ql:quickload :sblint)
(sblint/run-lint:run-lint-asd "~/Programming/Lisp/clos-sweeper/clos-sweeper.asd" )

Not implemented

Icons

No icons yet, the state of the game is indicated by colour of the tiles.

Roswell

I am not sure if roswell will be needed, but I will add the notes just in case we need it later.

installing roswell

https://github.com/roswell/roswell/wiki/Installation#windows

# Windows
pacman -S mingw-w64-x86_64-roswell

# Linux
sudo apt install roswell

# show your default Lisp
ros list installed

https://github.com/roswell/roswell/wiki

https://github.com/roswell/roswell/wiki/How-to-setup-a-lisp-dev-environment-on-windows-with-Roswell

generating executable with roswell

This can generate an executable but for all our purposes the section Running at the top makes more sense.

rm .\src\clos-sweeper.exe
sh .\builder.ros
.\src\clos-sweeper.exe

msys2 doctor

I could tell the users to install MSYS2 and do some checks to see if MSYS2 is installed and in good condition.

That would allow us to avoid the super entangled mess of Windows distribution

The folder distributions/clos-sweeper-windows contains 2 ways of testing MSYS2 installation.

another possible MSYS2 solution

https://stackoverflow.com/questions/47438779/executing-a-script-in-msys2-mingw

simple solution

Compile the Lisp executable on Windows. Create a cmd script that will add MSYS2 path and call the executable. Create a shortcut to the cmd script to launch the script and the Lisp executable. The shortcut Properties dialog has a Run field that can be used to run the cmd script window minimized.