lucasnscr / kalaha-game

Implementing KalahaGame

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Kalah Game

This project has the purpose to run kalaha game with two players on the same computer.

Rules

Game Play

The player who begins with the first move picks up all the stones in any of his own six pits, and sows the stones on to the right, one in each of the following pits, including his own big pit. No stones are put in the opponents' big pit. If the player's last stone lands in his own big pit, he gets another turn. This can be repeated several times before it's the other player's turn.

Capturing Stones

During the game the pits are emptied on both sides. Always when the last stone lands in an own empty pit, the player captures his own stone and all stones in the opposite pit (the other player’s pit) and puts them in his own (big or little?) pit.

The Game Ends

The game is over as soon as one of the sides runs out of stones. The player who still has stones in his pits keeps them and puts them in his big pit. The winner of the game is the player who has the most stones in his big pit.

Installation and Technologies

  • Docker
  • Docker-compose
  • Java 17
  • Maven
  • SpringBoot
  • SpringDoc OpenApi
  • Lombok
  • JUNIT 5
  • Docker Maven Plugin by Fabric8 for generate containers with ARM64 Architecture

About Running Project

For running this project you need two forms, Maven or Docker-Compose. For using maven you need run this command

mvn spring-boot:run

Docker Compose

If you prefer using docker-compose, you need run the container, enter in container bash and execute the commnands:

docker-compose up -d

OpenApi documentation: http://localhost:8081/doc

Running the tests

mvn test

About the Solution

For the best construction of the game, it was necessary to use a behavioral pattern, a state machine.

The State pattern suggests that you create new classes for all possible states of an object and extract all state-specific behaviors into these classes.

Instead of implementing all behaviors on its own, the original object, called context, stores a reference to one of the state objects that represents its current state, and delegates all the state-related work to that object.

Example State Machine to this project

State illustration

Author

About

Implementing KalahaGame


Languages

Language:Java 99.7%Language:Dockerfile 0.3%