Giter Site home page Giter Site logo

sadiul-hakim / minesweeper-csp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ebarlas/minesweeper-csp

1.0 0.0 0.0 31 KB

Minesweeper implemented in Java using virtual threads and communicating sequential processes

License: MIT License

Java 100.00%

minesweeper-csp's Introduction

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.

minesweeper-csp's People

Contributors

ebarlas avatar

Stargazers

sadiul-hakim. avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.