machine learning in Python to play checkers? [closed]

[亡魂溺海] 提交于 2019-12-06 02:47:28

问题


I am a machine learning beginner. I'd like to learn the basics by teaching computers to play checkers. Actually, the games I want to learn are Domineering and Hex. My language of choice is Python

These games are pretty easy to store and the rules are much simpler than chess, but there aren't too many people who play. If I can get this idea off the ground it would be great for experimenting Combinatorial Game Theory to see if a computer and find the optimal move.

I found this old paper on checkers from the 1960's by a guy at IBM. Originally I had asked about neural networks, but they are saying it's the wrong tool.

EDIT: It could be that machine learning is not the right strategy. In that case, what goes wrong? and what is a better way?


回答1:


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!)




回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/12593834/machine-learning-in-python-to-play-checkers

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