Authors: Phelan, Mesbah
What is the problem?
State the general problem. If applicable, tell us what information you will use, e.g., a link to some web site that provides the information you used. What will you do?
We will create the game of Chess in prolog, modelling the board state with all the pieces. We will allow players to make moves while checking that they are valid, according to the rules of chess (https://en.wikipedia.org/wiki/Rules_of_chess). We will analyze the board state to see if a player is in check, if a player is checkmated, or if there is a stalemate.
What is the something extra?
What is the in-depth aspect you will do? If the problem is related to some other group's project, tell us how they fit together. If in doubt, include the information.
We plan to implement all rules of chess, including the less common ones such as castling, en passant, and pawn promotion. We will also analyze the board to see which player is “winning” (i.e. has more points), and use this to see if we can create an AI to predict favourable moves. We will also try to make a GUI to visualise the board.
What did we learn from doing this?
What is the bottom-line? Is logic programming suitable for (part-of) the task? Make sure you include the evidence for your claims.
We learned that logic programming is very suitable for describing the rules of chess. Chess has a strict rule set that is fairly easily converted to logic statements in prolog, and the nature of the language made writing some of the rules very straightforward. However, since prolog does not allow direct index access on lists, our solution on storing the board state felt less efficient than a regular 2-dimensional array. Nevertheless, it allowed for some powerful controls. For example, after defining each rule it was as easy as calling move() with variables to get a list of every legal move that a certain color could make given a specific board state. This proved much simpler than traditional languages, which would have required a lot of complex looping.
We were also surprised to find how easy it was to create a web-server using prolog. Actually parsing incoming data and formatting the output was a minor nightmare, but establishing an HTTP connection, creating an API endpoint, and serving static files was fairly straightforward. Due to time constraints, we were unable to finish the AI, but we compensated for this by connecting the system to an amazing web-based GUI.
In the end, prolog was an adequate tool to solve this the logic component of this programming task.