/connect-four-challenge-client-java

Java client to play the game connect four. #GameNightHacked2018

Primary LanguageJavaOtherNOASSERTION

connect-four-client-client-java Build Status

This is a Java client for the connect four challenge server. This client allows you to easily develop a bot for the connect four challenge.

Getting started

Clone this repository and start the ConnectFourClientApplication class:

public class ConnectFourClientApplication {
    private static final String SERVER_URL = "http://localhost:8080";
    private static final int NUMBER_OF_GAMES = 1_000;

    public static void main(String[] args) {
        ConnectFourAdapter connectFourAdapter = new ConnectFourAdapter(SERVER_URL);
        ExecutorService executor = Executors.newFixedThreadPool(2);
        executor.submit(new GameRunner(connectFourAdapter, "Alice", new RandomStrategy(), NUMBER_OF_GAMES));
        executor.submit(new GameRunner(connectFourAdapter, "Bob", new RandomStrategy(), NUMBER_OF_GAMES));
    }
}

Implement your own bot

To implement your own bot you need to provide an implementation of the ConnectFourStrategy interface:

public interface ConnectFourStrategy {
    int dropDisc(Game game);

    default void win(Game game) {
    }

    default void loose(Game game) {
    }

    default void draw(Game game) {
    }