Giter VIP home page Giter VIP logo

java-checkers's Introduction

Java Checkers

Sample Checkers Game

Description

A checkers game with a GUI implemented in Java. The program supports a simple computer player as well as another checkers program instance connected through the network.

The computer player works by assigning a weight for each move. When a move weight is calculated, it is based off information such as move safety (e.g. if the move results in the checker being taken by the other player, it is less likely to make that move). It checks a number of other factors and assigns a final weight. The move with the highest weight is chosen as the move. To ensure computer players are less predictable, if multiple moves have the same weight then one is randomly chosen.

Compile and Run

Manual

  1. In terminal/command prompt, navigate to src/
  2. Compile with javac ui/*.java model/*.java logic/*.java network/*.java
  3. Run with java ui.Main

Features

User Interface

The checkers program comes complete with all graphical user interface components that scale relative to the size of the window. It is a user-friendly UI and has options to change the type of player for both player 1 and 2, and restart the game. In addition, it provides a checker board UI to show the current game state.

Different Player Types

Multiple different types of players are supported and can be selected by the user:

  1. Human - this is the player that allows the user to interact with the checker board when it is their turn.
  2. Computer - implements simple logic to make smart moves, without input from the user.
  3. Network - this type of player represents a player on a remote checkers client which can make moves.

All player classes extend the abstract Player class and either implement the logic to update the game or allow the user to input their moves.

Peer to Peer Connections

Network Game Setup Example

Each instance of a checkers window/program is network capable. It is able to make connections across the network to other checkers clients. To set up a network player, simply do the following:

  1. Select "Network" as the type of player, for the player you want to be controlled by a remote client.
  2. Click the "Set Connection" button
  3. Enter the source port that this client will listen for connections on (1025 to 65535).
  4. Click "Listen".
  5. Repeat steps 1 - 4 on the second client but for the other player (e.g. if client 1 has player 2 as a network player, then client 2 needs player 1 as a network player).
  6. Enter the host name or IP in the destination host field (e.g. 127.0.0.1, localhost, etc).
  7. Enter the destination port that the other client is listening on.
  8. Click "Connect".

In addition to peer-to-peer connections, a checkers window can act as a router and forward the game state between two clients if both of the players are network players.

Network Security

A small amount of security has been put in place for peer-to-peer connections. When a remote client makes a new connection, it receives a randomly generated session ID that must be used in all following messages between the clients. This ensures that another checkers client cannot pretend to be an already connected client and change the game state unexpectedly.

java-checkers's People

Contributors

devonmcgrath 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.