How Chess Algorithm Works?

How Chess Algorithm Works?

Chess is a two-player strategy board game played on checkered board with 64 squares arranged in an 8x8 grid. For your information, chess…

STEP 1 : Constructing “tree” When we start the game, each player have 16 pieces. Assume now is computer turn. The computer can make 1 of 20 possible moves (2 each for the 8 pawn, plus 2 each for the knights). After that, the opponent can also make 20 possible moves. That make it we have 20*20 possible scenarios which means 400 scenarios only in two turns. Next, the computer can make another 20 possible moves to each of these 400 scenarios. As long the game still continues, the tree will keeps growing. In theory, the perfect computer would be able to get to the very bottom of this tree, and look at all possible configurations of the board, approximately 10¹²⁰. Then, it would see which are the paths down this tree that will lead to the victory, and choose the best one for the bot. STEP 2 : Evaluating the outcomes Pretty sure that all of us know the problem, 10¹²⁰ is very huge number. For your information, the total estimated atoms in the universe are 10⁷⁵, in other words, the bot might still calculating its move while universe already reached its end. The real and sufficient computers will build up this tree to the best of their hardware capabilites, like 5, or 10, or 20 or whatever moves into the future. Once they have this limited tree, they evaluate each position using an evaluation function. The pretty simple example is an evaluation function could be the number of pieces the computer has minus number of pieces opponent has. For example, the computer has 12 pieces left on the board, while the opponent only has 8. Then the computer would evaluate such a board to 12-8 = 4. Of course, that is not a very good evaluation function, but that is the idea. This can be made more and more complicated, taking into account of many values such as individual pieces, board position, control of the center, vulnerability of the king to check, vulnerability of the opponent’s queen, and tons of other parameters. Function can be whatever as long as it works, as it allows a computer to compare board positions, to see which are the desirable outcomes. STEP 3 : Making a move After doing the analysis, now it is time to make the decision, this is the example of simplified tree.Now, let’s begin the fun part.First, it starts from the most bottom level, let’s call it first level. The computer will chooses the one with maximum score. Consider the right-most square team at the first level. It has two possible outcomes 2 and 5. Since it will be the computer’s turn at that stage, it chooses the best outcome, the one with MAX score, which is 5, and so it assigns 5 to that node. Same things for other square in the same level.

mathematics programming math chess algorithms

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Programming Require Math? Why Learning Math Will Make Better Programmer

Does Programming Require Math? It seems that the general population has a preconceived notion that mathematics and programming are an intertwined discipline. To be a great programmer, one also needs to be great at math. So, does programming require math?

A Guide to Important Graph Algorithms for Competitive Programming

And how you can use DFS and BFS. If you’ve read an Introduction to Competitive Programming, then you’re probably familiar with why Competitive Programming is important.

Making Sense of Algorithms: General Perspective

Making Sense of Algorithms: General Perspective: features, groups, and modes of searching and evaluating algorithms — forests to the trees.

The Math Behind “Big O” and Other Asymptotic Notations

The Math Behind “Big O” and Other Asymptotic Notations. The formal definitions of notations like “Big O”, “Big Omega”, and “Big Theta”.

A greedy algorithm is a simple

The Greedy Method is an approach for solving certain types of optimization problems. The greedy algorithm chooses the optimum result.