Computer Chess By Thomas Wiest and Rusty Howell. Step 1: Source Code Control We prefer Can.

Slides:



Advertisements
Similar presentations
Adversarial Search We have experience in search where we assume that we are the only intelligent being and we have explicit control over the “world”. Lets.
Advertisements

Computers playing games. One-player games Puzzle: Place 8 queens on a chess board so that no two queens attack each other (i.e. on the same row, same.
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2008.
Table of Contents Why Play Chess? Setting Up the Board Get to Know the Pieces Check and Checkmate What the Chess Pieces Are Worth Opening Goals Endgame.
L.O. Today you will learn how to play chess. How to Play Chess.
Artificial Intelligence in Game Design Heuristics and Other Ideas in Board Games.
Chess AI’s, How do they work? Math Club 10/03/2011.
Minimax and Alpha-Beta Reduction Borrows from Spring 2006 CS 440 Lecture Slides.
Representing a Game Board In a game, we represent the action taking place using an array – In a very simple game, we use individual variables to represent.
Mock test review Revision of Activity Diagrams for Loops,
Logging and Replay of Go Game Steven Davis Elizabeth Fehrman Seth Groder.
Shallow Blue Project 2 Due date: April 5 th. Introduction Second in series of three projects This project focuses on getting AI opponent Subsequent project.
Creating Shareable Models By: Eric Hutton CSDMS - Community Surface Dynamics Modeling System (pronounced ˈ s ɪ stəms) Image by Flickr user Let There Be.
MAE 552 – Heuristic Optimization Lecture 28 April 5, 2002 Topic:Chess Programs Utilizing Tree Searches.
Online Chess Project 3 Due date: April 17 th. Introduction Third in series of three projects This project focuses on adding online support –2 players.
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2006.
CIS 310: Visual Programming, Spring 2006 Western State College 310: Visual Programming Othello.
Game Tree Search based on Russ Greiner and Jean-Claude Latombe’s notes.
THE RENJU GAME BY ABHISHEK JAIN, PRANSHU GUPTA & RHYTHM DAS PCLUB SUMMER PROJECT PRESENTATION JUNE, L7 IIT KANPUR MENTOR – SANIL JAIN.
VOCABULARY  Deck or pack  Suit  Hearts  Clubs  Diamonds  Spades  Dealer  Shuffle  Pick up  Rank  Draw  Set  Joker  Jack 
How to play Chess.
1 Adversary Search Ref: Chapter 5. 2 Games & A.I. Easy to measure success Easy to represent states Small number of operators Comparison against humans.
CSC 412: AI Adversarial Search
Game Trees: MiniMax strategy, Tree Evaluation, Pruning, Utility evaluation Adapted from slides of Yoonsuck Choe.
Chess Merit Badge Chess Basics: Set Up the Board & Basic Rules by Joseph L. Bell © 2011.
A Beginners Guide. The Pieces Chess consists of Sixteen pieces eight Pawns two Rooks two Knights two bishops one Queen and one king this guide will show.
General Presentation Suggestions - Each bullet should be a thought. Full sentences should be avoided and multiple sentence bullets should NEVER be done.
Game Playing Chapter 5. Game playing §Search applied to a problem against an adversary l some actions are not under the control of the problem-solver.
Game Playing. Introduction Why is game playing so interesting from an AI point of view? –Game Playing is harder then common searching The search space.
#2. UIL Chess Puzzle Practice Material This year’s UIL Chess Puzzle Test includes “solve the mate” positions similar to last year’s, but it also tests.
Game Playing.
Artificial Intelligence in Game Design Lecture 22: Heuristics and Other Ideas in Board Games.
11 Finding Winners Using Arrays Session 8.2. Session Overview  Find out how the C# language makes it easy to create an array that contains multiple values.
Prepared by : Walaa Maqdasawi Razan Jararah Supervised by: Dr. Aladdin Masri.
Game Playing Chapter 5. Game playing §Search applied to a problem against an adversary l some actions are not under the control of the problem-solver.
Class Usability Experience User slides are in BLUE.
How to Play Chess By: John. Dedication I dedicate this project to my family because we all love chess.
e~TASK Semester 1By Thomas Burke 1) Chess is like life because there are black and white squares on they chess board so its saying that we have good.
Games. Adversaries Consider the process of reasoning when an adversary is trying to defeat our efforts In game playing situations one searches down the.
Senior Project Poster Day 2007, CIS Dept. University of Pennsylvania Reversi Meng Tran Faculty Advisor: Dr. Barry Silverman Strategies: l Corners t Corners.
More on Logic Today we look at the for loop and then put all of this together to look at some more complex forms of logic that a program will need The.
CSCI 4310 Lecture 6: Adversarial Tree Search. Book Winston Chapter 6.
GAME PLAYING 1. There were two reasons that games appeared to be a good domain in which to explore machine intelligence: 1.They provide a structured task.
How to Play Chess. Name of Each Piece The relative values of the chess pieces 9 points 5 points 3+ points 3 points 1 point.
Summary of the Moves of Chess
Lesson 1 History of Chess Why We Teach Chess Goal of Chess.
Demonstration and Application Revision Version 2.0: The Return of the Revolutionaries of the Mountain of Slyzikarieth’s Death (Part XIV) Josh Waters Ty.
Today’s Topics Playing Deterministic (no Dice, etc) Games –Mini-max –  -  pruning –ML and games? 1997: Computer Chess Player (IBM’s Deep Blue) Beat Human.
How to play chess? By Mervyn George. The Rules of the Game White always move first White always move first You should always play touch a piece move a.
Chess Strategies Component Skills Strategies Prototype Josh Waters, Ty Fenn, Tianyu Chen.
Discussion 2: Intro to Project 1: Chess Submit Project 1 under # 11!
A Levoy PowerPoint Presentation
CompSci Backtracking, Search, Heuristics l Many problems require an approach similar to solving a maze ä Certain mazes can be solved using the.
CPS Backtracking, Search, Heuristics l Many problems require an approach similar to solving a maze ä Certain mazes can be solved using the “right-hand”
More on Logic Today we look at the for loop and then put all of this together to look at some more complex forms of logic that a program will need The.
Adversarial Search. Regular Tic Tac Toe Play a few games. –What is the expected outcome –What kinds of moves “guarantee” that?
An AI Game Project. Background Fivel is a unique hybrid of a NxM game and a sliding puzzle. The goals in making this project were: Create an original.
Artificial Intelligence in Game Design Board Games and the MinMax Algorithm.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech May 2009.
CPS 100, Spring Search, Backtracking,Heuristics l How do you find a needle in a haystack?  How does a computer play chess?  Why would you write.
Understanding AI of 2 Player Games. Motivation Not much experience in AI (first AI project) and no specific interests/passion that I wanted to explore.
Game playing Types of games Deterministic vs. chance
Backtracking, Search, Heuristics
CS Fall 2016 (Shavlik©), Lecture 11, Week 6
How To Play Chess (And other Information)
CHESS.
Greenways Gladiators Chess Club
Backtracking, Search, Heuristics
CS51A David Kauchak Spring 2019
Backtracking, Search, Heuristics
Presentation transcript:

Computer Chess By Thomas Wiest and Rusty Howell

Step 1: Source Code Control We prefer Can use pay/hosted sites: – --- $20/monthhttp://wush.net/subversion.php – --- $10/monthhttps://secure.cvsdude.org/ Can host an SVN server yourself Can use free/hosted sites: – Reasons: –Collaboration –Easily back out changes –Backup

Step 2: Setup Interface and Debug Tab Basically just get it compiling, telling you your color, and you reacting properly. Make sure your DLL is getting copied into the framework’s output directory. Create the Debug Tab custom user control, and be able to add controls easily.

Step 3: Data Structures Decide on data structures to represent the board and pieces. –It is suggested that you use an enum to represent MyChessPiece (MyChessPiece.WhitePawn, MyChessPiece.BlankTile, MyChessPiece.BlackPawn, etc) –Make sure that MyChessPiece.BlankTile is in the middle so that you can say: if (curTile < MyChessPiece.BlankTile) then white else if (curTile > MyChessPiece.BlankTile) then black –It is suggested that you use an 8x8 array of MyChessPiece to represent the chess board. –It is also suggested that you have an array of piece values, for example if you were black: pieceValue[MyChessPiece.WhitePawn] = 1; pieceValue[MyChessPiece.BlackPawn] = -1;

Step 4: Move Generator Create your Move Generator –Pass in the board and a board location (row, col). Have it return all moves for that piece. To get all moves for a board, cycle through all rows and columns, passing each tile into the Move Generator and storing the results in a huge Array (or ArrayList) ONLY return valid moves Create InCheck function Make sure to check for special cases: –In Check (don’t move into and not out of) –Pawn (diagonal killing) –Queening (straight on, and diagonal killing queening on both ends of the board)

Step 5: Move Validator Move Validator just takes in a board and a move and returns a bool of “pass or fail” Move Validator calls Move Generator and if Move Generator returns the move in it’s list of valid moves, then the move is good A move is invalid if it goes over time. Make sure to check. Add in a special case to allow a human player to pick up a piece and put it back in the same place (helps in debugging)

MILESTONE-1: Random AI Create an AI that takes all possible moves, and randomly picks one (and moves). To meet this milestone: –AI must make valid moves –AI must catch the user making invalid moves –AI must handle special cases (in check, diagonal killing, etc) –AI does not use Mini-Max at this point

Step 6: Debug Tab Add code in your tab to see: – what the AI thinks the board looks like –what it thinks the score is –who it thinks is winning –any other info that is relevant

Step 7: Benchmark Info “One test is worth 1,000 expert opinions” – Russ Miller Make it so that you collect benchmarking info like: –Depth (Start, Completed) –Moves Generated –Moves Visited –% Waste –How many Moves were visited per level (not useful until Mini- Max is plugged in, but nice to have) –Average of above

Step 8: Test Play MANY games and make sure that the AI is performing appropriately Make sure that Moves are generated correctly Make sure that the AI flags invalid game when you try to perform illegal moves This is a VERY important step! Before starting Mini-Max, you want to make sure that your core code is VERY solid (debugging Mini-Max is hard enough)

Step 9: Evaluate Board Create the Evaluate Board function Can be as simple as going through the board tile by tile and adding up piece values: total += pieceValue[board[x,y]]; Simply returns board score by adding up the values of all of the pieces Can also have certain “extensions” (see Advanced slide at end of presentation) Make sure this works properly, otherwise your AI will help the other AI win. This is the “smarts” of the AI.

MILESTONE-2: Greedy-1 AI You should at least be here by the first class tournament Create an AI that takes all possible moves, and picks the most valuable one (and moves) To meet this milestone: –AI must select the most valuable move in it’s list. In the case of multiple moves being the same value, choose the first one. –AI must make valid moves –AI must catch the user making invalid moves –AI must handle special cases (in check, diagonal killing, etc) –AI does not use Mini-Max at this point –Greedy-1 AI should beat Random AI every single time.

Step 10: Add Mini-Max Leave about a week to add and test Mini-Max (by far hardest part of the chess program to get right) Test Mini-Max with depth 2 and 3 If your program does Mini-Max depth 3 correctly, you can be pretty confident that Mini-Max depth n will work also Choose how you want to solve the in order problem –Order Bonus –Create all children and Mini-Max from highest value to lowest value

MILESTONE-3: Mini-Max AI Create an AI that selects the best move based on Mini-Max with A/B pruning To meet this milestone: –AI must select the best move based on Min-Max –AI must make valid moves –AI must catch the user making invalid moves –AI must handle special cases (in check, diagonal killing, etc) –Mini-Max AI should beat Greedy-1 AI and Random AI every single time

Final Testing Play MANY games and make sure that the AI is performing appropriately Make sure that Moves are selected correctly Make sure that the AI flags invalid game when you try to perform illegal moves This is a VERY important step!

Things to Know Mini-Max is VERY time consuming to debug. Stay with the Psuedo code as much as possible. Mini-Max is executed HUNDREDS of thousands of times, so even one extra line of code can adversely impact performance (‘#if debug’ is your friend) Avoid creating objects in Mini-Max (serious performance hit) Avoid static functions because if you play your AI against itself, it will share static functions, and static variables. Understand the Horizon Effect

Advanced Evaluate Board Make sure that any additional stuff that you add is worth less than a pawn, otherwise you’ll get pawn sacrifices. Any Advancement to Evaluate Board not only makes your offense better, but also your defense, since you’ll automatically avoid it (because of Mini- Max) You can add different stuff to evaluate board to make your AI “smarter” –Forking –Trapping –Knights in the center –King in the corner –Protected Pieces –Etc Opening Books help you initially to setup good position (there are a bunch of them out there, but you have to pare them down to not have ‘en pesaint’ moves, and also castling moves.

Best Practices Do not move onto the next step until you feel comfortable with the amount of testing that has been done on the current step! (Build on a solid foundation) Use #define’s at each milestone so that you can easily build Random AI and Greedy-1 AI (off of your new code) You can also create Greedy-2 (depth 2), and Greedy-3 by just executing Mini-Max with depth-3 and picking the highest scoring move. Test your AI often as both White and Black (pit AI against AI to test this) NEVER use floats, always use Ints Buy a real chess board to help debug Mini-Max ($7 at k-mart) Read a few of the Chess HowTo’s out on the internet

What will help you to Win (listed in order of priority) Testing to make sure that your AI doesn’t make invalid moves, and doesn’t allow invalid moves Having a really “smart” evaluate board Getting as far down in Mini-Max as possible

Final Thoughts It’s hard, but it’s possible to do (we did ours during summer term and had less time) Well worth the effort Amazing to see your program get more intelligent with time It’s pretty amazing when your program outsmarts you

Questions