Coder Social home page Coder Social logo

connectfour-1's Introduction

Description

Play Connect Four against the computer with this Java applet. Right click on the mouse to drop a piece into the selected column. After watching your piece fall the computer will make its move. The difficulty setting can be adjusted to easy, medium, or hard.

alt text

Download

  • Download: zip
  • Git: git clone https://github.com/jostmey/ConnectFour

Compile

Make sure a Java Developer Kit (JDK) has first been installed such as Open JDK. Installation instructions for Open JDK may be found here but be sure to install the developer package, not the runtime environment. The program has been tested on OpenJDK 7 but is expected to work on more recent versions.

To compile the code from the command line terminal, set the working directory to this folder and run the following command.

javac GameEngine.java InterfaceEngine.java -d bin/

Run

If your browser supports java applets then you can use it to run the program simply by opening the file ConnectFour.html. Alternatively, you can run the program from the command line terminal. Set the working directory to this folder and run the following command.

appletviewer ConnectFour.html

How It Works

The program searches every possible move several turns into the future looking for "traps". A trap is a condition in the game such that no matter what you do the computer can still win. The program will pick the move that offers the greatest possibility of laying a trap to catch you, while at the same time trying to avoid any traps you set for it. As the program searches for its best move, the algorithm used to score each move assumes that you will pick the optimal move. In this respect, the underlying algorithm resembles the minimax alrogithm.

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.