machine learning in Python to play checkers? [closed]

帅比萌擦擦* 提交于 2019-12-04 07:57:50
Hans Scundal

You might want to take a look at the following: Chinook, Upper Confidence Trees, Reinforcement Learning, and Alpha-Beta pruning. I personally like to combine Alpha-Beta Pruning and Upper Confidence Trees (UCT) for perfect information games where each player has less than 10 reasonable moves. You can use Temporal Difference Learning to create a position evaluation function. Game AI is probably the most fun way to learn machine learning.

For links to all of these topics, click on

http://artent.net/blog/2012/09/26/checkers-and-machine-learning/

(I was not able to include more links because the stack overflow software considers me a newbie!)

Get the book called "Machine learning" by McGraw Hill and read the first chapter. It's extremely well written and the first chapter will teach you enough to make a program that plays checkers. Personally I made a program that plays 5 in a row on miniclip.com, also in python.

http://www.amazon.com/Learning-McGraw-Hill-International-Editions-Computer/dp/0071154671

When playing checkers, you seek to gain an advantage over your opponent by taking his or her pieces and crowning your own. Losing your pieces and allowing your opponent to crown his or her pieces is not desirable, so you avoid doing it.

Board game engines usually revolve around a position evaluation function. For checkers, my first guess would be something like this:

score =       number of allies         -     number of opponents
        + 3 * number of crowned allies - 3 * number of crowned opponents

Given a board, this function will return the score of the board. The higher the score, the better your position. The lower the score, the worse your position.

To make a naive checkers "engine", all you need to do is find the best move given a board position, which is just searching through all immediate legal moves and finding the one that maximizes your score.

Your engine won't think ahead more than one move, but it will be able to play against you somewhat.

The next step would to give your engine the ability to plan ahead, which essentially is predicting your opponent's responses. To do that, just find your opponent's best move (here comes recursion) and subtract it from your score.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!