Git Product home page Git Product logo

chessfs's Introduction

โ™Ÿ ChessFs

ChessFs is a chess engine developed in F#.

StateActions pattern

The functional State pattern exposes all the possible operations and only transitions to a different state if the operation is legal. This is a nice pattern if the number of operations is low. However, when the number of legal operations and states is not well defined beforehand, it is better to only expose the legal operations.

The State Actions pattern is a way of doing this. For each state you will have a State-Actions object: it exposes representation data that allows UIs to show information about it, and a set of legal Actions. Each action has also representation data, but more importantly it has a function that return a new State-Actions object (which represents the result of executing said action on the former state).

This way, the UI can show just the actions that are legal at each step.

  • StateActions:

    • StateRepresentation
    • Action list
  • Action:

    • ActionRepresentation
    • unit -> StateActions

This is a really useful pattern with turn-based table games like chess or checkers because the state space is not bounded and the legal actions must be calculated for each state individually and can be quite a number of them. Also the number of possible actions (legal or not) is pretty big.

With this pattern you can easily implement a state machine. The input can be any kind of sequence; for example a sequence of strings with chess moves expressed in algebraic notation. The transition function will translate all the available Actions into the same a

PlayerActionOutcome (StateActions)

This type has its representation and list of actions available through the functions PlayerActionOutcome.representation and PlayerActionOutcome.actions.

ChessStateRepresentation (StateRepresentation)

A record with useful data to represent a chess board.

ExecutableAction (Action)

The representation of the action is available with ExecutableAction.representation and the function that gives the next PlayerActionOutcome is ExecutableAction.executefn.

PlayerActionDisplay (ActionRepresentation)

A discriminated union that represents the possible actions for a chess player.

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.