Git Product home page Git Product logo

othello-in-haskell's Introduction

Othello

This is a simple implementation of the Minimax algorithm for Othello/Reversi. Is my first "real" code after a few days attempting learn Haskell, so it might not be very idiomatic, elegant or readable.

Why?

Why not? Othello is a nice game to play, that requires no graphics and the Minimax algorithm can be implemented fairly easily. I had written it once before in C (and failed horribly in Visual Basic), so I knew what I was in for. It is complex enough to be more than a small exercise. Plus, I get to brag about how 1337 I am implementing AI in Haskell. I could find only one other implementation when I wrote this, and it was written in a kind-of-imperative style.

How?

To play, just enter the X/Y coordinate as a tuple, ie. (4,2). You play as "O".

The basic datastructure is a map of an Int,Int tuple to a Piece data. This let me use an immutable datastructure, and still refer to the pieces in a simple x/y coordinate system.

The heuristics are pretty simple. The Minimax algorithm is set up to optimize for advantage in the number of pieces but most importantly, the number of possible moves. This ensure the AI will dominate the match, leaving you no room to make any smart moves for yourself. I'm not a terrible othello player, but I had a hard time beating the AI.

TODO

  • Update to be more idiomatic Haskell. I had some code review from a Haskell hacker friend, but I'll need some more Haskell time to "get" some of the point free style and evaluate what I like.

  • Implement alpha/beta pruning. This should be simple, but I've never actually done it.

  • Parallelize? I have two cores and multithreading. This should be the ideal algorithm to split over a number of threads. We'll see as soon as I get the urge to Haskell.

othello-in-haskell's People

Watchers

 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.