Giter Club home page Giter Club logo

sdm_project's Introduction

Software Development Methods course project

CircleCI

Exam project for the Software Development Methods course at the University of Trieste. Written in Java, using Gradle, CircleCI and libGDX. The template for this project has been generated using libGDX's tool.

The Freedom board game

This repository contains an implementation of the freedom board game. Below you can find a brief description, which was taken from here:

Freedom is a two-player abstract strategy board game invented by Veljko Cirovic and Nebojsa Sankovic in 2010. It is played with black and white stones on a square board. The game is related to Go-Moku and Slimetrail. It can be played with a Go set or with pen and paper.

Rules:

  • Board: Freedom is played on a 10×10 square board. Beginners can try the game on an 8×8 board. Other board sizes may be also used.

  • Objective: The objective of Freedom is to have more "live" stones at the end of the game than your opponent has. A stone is considered to be "live" if it is a part of some horizontal, vertical or diagonal row of exactly 4 stones of the same color.

  • Play: A game begins with an empty board. Each player has an allocated color: White and Black. White plays first, putting one white stone anywhere on the board. After this move players take turns placing their stones on empty cells adjacent to the last opponent's stone. If all cells adjacent to the last opponent's stone are occupied then the player gets the right ("freedom") to place his stone on any empty cell of the board. The game ends when the board is filled with stones. The last player has the right to pass on his last turn (and leave the last cell empty) if placing his stone reduces his score.

Project configuration and setup

The project is divided in five different modules:

  1. A core module, containing the core classes and main GUI implementation
  2. An android module, with an AndroidLauncher that runs the game within an Android Activity
  3. A desktop module, with a DesktopLauncher to run the game as a desktop app
  4. A html module, that builds the necessary files to execute the game on a server or as a webapp
  5. A terminal module, to launch the application as a terminal-based game

All modules are fully documented with javadoc-style documentation. To generate it, simply run the relevant gradle task. You can optionally specify the module name.

./gradlew [module_name]:javadoc

Minimum requirements

This project requires Java version 11 to run, as specified in the gradle.build configuration files. As for Android, it requires API level 14 (Android 4.0) to run.

Code analysis

A dockerized SonarQube server with persistent storage is provided to enable code analysis. To start the server, simply run the following command:

docker compose -f path/to/docker-compose.yml up -d

An issue may appear on Linux systems, indicating that the container requires more virtual memory in order to run correctly:

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

To temporarily circumvent this issue, run the following command. For more information, check out this thread

sudo sysctl -w vm.max_map_count=262144 

To use the Sonarqube Scanner run:

./gradlew -Dsonar.login=[auth_token] sonar

To generate a code coverage report for the whole project with JaCoCo run:

./gradlew -Dsonar.login=[auth_token] test jacocoTestReport sonar

Unit testing

Each module can have its own set of tests. Unit testing is done via the JUnit 5 framework, using Mockito to mock libGDX's rendering capabilities.

The tests can be executed all together, by running the main test task:

./gradlew test

Or they can be executed separately for each module:

./gradlew [module_name]:test

Run the project

To launch the desktop application, run:

./gradlew desktop:run

To launch the webapp, run:

./gradlew html:superDev

This command will also start a server on local port 8080.

If you only wish to compile the project to Javascript and then use the generated files yourself, run:

./gradlew html:dist

More details on what to do next and where to find the generated files can be found here. If you want to give it a try without having to compile everything yourself, you can take a look at the webapp version of the game on our GitHub Pages website!

To launch the terminal-based version of the game with gradle, run:

./gradlew terminal:run

As an alternative, you could also build the jar executable yourself by running:

./gradlew terminal:dist

The obtained jar file can be then executed by a JVM. You can find out the available command-line arguments by specifying the --help option.

To build an unsigned APK file for Android, run:

./gradlew android:assembleRelease

By default, you can't publish or install unsigned APKs on Android devices. We provide a version signed by us in the Releases section of this repository.

Credits

This project was built using the libGDX library. All credits go to the authors. The command line argument parsing was done using the JCommander tool. All credits go to the author, Cédric Beust.

sdm_project's People

Contributors

