(en) PyCheckers — #1 Introduction

in #programming7 years ago

PyCheckers is series of articles in which I'll be describing my process of creating a checkers board game (also known as English draughts) in Python programming language. This is a project for my studies and I am still learning to code in Python, therefore I invite you all to follow up and learn with me.

Checkers on-line!

One of the projects that I have to make for my studies is the one in which I have to create a game in the Python programming language. I have decided to try my best and create a checkers board game from the ground up. There will be blood, sweat and tears, but I hope that in 2 months time what I'll have is a fully-fledged checkers game to play either with another human being or with a computer algorithm—and which at least poses a bit of a challenge to win with!

Also, if you're a Polish speaker, then I am simultaneously running this series in Polish language as PyWarcaby.

PyCheckers

On the game itself

Checkers board

by Jud McCranie, Wikimedia Commons

Checkers are one of the many draughts alternations. They are played on a 8x8 checkerboard with squares in light and dark colors (often black and white) alternating.

Each one of the players starts with 12 ordinary game pieces (called men) placed at their end of the board (let's call this the base for our convenience). This leaves exactly two empty rows between players' pieces, onto which they can move after starting the match. Game pieces can only move to dark squares, therefore player can move a man only diagonally to the front—away from his base. A man can only move by one square, not more. A player has to make a move in his round—omitting a move is prohibited.

Captures

If there is an enemy's piece in front of player's piece, then he can capture this enemy piece by jumping over it. Then the enemy's piece is removed from the board. A piece can only jump over one enemy's piece, so if there is another piece—either enemy of player's own piece—behind the piece you want to capture, then you cannot do this.

However, if you can capture enemy's piece, then you are required to do this—you can't skip capturing. If you can make two or more captures by different pieces of your own, then you are free to choose which one to make. If, after capturing enemy's piece, you can capture another of his pieces with the same piece you just moved, then you're move is extend so you can (and have to) do it. This is called a multiple capture.

A piece that will reach the end of the board—enemy's base—is automatically granted a king rank. This also ends the turn of player who reached enemy's base. A king can not only move forward, as men can, but can also move and capture backwards—towards his own base.

Winning conditions

Obviously, a player that captures all of his enemy's pieces wins. However, there are also situations in which one player still has got some pieces, but the other player has blocked all of these piece so none of them can make a move. The player whose pieces can no longer make any move loses.

A draw

In English draughts it is more often than for other draughts that a match ends with a draw. This situation happens when both of players are blocked by each other and none of them can make any move.

Some technical details

As I mentioned before, I will create the game using Python programming language in version 3.

Python logo

It is a high-level programming language that is often used for big data analysis, processing of huge data sets (especially text data) and machine learning. There is no problem whatsoever with using Python for other purposes like web apps and games (like in my case). The language is very flexible, adapts well to different use cases and has got a massive catalog of built-in/default libraries. I'd also like to note the increasing popularity of Python among programmers and the need for Python programmes in business.

My game will be built using Flask micro-framework, which makes creating a Python-based website a breeze. Flask is based on MVC (Model-View-Controller) paradigm and serves such basic functions as a routing engine and Jinja dynamic templating engine.

I want to make two different game modes: a game for two human players and the second one for human vs. computer match.

Two-players mode

Pretty straight-forward, I reckon. The app will allow two players to play a checkers match on two different computers. It only takes one player to start a new multi-player game and then send the generated unique link to a person that he/she wants to play with. After opening the link the second player will right in jump into the game.

Player vs. computer mode

This mode is the second big functionality of my game. This is also where the biggest obstacles will arise and where I will have most work at—and for you it means the most interesting content. I'll have to create and algorithm for the AI player, so that a match with it will be at least a little bit demanding.

Summing it up

This is all there is for today. In this introduction I described the basic rules of English draughts (checkers) board game and the details of my project. With these basic information I can start my project and you can follow my progress.

In the next episode I'll touch some more technical details:

  • more technical and unequivocal description of game rules,
  • more accurate description of my tech-stack,
  • information on the algorithm I'll be using for the AI.

I encourage you to follow my PyCheckers series if you're interested in technology, programming and artificial intelligence or any similar field. PyCheckers will let you get into algorithmic thinking and learn some new programming skills.

Also, feel free to comment articles in this series. I am not a professional programmer, so there for sure will be some bugs, mistakes and things that could be done better. If you spot anything like that, have got something else to add or want to ask some questions—feel free to do it!

Thank you for your attention and see you next time!

Sort:  

Congratulations @mciszczon! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

You got your First payout

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

Coin Marketplace

STEEM 0.19
TRX 0.15
JST 0.029
BTC 63493.34
ETH 2578.53
USDT 1.00
SBD 2.79