Using Bitboards for Move Generation in Shogi

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

Apostles Chess Club Lesson #4. Algebraic Chess Notation System The board is set up from white’s position. Black must look at the board from the white.
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.
2002/11/15Game Programming Workshop1 A Neural Network for Evaluating King Danger in Shogi Reijer Grimbergen Department of Information Science Saga University.
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.
CHESS FOR KIDS Lesson 1.
L.O. Today you will learn how to play chess. How to Play Chess.
Application of Artificial intelligence to Chess Playing Capstone Design Project 2004 Jason Cook Bitboards  Bitboards are 64 bit unsigned integers, with.
Welcome to the basics of chess. This is a graphically designed program that will help you learn how to play chess. By Amir and Mike, 9B.
October 28th 2001GPW20011 Using Castle and Assault Maps for Guiding Opening and Middle Game Play in Shogi Reijer Grimbergen (Saga University) Jeff Rollason.
Plausible Move Generation Using Move Merit Analysis in Shogi Reijer Grimbergen (Electrotechnical Laboratory) Hitoshi Matsubara (Future University Hakodate)
Intelligence for Games and Puzzles1 Some Chess-specific Techniques Chess is played on an 8x8.
How to play Chess.
Chess Merit Badge Chess Basics: Set Up the Board & Basic Rules by Joseph L. Bell © 2011.
Aayush Garg Pecha-Kucha Design Games 10. Games I like Strategy games Mathematical games Paper and Pencil games Street games.
Panther Chess Club Sponsors: –Mr. Sergio Treviño (English, Room 408) –Mr. Felix Esquivel (Criminal Justice, Room 50) Meetings every Monday and Wednesday.
Apostles Chess Club Session Three. Chess Piece Symbols The symbols shown above are the ones most used when showing chess pieces in print or on the internet.
Database Chess A server-based web gaming application by Jordan Arnold.
Prepared by : Walaa Maqdasawi Razan Jararah Supervised by: Dr. Aladdin Masri.
2004/11/13GPW20041 What Shogi Programs Still Cannot Do - A New Test Set for Shogi - Reijer Grimbergen and Taro Muraoka Department of Informatics Yamagata.
2009/11/14GPW20091 Analysis of the Behavior of People Solving Sudoku Puzzles Reijer Grimbergen School of Computer Science, Tokyo University of Technology.
Planning to Guide Opening and Middle Game Play in Shogi Reijer Grimbergen (Electrotechnical Laboratory) Hitoshi Matsubara (Future University Hakodate)
Chess and AI Group Members Abhishek Sugandhi Sanjeet Khaitan Gautam Solanki
PYIWIT'021 Threat Analysis to Reduce the Effects of the Horizon Problem in Shogi Reijer Grimbergen Department of Information Science Saga University.
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.
Chess By Kezia Farley.
Summary of the Moves of Chess
Lesson 1 History of Chess Why We Teach Chess Goal of Chess.
Chess By Kyle Fischer. What is chess? Chess is a game that you try to get the other person’s king in a checkmate.
A game based off of the esteemed classic By: Tadziu Kosiara.
Each piece is represented by a symbol. The pieces all stand in the same position at the start of the game the pieces are the Rook, the Knight, the Bishop,
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.
The Basics Of Chess Student Name: Jovannie Charles Date: 3/25/11.
Every chess master was once a beginner. Irving Chernev
2006/6/30SIGGI-161 The Society of Shogi - A Research Agenda - Reijer Grimbergen Department of Informatics Yamagata University.
CHESS Basics for Beginners. BOARD SET-UP The letters go across the board in front of you. “White on right!” Each player has a white square in their right.
A Levoy PowerPoint Presentation
Computers and Games Board Maps and Hill-Climbing for Opening and Middle Game Play in Shogi Reijer Grimbergen (Saga University) Jeff Rollason (Oxford.
2008/11/08GPW20081 A Reproduction Experiment Concerning the Relation Between Perceptual Features and Memory in Shogi Reijer Grimbergen Department of Informatics.
Plausible Move Generation Using Move Merit Analysis with Cut-off Thresholds in Shogi Reijer Grimbergen (Electrotechnical Laboratory)
Steps and Vocabulary Martha Rice. You can use the same problem solving methods to solve just about any problem, from word problems to logic problems to.
CHESS “The Ultimate GAME of Challenge and Strategy”
Some counting questions with the Rules of Chess. Chessboard and Chess pieces The game of chess is played on an 8-by-8 grid of alternately colored squares.
Bitwise Operations C includes operators that permit working with the bit-level representation of a value. You can: - shift the bits of a value to the left.
D1 Miwa Makoto Chikayama & Taura Lab
Designing: A Game of Chance
#1 Chess Engine of Spring 2017 at S&T
Ab & Team Presents CHESS “It’s not just a game”.
Stuart Russell and Jason Wolfe UC Berkeley
Ramblewood Middle Chess Club
Pengantar Kecerdasan Buatan
Optimizing Minmax Alpha-Beta Pruning Real Time Decisions
CHESS PIECES.
How To Play Chess (And other Information)
CHESS.
How to play chess ? By Peter Mann A Beginners Guide.
Week 9 - Monday CS 121.
Chess Basics: Set Up the Board & Basic Rules
Heuristic AI for XiangQi
Bitwise Operations C includes operators that permit working with the bit-level representation of a value. You can: - shift the bits of a value to the left.
On the Relation Between Perception, Memory and Cognition in Games
Rules to play chess. Chess is a played with 16 pieces: 8 pawns, 2 towers, 2 knights, 2 bishops, 1 queen and 1 king. Movements: Pawns: They only can move.
Strategic Thinking There are two concepts that all chess players must understand from the start; strategy and tactics. Beginners often confuse the two.
Water Quality of Watershed
Working with the Compute Block
Scalable light field coding using weighted binary images
CS51A David Kauchak Spring 2019
Minimax Pathology and Real-Number Minimax Model
Backtracking, Search, Heuristics
Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning
Presentation transcript:

Using Bitboards for Move Generation in Shogi Reijer Grimbergen Department of Informatics Yamagata University 2006/11/11 GPW2006

Outline Why this presentation? Basic bitboards Attack bitboards Other bitboards Experimental results Conclusions and future work 2006/11/11 GPW2006

Why this presentation? Bitboards are not a new idea Have been used in chess for a long time Bitboards are not new in shogi Yamashita has explained how to use bitboards in shogi Bonanza uses bitboards Why then this presentation? Yamashita’s explanation is buried in his BBS There are some details that can be optimized I don’t agree with Yamashita’s conclusion No concise explanation about bitboards 2006/11/11 GPW2006

Basic bitboards What are bitboards? Bitboards are a binary representation of knowledge for all squares on the board Presence of knowledge is represented by setting the bit for the square to 1 Absence of knowledge is represented by setting the bit for the square to 0 Chess programs use bitboards for expressing many different types of knowledge 2006/11/11 GPW2006

Basic bitboards Bitboards in chess Yamashita’s representation One bitboard can be represented with a 64 bit integer Yamashita’s representation Represent a bitboard with three integers Hoki’s optimization Represent a bitboard with an array of three integers typedef struct { unsigned int bb[3]; } BITBOARD; 2006/11/11 GPW2006

9 8 7 6 5 4 3 2 1 a b c d e f g h i bb[0] bb[1] bb[2] 26 25 24 23 22 21 20 19 18 a 17 16 15 14 13 12 11 10 b c d e f g h i bb[0] bb[1] bb[2] 2006/11/11 GPW2006

Basic bitboards Logical operations on bitboards Similar operations for OR, XOR and NOT Other basic operations on bitboards ClearBB: setting all bits to 0 SetBB: setting all bits to 1 CopyBB: copying a bitboard void AndBB(BITBOARD *to, *from1, *from2) { to→bb[0] = from1→bb[0] & from2→bb[0]; to→bb[1] = from1→bb[1] & from2→bb[1]; to→bb[2] = from1→bb[2] & from2→bb[2]; } 2006/11/11 GPW2006

Basic bitboards 9 8 7 6 5 4 3 2 1 a b c d e f g h i bb[0] bb[1] bb[2] b c d e f g h i bb[0] bb[1] bb[2] 2006/11/11 GPW2006

Basic bitboards Bitboards for position information Occupied: bitboard for the occupied squares SentePieces: bitboard for the black pieces GotePieces: bitboard for the white pieces Bitboards for each type of piece for black and white SenteGold: has 1s for the squares with black golds The bitboards with position information must be updated at every move 2006/11/11 GPW2006

Attack bitboards Non-sliding pieces 81 bitboards for each piece Example: bitboard for black gold on 5e 9 8 7 6 5 4 3 2 1 a b c d e f g h i 2006/11/11 GPW2006

Attack bitboards 飛 金 銀 玉 香 桂 Horizontal attacks Example g h i Pre-calculate bitboards for all possible blocking possibilities Example Block pattern of the rook on 7h (square 66): 001010110 = 86 bb[2] = 000000000110110000000000000 = 221184 RankAttacks[66][86].bb[2] := 221184 g 飛 金 銀 玉 h 香 桂 i 2006/11/11 GPW2006

Attack bitboards 飛 金 銀 玉 香 桂 歩 Problem g Optimization (Hyatt) h i BITBOARD RankAttacks[81][512] is a big piece of memory (497Kb) Optimization (Hyatt) Edge squares do not change the piece attack BITBOARD RankAttacks[81][128] (124Kb) g 飛 金 銀 玉 h 香 桂 i 歩 2006/11/11 GPW2006

Attack bitboards Vertical attacks Solution (Hyatt) For horizontal attacks the bits are in consecutive positions, so masking and shifting is enough For vertical attacks the bits are 9 positions apart Solution (Hyatt) Rotate the board 90 degrees Needs a new bitboard Occupied_rot90 that has to be updated at every move Can be used for both rooks and lances in shogi 2006/11/11 GPW2006

9 8 7 6 5 4 3 2 1 a 10 11 12 13 14 15 16 17 b 18 19 20 21 22 23 24 25 26 c 27 28 29 30 31 32 33 34 35 d 36 37 38 39 40 41 42 43 44 e 45 46 47 48 49 50 51 52 53 f 54 55 56 57 58 59 60 61 62 g 63 64 65 66 67 68 69 70 71 h 72 73 74 75 76 77 78 79 80 i 9 8 7 6 5 4 3 2 1 18 27 36 45 54 63 72 a 10 19 28 37 46 55 64 73 b 11 20 29 38 47 56 65 74 c 12 21 30 39 48 57 66 75 d 13 22 31 40 49 58 67 76 e 14 23 32 41 50 59 68 77 f 15 24 33 42 51 60 69 78 g 16 25 34 43 52 61 70 79 h 17 26 35 44 53 62 71 80 i 2006/11/11 GPW2006

9 8 7 6 5 4 3 2 1 a b c d e f g h i 9 8 7 6 5 4 3 2 1 a b c d e f g h i 2006/11/11 GPW2006

Attack bitboards Diagonal attacks Solution (Hyatt) For bishops the bits along a diagonal are not adjacent Solution (Hyatt) Use rotations of 45 degrees clockwise and 45 degrees anti-clockwise Needs new bitboards Occupied_r45 and Occupied_l45 which must be updated at every move 2006/11/11 GPW2006

9 1 18 10 2 27 19 11 3 36 28 20 12 4 45 37 29 21 13 5 54 46 38 30 22 14 6 63 55 47 39 31 23 15 7 72 64 56 48 40 32 24 16 8 73 65 57 49 41 33 25 17 74 66 58 50 42 34 26 75 67 59 51 43 35 76 68 60 52 44 77 69 61 53 78 70 62 79 71 80 8 7 17 6 16 26 5 15 25 35 4 14 24 34 44 3 13 23 33 43 53 2 12 22 32 42 52 62 1 11 21 31 41 51 61 71 0 10 20 30 40 50 60 70 80 9 19 29 39 49 59 69 79 18 28 38 48 58 68 78 27 37 47 57 67 77 36 46 56 66 76 45 55 65 75 54 64 74 63 73 72 2006/11/11 GPW2006

9 1 18 10 2 27 19 11 3 36 28 20 12 4 45 37 29 21 13 5 54 46 38 30 22 14 6 63 55 47 39 31 23 15 7 72 64 56 48 40 32 24 16 8 73 65 57 49 41 33 25 17 74 66 58 50 42 34 26 75 67 59 51 43 35 76 68 60 52 44 77 69 61 53 78 70 62 79 71 80 8 7 17 6 16 26 5 15 25 35 4 14 24 34 44 3 13 23 33 43 53 2 12 22 32 42 52 62 1 11 21 31 41 51 61 71 10 20 30 40 50 60 70 80 9 19 29 39 49 59 69 79 18 28 38 48 58 68 78 27 37 47 57 67 77 36 46 56 66 76 45 55 65 75 54 64 74 63 73 72 2006/11/11 GPW2006

9 1 18 10 2 27 19 11 3 36 28 20 12 4 45 37 29 21 13 5 54 46 38 30 22 14 6 63 55 47 39 31 23 15 7 72 64 56 48 40 32 24 16 8 73 65 57 49 41 33 25 17 74 66 58 50 42 34 26 75 67 59 51 43 35 76 68 60 52 44 77 69 61 53 78 70 62 79 71 80 8 7 17 6 16 26 5 15 25 35 4 14 24 34 44 3 13 23 33 43 53 2 12 22 32 42 52 62 1 11 21 31 41 51 61 71 10 20 30 40 50 60 70 80 9 19 29 39 49 59 69 79 18 28 38 48 58 68 78 27 37 47 57 67 77 36 46 56 66 76 45 55 65 75 54 64 74 63 73 72 2006/11/11 GPW2006

Other bitboards Piece promotions Required promotion check Use bitboards that have 1s for the squares inside the black or white promotion zone Required promotion check Use bitboards to decide if a knight, lance or pawn must promote 2006/11/11 GPW2006

9 8 7 6 5 4 3 2 1 a b c d e f g h i bb[0] bb[1] bb[2] 26 25 24 23 22 21 20 19 18 a 17 16 15 14 13 12 11 10 b c d e f g h i bb[0] bb[1] bb[2] 2006/11/11 GPW2006

Using bitboards made move generation 48.8% faster Experimental results Comparing bitboards with attack tables Yamashita showed a 20% speed increase for a tsume shogi solver A different test Minimax search with move generation using bitboards and move generation using attack tables Test conditions Minimax search to depth 4 for 100 positions from two professional games Evaluation function: only material Version Time Attack tables 24810s Bitboards 12709s Using bitboards made move generation 48.8% faster 2006/11/11 GPW2006

Conclusions and Future work Bitboards made move generation almost twice as fast Bitboards make a program more transparent Bitboards might be a good alternative to attack tables in shogi as well Future work Will bitboards slow down the evaluation function? The Static Exchange Evaluator and pin analysis can be implemented efficiently with bitboards Faster than using attack tables? 2006/11/11 GPW2006