manuelkoso avatar peiva-git avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

manuelkoso

sdm_project's Issues

Tests refactoring

A refactoring of the tests classes is needed, I'm gonna start by moving the providers to appropriate Providers classes

Last move dialog

Is your feature request related to a problem? Please describe.
Implement the last move dialog

Board size

I realized that a board can have other sizes, not only 8x8 or 10x10 (see README description).

Functional programming

We have to start to use more Streams (we can start by replacing some for statements).

Main menu screen

Is your feature request related to a problem? Please describe.
Improve the main menu appearance

Refactor the `FreedomLine` class

  1. Is there a more relevant toString() method than the original one?
  2. equals(): why is the board field considered when evaluating if two FreedomLines are equal?

Improve unit testing

Improve tests by checking the following:

  1. There should be a test for each class method
  2. For each method, test:
    1. One correct input
    2. One wrong input
    3. Every border case
    4. Test for exceptions thrown

Get user input (terminal version)

As "first working implementation" I think that we have to create a terminal version of the game. So we need to decide how to read user inputs (in #31 I created a UserInput interface)

Bug when using a board size that's too large

Describe the bug
Board columns appear as ASCII characters other than letters

To Reproduce
Steps to reproduce the behavior:

  1. run the terminal:run gradle task with a board size parameter of 90

Expected behavior
Board size should be limited to the number of letters in the english alphabet

Screenshots
If applicable, add screenshots to help explain your problem.
bug

Environment:

  • terminal module
  • gradle launch configuration

Refactor `MapBoard` class

The Board's iterator should probably be removed and replaced by a getPositions() method entirely. Also, the Cell interface is never used outside of MapBoard: we might as well refactor it into a private abstract class inside of MapBoard, replacing MapBoardCell

Generalize `Game` class

We have to make the class Game more general. We can create an abstract class Game and a class that extends the Game class named FreedomGame. The FreedomGame would have a field UserInput userInput which is initialized in the constructor as follows (for example):

    public enum TypeOfGame {TERMINAL, GUI, CLIENT_SERVER}

    private UserInput userInput;

    public FreedomGame(@NotNull Board board, @NotNull Player whitePlayer, @NotNull Player blackPlayer, @NotNull TypeOfGame typeOfGame) {
        super(board, whitePlayer, blackPlayer);
        switch (typeOfGame) {
            case TERMINAL:
                this.userInput = new TextInput();
            case GUI:
                // TODO
                break;
            case CLIENT_SERVER:
                // TODO
        }
    }

This is just an idea, we can do it another way, for example creating three different classes for the three versions of the game. Let me know what you think.

Refactor FreedomLine class

It has to be generalized (e.g. Line class) and there must be a check in the add method (and also in the constructor) to prevent "no-line" shapes

Add a class for Color enum

I think that we need a separate class file where to place the color enum, because it will be used in different classes.

Class Logger

I think that we need a class Logger for logging on the standard output.

Found bug when printing user feedback in the no freedom case

Found bug

When picking a free cell on row 8, on the next iteration the system wrongly suggests cells that are out of board bounds

How to reproduce

Start a game. Keep picking positions until you reach row 8. On the next iteration, positions outside the board will be wrongly suggested. Thankfully, if a position out of bounds gets picked, the system refuses it. However, even if the next picked position is correct, the system will crash.

Class Play

I think that the putStone method is not strictly related to the Board class. So, instead, we can create a class Play which will contain the method putStone and other actions that a Player can do.

`RuntimeException` when executing the `desktop:run` gradle task

Describe the bug
When the desktop:run gradle task is executed, a RuntimeException is thrown

To Reproduce
Steps to reproduce the behavior:

  1. Run ./gradlew desktop:run
  2. Click on an empty tile

Expected behavior
An image asset should be loaded on the empty tile

Environment:

  • Project module: desktop
  • Launch configuration used: gradle launch configuration

Bug with user input acquisition in `TextInput`

If the board is larger than 9x9, the user is unable to insert row indexes larger than 9, because the used regex prevents it.
The following condition needs to be corrected:

if (input.matches("[A-Z][0-9]")) {
// etc
}

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.