Giter Site home page Giter Site logo

chess's Introduction

Group Project in TDT4240 - Software Architecture

This is the android application Chess++. It is an online multiplayer game where you can play one of many chess variants.

Project Image

Built with

  • Kotlin ๐Ÿค–
  • LibGDX ๐ŸŽฎ
  • Firebase Realtime Database ๐Ÿฆ

How to run the project

Prerequisites

  • Git
  • JVM version 17
  • Gradle 8.6
  • Install locally:
https://github.com/isaksolheim/chess.git
  • Android studio with Android SDK

Start the app

In android studio, make sure to have an emulated device running.

Navigate to the root of the project in a terminal. Run the project with:

./gradlew :android:run

Run the tests

In a terminal, in the root of the project:

./gradlew :core:test

Test report can be found in ./core/build/report/tests/index.html

Generate jacoco coverage report with:

./gradlew :core:jacocoTestReport

It can be found in ./core/build/report/jacocoHtml/index.html

Project Structure

The project is structured as follows:

  • android: Subproject for android.
  • core: Subproject for the chess logic and views.
    • src/me/isak/chess: Source code
      • model:
        • base: All version agnostic chess logic
        • versions: Folder with source code specific for each version of chess
          • fischer
          • horde
          • koth: King of the Hill
          • racing: Racing Kings
          • Standard
          • threecheck: Three Check
      • sound: Sounds and controller
      • viewmodels: Binds model and views together
      • views: Different views presented to the user
    • test/me/isak/chess: Test for chess logic
      • integration: Tests for running of full games of each version
      • model/core: Unit tests for chess logic

chess's People

Contributors

sondrp avatar isaksolheim avatar rockne avatar sundgom avatar klarawust avatar lkfurhov avatar

Stargazers

 avatar

Watchers

 avatar

chess's Issues

Three-check

Make new chess version: three check

Rules:

  • All normal chess rules apply.
  • If you make a legal move that puts the enemy king in check for the third time, you win.

A double check is counted as a single check.
Still possible to win by normal checkmate.

Horde

Make new chess version: Horde

Special starting position where white has 36 pawns.

Rules:

  • All normal chess rules apply.
  • Black win by capturing all the white pawns.
  • White win by normal checkmate.

Racing kings

Make new chess version: Racing kings

Rules:

  • Custom startingposition, where all pieces are on rank 1 and 2.
  • Not allowed to put the enemy king in check.
  • First player to reach the 8th rank with their king wins.

King of the Hill

Make new chess version: King of the hill.

Rules:

  • All normal chess rules apply.
  • If you make a legal move that moves your king to one of the center squares (d4, d5, e4, e5) you win.

Also possible to win by checkmating the king.

Promotion logic

Currently, a pawn automatically promotes to a queen when reaching the final row. Should implement logic allowing the user to select which piece they would like to promote to.

IsKingInCheck calculation can be improved

When finding out if a move is legal or not, we have to check if the move puts the king in check. This is done by calculating all the moves of the enemy, and checking if at least one of them captures the king. Here is the relevant code:

    // return true if one of the moves results in a board without a king
    return board.indices
      .filter { square -> board[square] != ' ' } // remove emtpy squares
      .filter { piece -> board[piece].isLowerCase() == whiteKing } // remove friendly pieces
      .flatMap { enemy -> calculateSimpleMoves(board, enemy) } // calculate all moves of the enemy piece
      .any { move -> !move.result.contains(kingToLookFor) } // check if one of the moves captured the king

it works fine, however it requires more computation than necessary. Even worse, the results are not cached, meaning that the whole calculation must be repeated for each potential move! That number could be 20+ for a queen on a sparse board.

Task: be more clever about this

Atomic

Make new chess version: Atomic

Rules:

  • Normal chess rules apply.
  • On capture: remove all pieces (except pawns) within a one square radius.
  • The team that blows up the enemy king first wins.
  • Normal checkmate is allowed.

atomic pieces despawn

The piece count does not update after an explotion, causing all pieces to despawn after being moved.

feature/makruk

chess variant called makruk. Ancient version of chess with slight changes to the rules.
Also new pieces

refactor move calculator

having two methods for checking if the king is in check is confusing. The user of the calculator must know which version of the pieces are used, which is not good design.

Change to let the calculator decide instead, by passing a parameter on creation.

bug/threecheck

bad logic for checking game over. Check counter might be incremented multiple times for each check. Causes games to end too early.

Handle game over

Improve method of accessing:

  1. board
  2. legal moves
  3. If the game is over
    Given that the game is over, it should have access to information about how.

Document & enhance chess core

Code is currently not documented, and unreasonably hard to read for anyone but the author.
The naming conventions does not align with the logical view architecture diagram.

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.