Skip to content

ebarlas/minesweeper-csp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minesweeper CSP

Minesweeper CSP is a Java implementation of Microsoft Minesweeper using communicating sequential processes (CSP).

Each game tile is an independent, anonymous process and all communication occurs via (buffered) channels. No explicit synchronization primitives are used beyond channels.

It's built atop virtual threads, defined in JDK Enhancement Proposal (JEP) 425 and available as a preview feature starting in Java 19.

The virtual threads feature is part of Project Loom.

Prior to virtual threads, CSP-style programming in this manner simply wasn't available in Java.

Channels

Build

An OpenJDK 19 or later build is required. At the time of this writing, virtual threads are a preview feature. That is why --enable-preview is provided below.


Build with mvn:

mvn compile

Run:

java --enable-preview -cp target/classes/ minesweeper.Main

Compile with javac:

javac --enable-preview -source 19 src/main/java/minesweeper/*.java -d build/

Run:

java --enable-preview -cp build/ minesweeper.Main

Command Line Arguments

Include beginner, intermediate, or advanced command-line argument to select a difficulty.

java --enable-preview -cp build/ minesweeper.Main advanced
Difficulty Rows Columns Mines Mine Density
Beginner 9 9 10 12%
Intermediate 16 16 40 16%
Advanced 16 30 99 21%

Assets

All game assets were created from scratch in Inkscape and rasterized to PNG images.

Processes

Every tile runs in its own process, defined in Cell.java. Cell processes communicate with each other via channels.

The game controller runs in its own process, defined in Game.java.

The window runs in its own process, defined in Window.java.

Finally, the clock runs in its own process, defined in Clock.java.

About

Minesweeper implemented in Java using virtual threads and communicating sequential processes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages