Classification of Chess Games: an Exploration of Classifiers for Anomaly Detection in Chess

Total Page:16

File Type:pdf, Size:1020Kb

Classification of Chess Games: an Exploration of Classifiers for Anomaly Detection in Chess Minnesota State University, Mankato Cornerstone: A Collection of Scholarly and Creative Works for Minnesota State University, Mankato All Graduate Theses, Dissertations, and Other Graduate Theses, Dissertations, and Other Capstone Projects Capstone Projects 2021 Classification of Chess Games: An Exploration of Classifiers for Anomaly Detection in Chess Masudul Hoque Minnesota State University, Mankato Follow this and additional works at: https://cornerstone.lib.mnsu.edu/etds Part of the Applied Statistics Commons, and the Artificial Intelligence and Robotics Commons Recommended Citation Hoque, M. (2021). Classification of chess games: An exploration of classifiers for anomaly detection in chess [Master’s thesis, Minnesota State University, Mankato]. Cornerstone: A Collection of Scholarly and Creative Works for Minnesota State University, Mankato. https://cornerstone.lib.mnsu.edu/etds/1119 This Thesis is brought to you for free and open access by the Graduate Theses, Dissertations, and Other Capstone Projects at Cornerstone: A Collection of Scholarly and Creative Works for Minnesota State University, Mankato. It has been accepted for inclusion in All Graduate Theses, Dissertations, and Other Capstone Projects by an authorized administrator of Cornerstone: A Collection of Scholarly and Creative Works for Minnesota State University, Mankato. CLASSIFICATION OF CHESS GAMES An exploration of classifiers for anomaly detection in chess By Masudul Hoque A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree of Applied Statistics, MS In Master’s in Applied Statistics Minnesota State University, Mankato Mankato, Minnesota May 2021 i April 2nd 2021 CLASSIFICATION OF CHESS GAMES An exploration of classifiers for anomaly detection in chess Masudul Hoque This thesis has been examined and approved by the following members of the student’s committee. ________________________________ Advisor ________________________________ Committee Member ________________________________ Committee Member ii Table of Contents Chapter 1 Introduction .......................................................................... 1 1.1 Introduction ......................................................................................... 1 1.2 Literature Review .............................................................................. 2 1.3 Research Problem Statement ........................................................ 6 Chapter 2 Data ............................................................................................ 8 2.1 Data Source........................................................................................... 8 2.2 Data Description ................................................................................. 8 2.3 Data Preprocessing ....................................................................... 11 2.4 Data Manipulations ....................................................................... 13 Chapter 3 Methodology ....................................................................... 15 3.1 Classification ..................................................................................... 15 3.1.1 Discriminant Analysis ........................................................ 15 3.1.1.a Linear Discriminant Analysis ............................ 17 3.1.1.b Quadratic Discriminant Analysis ..................... 21 3.1.2 K Nearest Neighbour .......................................................... 24 3.1.3 Multinomial Logistic Regression ................................... 27 3.2 Model Validation ............................................................................. 32 3.2.1 Confusion Matrix .................................................................. 34 3.2.2 K Fold Cross-Validation ..................................................... 39 3.2.3 Leave One Out Cross-Validation..................................... 41 3.3 Technology Use ............................................................................... 42 iii Chapter 4 Results .................................................................................... 44 4.1 Phase I ................................................................................................. 44 4.1.1 Linear Discriminant Analysis .......................................... 51 4.1.2 Quadratic Discriminant Analysis ................................... 54 4.1.3 Multinomial Logistic Regression .................................. 57 4.1.4 K nearest Neighbour ........................................................... 62 4.1.5 Phase I Summaries .............................................................. 70 4.2 Phase II ................................................................................................ 77 4.2.1 Linear Discriminant Analysis .......................................... 81 4.2.2 Quadratic Discriminant Analysis ................................... 85 4.2.3 Multinomial Logistic Regression .................................. 89 4.2.4 K nearest Neighbour ........................................................... 94 4.2.5 Phase II Summaries .......................................................... 102 4.3 Phase III .......................................................................................... 109 Chapter 5 Conclusions ....................................................................... 118 5.1 Conclusion ...................................................................................... 118 5.2 Future Work ................................................................................... 121 References ............................................................................................... 123 Appendix .................................................................................................. 123 Python Codes ........................................................................................ 127 R codes..................................................................................................... 130 iv CLASSIFICATION OF CHESS GAMES An exploration of classifiers for anomaly detection in chess Masudul Hoque A THESIS SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE DEGREE OF MASTER OF SCIENCE IN APPLIED STATISTICS MINNESOTA STATE UNIVERSITY, MANKATO MANKATO, MINNESOTA MAY 2021 ABSTRACT Chess is a strategy board game with its inception dating back to the 15th century. The Covid-19 pandemic has led to a chess boom online with 95,853,038 chess games being played during January, 2021 on lichess.com. Along with the chess boom, instances of cheating have also become more rampant. Classifications have been used for anomaly detection in different fields and thus it is a natural idea to develop classifiers to detect cheating in chess. However, there are no specific examples of this, and it is difficult to obtain data where cheating has occurred. So, in this paper, we develop 4 machine learning classifiers, Linear Discriminant Analysis, Quadratic Discriminant Analysis, Multinomial Logistic Regression, and K-Nearest Neighbour classifiers to predict chess game results and explore predictors that produce the best accuracy performance. We use Confusion Matrix, K Fold Cross-Validation, and Leave-One-Out Cross- Validation methods to find the accuracy metrics. There are three phases of analysis. In phase I, we train classifiers using 1.94 million over the board game as training data and 20 thousand online games as testing data and obtain accuracy metrics. In phase II, we select a smaller pool of 212 games, select additional predictor variables from chess engine evaluation of the moves played in those games and check whether the inclusion of the variables improve performance. Finally, in phase III, we investigate for patterns in misclassified cases to define anomalies. From phase I, the models are not performing at a utilizable level of accuracy (44-63%). For all classifiers, it is no better than deciding the class with a coin toss. K-Nearest Neighbour with K = 7 was the best model. In phase II, adding the new predictors improved the performance of all the classifiers significantly across all validation methods. In fact, using only significant variables as predictors produced highly accurate classifiers. Finally, from phase III, we could not find any patterns or significant differences between the predictors for both correct classifications and misclassifications. In conclusion, machine learning classification is only one useful tool to spot instances that indicates anomalies. However, we cannot simply judge anomalous games using only this method. v Acknowledgements I would first like to thank my thesis advisor Dr Iresha Premarathna of the Department of Mathematics & Statistics at Minnesota State University-Mankato. Dr Premarathna was always available to provide invaluable insight, guidance, and answer any question about my research or writing. She consistently allowed this paper to be my work but steered me in the right direction whenever I felt lost. I would also like to acknowledge Dr. Mezbahur Rahman and Dr. Deepak Sanjel of the Department of Mathematics & Statistics at Minnesota State University-Mankato as esteemed members of the thesis committee, who were wonderful teachers in many of my courses. I am gratefully indebted to their teachings and valuable comments on this thesis. I must express my very profound gratitude to my mother, for providing me with unfailing support and continuous encouragement throughout my years of study and through the process of researching and writing this thesis.
Recommended publications
  • (2021), 2814-2819 Research Article Can Chess Ever Be Solved Na
    Turkish Journal of Computer and Mathematics Education Vol.12 No.2 (2021), 2814-2819 Research Article Can Chess Ever Be Solved Naveen Kumar1, Bhayaa Sharma2 1,2Department of Mathematics, University Institute of Sciences, Chandigarh University, Gharuan, Mohali, Punjab-140413, India [email protected], [email protected] Article History: Received: 11 January 2021; Accepted: 27 February 2021; Published online: 5 April 2021 Abstract: Data Science and Artificial Intelligence have been all over the world lately,in almost every possible field be it finance,education,entertainment,healthcare,astronomy, astrology, and many more sports is no exception. With so much data, statistics, and analysis available in this particular field, when everything is being recorded it has become easier for team selectors, broadcasters, audience, sponsors, most importantly for players themselves to prepare against various opponents. Even the analysis has improved over the period of time with the evolvement of AI, not only analysis one can even predict the things with the insights available. This is not even restricted to this,nowadays players are trained in such a manner that they are capable of taking the most feasible and rational decisions in any given situation. Chess is one of those sports that depend on calculations, algorithms, analysis, decisions etc. Being said that whenever the analysis is involved, we have always improvised on the techniques. Algorithms are somethingwhich can be solved with the help of various software, does that imply that chess can be fully solved,in simple words does that mean that if both the players play the best moves respectively then the game must end in a draw or does that mean that white wins having the first move advantage.
    [Show full text]
  • Should Chess Players Learn Computer Security?
    1 Should Chess Players Learn Computer Security? Gildas Avoine, Cedric´ Lauradoux, Rolando Trujillo-Rasua F Abstract—The main concern of chess referees is to prevent are indeed playing against each other, instead of players from biasing the outcome of the game by either collud- playing against a little girl as one’s would expect. ing or receiving external advice. Preventing third parties from Conway’s work on the chess grandmaster prob- interfering in a game is challenging given that communication lem was pursued and extended to authentication technologies are steadily improved and miniaturized. Chess protocols by Desmedt, Goutier and Bengio [3] in or- actually faces similar threats to those already encountered in der to break the Feige-Fiat-Shamir protocol [4]. The computer security. We describe chess frauds and link them to their analogues in the digital world. Based on these transpo- attack was called mafia fraud, as a reference to the sitions, we advocate for a set of countermeasures to enforce famous Shamir’s claim: “I can go to a mafia-owned fairness in chess. store a million times and they will not be able to misrepresent themselves as me.” Desmedt et al. Index Terms—Security, Chess, Fraud. proved that Shamir was wrong via a simple appli- cation of Conway’s chess grandmaster problem to authentication protocols. Since then, this attack has 1 INTRODUCTION been used in various domains such as contactless Chess still fascinates generations of computer sci- credit cards, electronic passports, vehicle keyless entists. Many great researchers such as John von remote systems, and wireless sensor networks.
    [Show full text]
  • On the Limits of Engine Analysis for Cheating Detection in Chess
    View metadata, citation and similar papers at core.ac.uk brought to you by CORE provided by Kent Academic Repository computers & security 48 (2015) 58e73 Available online at www.sciencedirect.com ScienceDirect journal homepage: www.elsevier.com/locate/cose On the limits of engine analysis for cheating detection in chess * David J. Barnes , Julio Hernandez-Castro School of Computing, The University of Kent, Canterbury, Kent CT2 7NF, United Kingdom article info abstract Article history: The integrity of online games has important economic consequences for both the gaming Received 12 July 2014 industry and players of all levels, from professionals to amateurs. Where there is a high Received in revised form likelihood of cheating, there is a loss of trust and players will be reluctant to participate d 14 September 2014 particularly if this is likely to cost them money. Accepted 10 October 2014 Chess is a game that has been established online for around 25 years and is played over Available online 22 October 2014 the Internet commercially. In that environment, where players are not physically present “over the board” (OTB), chess is one of the most easily exploitable games by those who wish Keywords: to cheat, because of the widespread availability of very strong chess-playing programs. Chess Allegations of cheating even in OTB games have increased significantly in recent years, and Cheating even led to recent changes in the laws of the game that potentially impinge upon players’ Online games privacy. Privacy In this work, we examine some of the difficulties inherent in identifying the covert use Machine assistance of chess-playing programs purely from an analysis of the moves of a game.
    [Show full text]
  • Emirate of UAE with More Than Thirty Years of Chess Organizational Experience
    DUBAI Emirate of UAE with more than thirty years of chess organizational experience. Many regional, continental and worldwide tournaments have been organized since the year 1985: The World Junior Chess Championship in Sharjah, UAE won by Max Dlugy in 1985, then the 1986 Chess Olympiad in Dubai won by USSR, the Asian Team Chess Championship won by the Philippines. Dubai hosted also the Asian Cities Championships in 1990, 1992 and 1996, the FIDE Grand Prix (Rapid, knock out) in 2002, the Arab Individual Championship in 1984, 1992 and 2004, and the World Blitz & Rapid Chess Championship 2014. Dubai Chess & Culture Club is established in 1979, as a member of the UAE Chess Federation and was proclaimed on 3/7/1981 by the Higher Council for Sports & Youth. It was first located in its previous premises in Deira–Dubai as a temporarily location for the new building to be over. Since its launching, the Dubai Chess & Culture Club has played a leading role in the chess activity in UAE, achieving for the country many successes on the international, continental and Arab levels. The Club has also played an imminent role through its administrative members who contributed in promoting chess and leading the chess activity along with their chess colleagues throughout UAE. “Sheikh Rashid Bin Hamdan Al Maktoum Cup” The Dubai Open championship, the SHEIKH RASHID BIN HAMDAN BIN RASHID AL MAKTOUM CUP, the strongest tournament in Arabic countries for many years, has been organized annually as an Open Festival since 1999, it attracts every year over 200 participants. Among the winners are Shakhriyar Mamedyarov (in the edition when Magnus Carlsen made his third and final GM norm at the Dubai Open of 2004), Wang Hao, Wesley So, or Gawain Jones.
    [Show full text]
  • Teaching AI to Play Chess Like People
    Teaching AI to Play Chess Like People Austin A. Robinson Division of Science and Mathematics University of Minnesota, Morris Morris, Minnesota, USA 56267 [email protected] ABSTRACT Current chess engines have far exceeded the skill of human players. Though chess is far from being considered a\solved" game, like tic-tac-toe or checkers, a new goal is to create a chess engine that plays chess like humans, making moves that a person in a specific skill range would make and making the same types of mistakes a player would make. In 2020 a new chess engine called Maia was released where through training on thousand of online chess games, Maia was able to capture the specific play styles of players in certain skill ranges. Maia was also able to outperform two of the top chess engines available in human-move prediction, showing that Maia can play more like a human than other chess engines. Figure 1: An example of a blunder made by black when they Keywords moved their queen from the top row to the bottom row indi- Chess, Maia, Human-AI Interaction, Monte Carlo Tree Search, cated by the blue tinted square. This move that allows white Neural Network, Deep Learning to win in one move. If white moves their queen to the top row, than that is checkmate and black loses the game [2]. 1. INTRODUCTION Chess is a problem that computer scientists have been ing chess and concepts related to Deep Learning that will attempting to solve for nearly 70 years now. The first goal be necessary to understand for this paper.
    [Show full text]
  • Rules of Chess
    Rules of chess From Wikipedia, the free encyclopedia The rules of chess (also known as the laws of chess) are rules governing the play of the game of chess. While the exact origins of chess are unclear, modern rules first took form during the Middle Ages. The rules continued to be slightly modified until the early 19th century, when they reached essentially their current form. The rules also varied somewhat from place to place. Today Fédération Internationale des Échecs (FIDE), also known as the World Chess Organization, sets the standard rules, with slight modifications made by some national organizations for their own purposes. There are variations of the rules for fast chess, correspondence chess, online chess, and chess variants. Chess is a game played by two people on a chessboard, with 32 pieces (16 for each player) of six types. Each type of piece moves in a distinct way. The goal of the game is to checkmate, i.e. to threaten the opponent's king with inevitable capture. Games do not necessarily end with checkmate – players often resign if they believe they will lose. In addition, there are several ways that a game can end in a draw. Besides the basic movement of the pieces, rules also govern the equipment used, the time control, the conduct and ethics of players, accommodations for handicapped players, the recording of moves using chess notation, as well as procedures for irregularities that occur during a game. Contents 1 Initial setup 1.1 Identifying squares 2 Play of the game 2.1 Movement 2.1.1 Basic moves 2.1.2 Castling 2.1.3 En passant 2.1.4 Pawn promotion Game in a public park in Kiev, using a 2.2 Check chess clock 3 End of the game 3.1 Checkmate 3.2 Resigning 3.3 Draws 3.4 Time control 4 Competition rules 4.1 Act of moving the pieces 4.2 Touch-move rule 4.3 Timing 4.4 Recording moves 4.5 Adjournment 5 Irregularities 5.1 Illegal move 5.2 Illegal position 6 Conduct Staunton style chess pieces.
    [Show full text]
  • Including ACG8, ACG9, Games in AI Research, ACG10 T/M P. 18) Version: 20 June 2007
    REFERENCE DATABASE 1 Updated till Vol. 29. No. 2 (including ACG8, ACG9, Games in AI Research, ACG10 t/m p. 18) Version: 20 June 2007 AAAI (1988). Proceedings of the AAAI Spring Symposium: Computer Game Playing. AAAI Press. Abramson, B. (1990). Expected-outcome: a general model of static evaluation. IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol. 12, No.2, pp. 182-193. ACF (1990), American Checkers Federation. http://www.acfcheckers.com/. Adelson-Velskiy, G.M., Arlazarov, V.L., Bitman, A.R., Zhivotovsky, A.A., and Uskov, A.V. (1970). Programming a Computer to Play Chess. Russian Mathematical Surveys, Vol. 25, pp. 221-262. Adelson-Velskiy, M., Arlazarov, V.L., and Donskoy, M.V. (1975). Some Methods of Controlling the Tree Search in Chess Programs. Artificial Ingelligence, Vol. 6, No. 4, pp. 361-371. ISSN 0004-3702. Adelson-Velskiy, G.M., Arlazarov, V. and Donskoy, M. (1977). On the Structure of an Important Class of Exhaustive Problems and Methods of Search Reduction for them. Advances in Computer Chess 1 (ed. M.R.B. Clarke), pp. 1-6. Edinburgh University Press, Edinburgh. ISBN 0-85224-292-1. Adelson-Velskiy, G.M., Arlazarov, V.L. and Donskoy, M.V. (1988). Algorithms for Games. Springer-Verlag, New York, NY. ISBN 3-540-96629-3. Adleman, L. (1994). Molecular Computation of Solutions to Combinatorial Problems. Science, Vol. 266. p. 1021. American Association for the Advancement of Science, Washington. ISSN 0036-8075. Ahlswede, R. and Wegener, I. (1979). Suchprobleme. Teubner-Verlag, Stuttgart. Aichholzer, O., Aurenhammer, F., and Werner, T. (2002). Algorithmic Fun: Abalone. Technical report, Institut for Theoretical Computer Science, Graz University of Technology.
    [Show full text]
  • The Cheater Hunter Mark Rivlin Interviews Andy Howie Andy Howie Is FIDE International Arbiter and Organizer, Executive Director
    The Cheater Hunter Mark Rivlin interviews Andy Howie Andy Howie is FIDE international arbiter and organizer, executive director of Chess Scotland and a Secretary/Delegate of the European Chess Union. He is at the heart of the battle against online and OTB cheating. In August 2020 he said on the English Chess Forum: “I can’t speak for other federations, but Scotland takes online cheating in organized tournaments very, very seriously. Anyone caught and proven to be cheating faces up to a 5 year ban depending on age.” You are a well-known and respected International Arbiter with a very impressive portfolio of tournaments, leagues and congresses. Tell us about your chess background and how you became an arbiter. Not sure about respected, infamous would probably be the adjective used by players up here in Scotland as I have a habit of arbiting in sandals and shorts even in the middle of winter! I started playing when I was seven, my dad taught me how to play. I won a few tournaments in Germany (I was brought up there as my father was in the armed services and we were based out there). I played with friends and work colleagues through the years and was a lot better than them so tried my luck in a local tournament and fell in love with it completely. I became an arbiter because a friend of mine was wronged in a tournament and I didn't know the rules well enough to argue. I swore I would never be in that position again, took the arbiters course and the rest, as they say, is history.
    [Show full text]
  • An Historical Perspective Through the Game of Chess
    On the Impact of Information Technologies on Society: an Historical Perspective through the Game of Chess Fr´ed´eric Prost LIG, Universit´ede Grenoble B. P. 53, F-38041 Grenoble, France [email protected] Abstract The game of chess as always been viewed as an iconic representation of intellectual prowess. Since the very beginning of computer science, the challenge of being able to program a computer capable of playing chess and beating humans has been alive and used both as a mark to measure hardware/software progresses and as an ongoing programming challenge leading to numerous discoveries. In the early days of computer science it was a topic for specialists. But as computers were democratized, and the strength of chess engines began to increase, chess players started to appropriate to themselves these new tools. We show how these interac- tions between the world of chess and information technologies have been herald of broader social impacts of information technologies. The game of chess, and more broadly the world of chess (chess players, literature, computer softwares and websites dedicated to chess, etc.), turns out to be a surprisingly and particularly sharp indicator of the changes induced in our everyday life by the information technologies. Moreover, in the same way that chess is a modelization of war that captures the raw features of strategic thinking, chess world can be seen as small society making the study of the information technologies impact easier to analyze and to arXiv:1203.3434v1 [cs.OH] 15 Mar 2012 grasp. Chess and computer science Alan Turing was born when the Turk automaton was finishing its more than a century long career of illusion1.
    [Show full text]
  • Learning to Play the Chess Variant Crazyhouse Above World Champion Level with Deep Neural Networks and Human Data Czech, Johannes; Willig, Moritz; Beyer, Alena Et Al
    Learning to Play the Chess Variant Crazyhouse Above World Champion Level With Deep Neural Networks and Human Data Czech, Johannes; Willig, Moritz; Beyer, Alena et al. (2020) DOI (TUprints): https://doi.org/10.25534/tuprints-00013370 Lizenz: CC-BY 4.0 International - Creative Commons, Attribution Publikationstyp: Article Fachbereich: 20 Department of Computer Science Quelle des Originals: https://tuprints.ulb.tu-darmstadt.de/13370 ORIGINAL RESEARCH published: 28 April 2020 doi: 10.3389/frai.2020.00024 Learning to Play the Chess Variant Crazyhouse Above World Champion Level With Deep Neural Networks and Human Data Johannes Czech 1*, Moritz Willig 1, Alena Beyer 1, Kristian Kersting 1,2 and Johannes Fürnkranz 3 1 Department of Computer Science, TU Darmstadt, Darmstadt, Germany, 2 Centre for Cognitive Science, TU Darmstadt, Darmstadt, Germany, 3 Department of Computer Science, JKU Linz, Linz, Austria Deep neural networks have been successfully applied in learning the board games Go, chess, and shogi without prior knowledge by making use of reinforcement learning. Although starting from zero knowledge has been shown to yield impressive results, it is associated with high computationally costs especially for complex games. With this Edited by: Balaraman Ravindran, paper, we present CrazyAra which is a neural network based engine solely trained Indian Institute of Technology in supervised manner for the chess variant crazyhouse. Crazyhouse is a game with Madras, India a higher branching factor than chess and there is only limited data of lower quality Reviewed by: Michelangelo Ceci, available compared to AlphaGo. Therefore, we focus on improving efficiency in multiple University of Bari Aldo Moro, Italy aspects while relying on low computational resources.
    [Show full text]
  • ECF Enewsletter April 2020
    A message from Chessable, sponsors of the ECF eNewsletter --- Must have classic, now available as 19 hours of video, and it's on sale! They are the 100 Endgames You Must Know and there is no quicker, easier and more efficient way to learn them than with this ... the ultimate endgame package on the ultimate chess learning platform. Find out more by following this link April 2020 ECF Newsletter Stay Safe – Play Chess at Home CONTENTS 1 - Play Chess at Home: an update from the ECF 2 - 4NCL Online: All the action from Round 1 3 - ECF Online Events 4 - Join the Club: Where to find your local online chess club 5 - ECF Online Ratings & OTB Monthly Grading 6 - Inside the Chess Bunker: Interview with chess journalist Leon Watson 7 - Tune In, Check Out: Chess podcasts you might like 8 - Chess on YouTube: 8 highly recommended channels 9 - We’ll Meet Again: What you need to know about postponed events 10 - Magnus Carlsen Invitational: $250,000 online rapidplay starts April 18 11 - In Czech: England’s teams at the World Senior Championships in Prague 12 - School’s Out, But Not Chess: CSC online resources for students & tutors 13 - Delancey UK Chess Challenge 14 - ECF Academy Goes Online 15 - ECF Finance Council update 16 – FIDE Veterans Award for Gerry Walsh 17 - Chess Magazine: April 2020 18 – ‘Checkmate Covid-19’ Red Cross Fundraiser 19 - ‘The Chess Pit’ Quiz: 10 brainteasers from the UK’s new chess podcast 1 - Play Chess at Home: An update from the ECF Dear chess friends, Welcome to this unusual April 2020 edition of the ECF Newsletter.
    [Show full text]
  • Python-Chess Release 1.6.1
    python-chess Release 1.6.1 unknown Sep 16, 2021 CONTENTS 1 Introduction 3 2 Installing 5 3 Documentation 7 4 Features 9 5 Selected projects 13 6 Acknowledgements 15 7 License 17 8 Contents 19 8.1 Core................................................... 19 8.2 PGN parsing and writing......................................... 36 8.3 Polyglot opening book reading...................................... 44 8.4 Gaviota endgame tablebase probing................................... 45 8.5 Syzygy endgame tablebase probing................................... 47 8.6 UCI/XBoard engine communication................................... 49 8.7 SVG rendering.............................................. 61 8.8 Variants.................................................. 63 8.9 Changelog for python-chess....................................... 65 9 Indices and tables 71 Index 73 i ii python-chess, Release 1.6.1 CONTENTS 1 python-chess, Release 1.6.1 2 CONTENTS CHAPTER ONE INTRODUCTION python-chess is a chess library for Python, with move generation, move validation, and support for common formats. This is the Scholar’s mate in python-chess: >>> import chess >>> board= chess.Board() >>> board.legal_moves <LegalMoveGenerator at ... (Nh3, Nf3, Nc3, Na3, h3, g3, f3, e3, d3, c3, ...)> >>> chess.Move.from_uci("a8a1") in board.legal_moves False >>> board.push_san("e4") Move.from_uci('e2e4') >>> board.push_san("e5") Move.from_uci('e7e5') >>> board.push_san("Qh5") Move.from_uci('d1h5') >>> board.push_san("Nc6") Move.from_uci('b8c6') >>> board.push_san("Bc4") Move.from_uci('f1c4') >>> board.push_san("Nf6") Move.from_uci('g8f6') >>> board.push_san("Qxf7") Move.from_uci('h5f7') >>> board.is_checkmate() True >>> board Board('r1bqkb1r/pppp1Qpp/2n2n2/4p3/2B1P3/8/PPPP1PPP/RNB1K1NR b KQkq - 0 4') 3 python-chess, Release 1.6.1 4 Chapter 1. Introduction CHAPTER TWO INSTALLING Download and install the latest release: pip install chess 5 python-chess, Release 1.6.1 6 Chapter 2.
    [Show full text]