Design and Implementation of Magic Chess

Similar documents
Small and large MCTS playouts applied to Chinese Dark Chess stochastic game

Wireless Powered Chess: - A Review

A Desktop Grid Computing Service for Connect6

Google DeepMind s AlphaGo vs. world Go champion Lee Sedol

Comparison Training for Computer Chinese Chess

Computer Chess Programming as told by C.E. Shannon

Theory of Computer Games: Concluding Remarks

Ar#ficial)Intelligence!!

Games (adversarial search problems)

2. Previous works Yu and Jing [2][3] they used some logical rules are deduced to paint some cells. Then, they used the chronological backtracking algo

Adversarial Search. CMPSCI 383 September 29, 2011

Artificial Intelligence

If a pawn is still on its original square, it can move two squares or one square ahead. Pawn Movement

Artificial Intelligence

Playing Othello Using Monte Carlo

On Drawn K-In-A-Row Games

Lecture 14. Questions? Friday, February 10 CS 430 Artificial Intelligence - Lecture 14 1

Foundations of AI. 6. Adversarial Search. Search Strategies for Games, Games with Chance, State of the Art. Wolfram Burgard & Bernhard Nebel

This article appeared in a journal published by Elsevier. The attached copy is furnished to the author for internal non-commercial research and

Applications of Artificial Intelligence and Machine Learning in Othello TJHSST Computer Systems Lab

More Adversarial Search

game tree complete all possible moves

Programming an Othello AI Michael An (man4), Evan Liang (liange)

A1 Problem Statement Unit Pricing

COMP3211 Project. Artificial Intelligence for Tron game. Group 7. Chiu Ka Wa ( ) Chun Wai Wong ( ) Ku Chun Kit ( )

A Simple Pawn End Game

Adversarial Search. CS 486/686: Introduction to Artificial Intelligence

Using Neural Network and Monte-Carlo Tree Search to Play the Game TEN

CS 440 / ECE 448 Introduction to Artificial Intelligence Spring 2010 Lecture #5

SEARCHING is both a method of solving problems and

CS 4700: Foundations of Artificial Intelligence


CS440/ECE448 Lecture 9: Minimax Search. Slides by Svetlana Lazebnik 9/2016 Modified by Mark Hasegawa-Johnson 9/2017

Two-Player Perfect Information Games: A Brief Survey

Adversarial Search. CS 486/686: Introduction to Artificial Intelligence

OCTAGON 5 IN 1 GAME SET

A Quoridor-playing Agent

Games solved: Now and in the future

GICAA State Chess Tournament

Botzone: A Game Playing System for Artificial Intelligence Education

CS 229 Final Project: Using Reinforcement Learning to Play Othello

Foundations of Artificial Intelligence

A Comparative Study of Solvers in Amazons Endgames

Comparison of Monte Carlo Tree Search Methods in the Imperfect Information Card Game Cribbage

Foundations of AI. 5. Board Games. Search Strategies for Games, Games with Chance, State of the Art. Wolfram Burgard and Luc De Raedt SA-1

Movement of the pieces

Two-Player Perfect Information Games: A Brief Survey

THE NATURE OF RETROGRADE ANALYSIS FOR CHINESE CHESS 1

Foundations of Artificial Intelligence

Today. Types of Game. Games and Search 1/18/2010. COMP210: Artificial Intelligence. Lecture 10. Game playing

Chess Rules- The Ultimate Guide for Beginners

Chess Puzzle Mate in N-Moves Solver with Branch and Bound Algorithm

Rating and Generating Sudoku Puzzles Based On Constraint Satisfaction Problems

DELUXE 3 IN 1 GAME SET

YourTurnMyTurn.com: chess rules. Jan Willem Schoonhoven Copyright 2018 YourTurnMyTurn.com

Intuition Mini-Max 2

Virtual Global Search: Application to 9x9 Go

ChessBase Accounts FIRST STEPS. CH E ACCESS THE WORLD OF CHESSBASE ANYWHERE, ANYTIME - 24/7

CPS 570: Artificial Intelligence Two-player, zero-sum, perfect-information Games

Available online at ScienceDirect. Procedia Computer Science 62 (2015 ) 31 38

6. Games. COMP9414/ 9814/ 3411: Artificial Intelligence. Outline. Mechanical Turk. Origins. origins. motivation. minimax search

COMP219: COMP219: Artificial Intelligence Artificial Intelligence Dr. Annabel Latham Lecture 12: Game Playing Overview Games and Search

An Intelligent Agent for Connect-6

Game Tree Search. CSC384: Introduction to Artificial Intelligence. Generalizing Search Problem. General Games. What makes something a game?

How to Play Chinese Chess Xiangqi ( 象棋 )

Unit-III Chap-II Adversarial Search. Created by: Ashish Shah 1

UNIT 13A AI: Games & Search Strategies

A Complex Systems Introduction to Go

Adversary Search. Ref: Chapter 5

CMPUT 657: Heuristic Search

Othello/Reversi using Game Theory techniques Parth Parekh Urjit Singh Bhatia Kushal Sukthankar

We are IntechOpen, the world s leading publisher of Open Access books Built by scientists, for scientists. International authors and editors

Outline. Game Playing. Game Problems. Game Problems. Types of games Playing a perfect game. Playing an imperfect game

Computer Science and Software Engineering University of Wisconsin - Platteville. 4. Game Play. CS 3030 Lecture Notes Yan Shi UW-Platteville

Artificial Intelligence Adversarial Search

Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning

Unit. The double attack. Types of double attack. With which pieces? Notes and observations

Monday, February 2, Is assigned today. Answers due by noon on Monday, February 9, 2015.

Artificial Intelligence Search III

More on games (Ch )

CPS331 Lecture: Search in Games last revised 2/16/10

Mind Ninja The Game of Boundless Forms

After learning the Rules, What should beginners learn next?

Intelligent Non-Player Character with Deep Learning. Intelligent Non-Player Character with Deep Learning 1

Foundations of Artificial Intelligence Introduction State of the Art Summary. classification: Board Games: Overview

Analysis of Computational Agents for Connect-k Games. Michael Levin, Jeff Deitch, Gabe Emerson, and Erik Shimshock.

Five-In-Row with Local Evaluation and Beam Search

5.4 Imperfect, Real-Time Decisions

CS221 Project Final Report Gomoku Game Agent

CS 4700: Artificial Intelligence

Triple Challenge.txt

Adversarial Search. Rob Platt Northeastern University. Some images and slides are used from: AIMA CS188 UC Berkeley

arxiv: v2 [cs.ai] 15 Jul 2016

Adversarial Search. Soleymani. Artificial Intelligence: A Modern Approach, 3 rd Edition, Chapter 5

CS 331: Artificial Intelligence Adversarial Search II. Outline

The game of Paco Ŝako

Dota2 is a very popular video game currently.

CSC242: Intro to AI. Lecture 8. Tuesday, February 26, 13

Ageneralized family of -in-a-row games, named Connect

COMP219: Artificial Intelligence. Lecture 13: Game Playing

Transcription:

Design and Implementation of Magic Chess Wen-Chih Chen 1, Shi-Jim Yen 2, Jr-Chang Chen 3, and Ching-Nung Lin 2 Abstract: Chinese dark chess is a stochastic game which is modified to a single-player puzzle game. We add some rules and reduce the board size. We also develop a computer program as a non-player character (NPC) to play with the player. The modified single-player game is called Magic Chess, which is suitable for the development of smartphone APPs. Many interesting rules are added in this paper. These rules are used for enhancing funny feeling and more difficulty level. Now there is more than 5 thousand times download Magic Chess app. Keywords: App games, Chinese dark chess, stochastic games, magic chess, puzzle game. 1. Introduction Chinese dark chess is a stochastic game. This game is famous in the Chinese culture sphere. Chinese dark chess is a two-player zero-sum stochastic game [2]. The board size is 4x8 squares. The kinds and quantities of the pieces used in Chinese dark chess are the same as those used in Chinese chess [3]. Chinese dark chess is as popular as Chinese chess in worldwide. In this paper, Chinese dark chess is modified to a single-player puzzle game. We add some rules and reduce the board size. We also develop a computer program as a non-player character (NPC) to play with the player. The modified single-player game is called Magic Chess [6], which is suitable for the development of smartphone APPs. This paper discusses the design of Magic Chess. Then, describes the used algorithms in this game. Finally, we propose the methods for adjusting the difficulties of the 123 levels in the Magic Chess app. 2. Rules for Magic Chess The rules of Magic chess are mainly modified from the game of Chinese dark chess. In Chinese dark chess, each of two players, called Red and Black, owns sixteen red and black pieces respectively. The sixteen pieces include one king, two s, two ministers, two rooks, two knights, two cannons and five pawns. Each piece is in one of the two possible states that are revealed and unrevealed. When a piece is in the revealed state, the piece reveals its type and can be moved to another square. When a piece is in the unrevealed state, its type is unknown and the only allowed action on the piece is flipping that changes the state of the piece from unrevealed to revealed. All the pieces are placed facedown at the beginning of a game, meaning that they are 1 Wen-Chih Chen 1 is with Liil Corporation( email: wayne.chen0610@gmail.com) 2 Shi-Jim Yen 2 and Ching-Nung Lin 2 are with the Department of Computer Science and Information Engineering, National Dong Hwa University, Hualien 97401, Taiwan (e-mail: sjyen@mail.ndhu.edu.tw, jirong@gmail.com). 3 Jr-Chang Chen 2 is with the Department of Applied Mathematics, Chung Yuan Christian University, Taoyuan 32023, Taiwan. (e-mail: jcchen@cycu.edu.tw). unrevealed. Two kinds of actions are allowed in the rules of Chinese dark chess: flipping actions and moving actions. Flipping actions are for face-down pieces, whose states are unrevealed. The detail rule of Chinese dark chess is described in [1][2]. The kinds of pieces used in Magic Chess are the same as those used in Chinese dark chess. One player, called Red, owns red pieces, and the other, called Black, owns black pieces. The sixteen pieces for each player include one king (K/k), s (G/g), ministers (M/m), rooks (R/r), knights (N/n), cannons (C/c) and pawns (P/p), where the upper-case letters and the lower-case ones in the parentheses are for Red and Black, respectively. Table 1 shows the pieces. Magic Chess uses small board sizes of 4x4, 5x5, and 6x6 to let players enjoy an interesting game in short time. Figure 1 shows the interfaces of 4x4 and 5x5 Magic Chess. Figure 2 is an example of 6x6 Magic Chess. Table 2 shows the number of each kind of piece for different board sizes. Some levels use different combination of pieces to improve the flexibility. The player enters the next level only if he wins a game by means of either capturing all stones of NPC or letting NPC have no moves to play. Table 1. The pieces. Type of Pieces Red type Chinese English Black type Chinese English Rank king minister rook knight cannon pawn K G M R N C P 1(highest) k g m r n c p 2 3 4 5 6 7(lowest) - 56 -

jumping over a carriage and then stay on the square with the opponent s piece to be captured. A carriage can be any unrevealed or revealed piece, but subject to three constraints: 1. The cannon, the carriage and the captured piece must be at the same row or the same column. 2. There are no pieces between the cannon and the carriage. 3. There are no pieces between the carriage and the piece to be captured. Figure 1. 4x4 (left) and 5x5(right) Magic Chess. Figure 2. 6x6 Magic Chess. Table 2. Piece sets for different board sizes. Type of Pieces of 4x4 of 5x5 of 6x6 king rook knight minister cannon pawn Wood 4 1 1 1 1 1 1 2 0 1 1 2 2 2 2 2 1 1 2 2 2 2 2 5 4 Players can only move pieces of their own colors. For pieces other than cannons, can be moved to an adjacent square, which is one square up, down, left or right, if is empty, or can capture the opponent s piece at when has equal or higher rank than. The ranks of piece types are shown in Table 1. One exception is that pawns can capture the opponent s king, but not vice versa. A moving action is a deterministic action. For cannons, the legal moving actions are different from those for other pieces. Cannons can be moved to an adjacent empty square in the same way as the actions applied on the other pieces, but cannot capture an adjacent opponent s piece. The only way for a cannon to capture an opponent s piece is to move the cannon 4 The Wood is as in the center of the 5x5 board in Figure 1. Wood is a special piece. It does not belong to each side and cannot be captured by each side. The color each player owns is decided by the piece flipped by the first player at the beginning. That is, if the color of the first flipped piece is red, the first player is Red and the second player is Black, and vice versa. The additional rules for Magic Chess are named magic rules are described as follows. 1. Wood magic: NPC could use this magic to change a player s piece to a Wood. Once a piece becomes a Wood, it will never restore. 2. Ice magic: NPC could use this magic to make a player s piece to an Ice with a number n (denoted by Ice-n). An Ice cannot be moved within n plies. 3. Gold magic: NPC could use this magic to make its own piece stronger. A piece protected by Gold magic can be captured only if the opponent plays capture moves twice on the piece. 4. Hidden magic: NPC could use this magic to let its own piece hidden after the piece is moved. 3. Algorithm for the NPC of Magic Chess Monte-Carlo Tree Search is useful on stochastic games. [2] However, for NPC of Magic Chess developed as a smartphone APP, its search depth is limited by smartphone software and hardware. It is important to use a variety of methods to speed up and improve the capability of Magic Chess APP. The NPC uses alphabeta search [5] and a transposition table to achieve the high performance objective. It also avoids a huge amount of repeated boards during the search to save time, and thus obtains satisfying results in most cases. The evaluation function in alpha-beta search is calculated based on the following factors. 1. The total score of all alive pieces. 2. Strong pieces reachable distance from the player s weak pieces. In the other words, a minus score could be calculated in the case of weak pieces reachable distance to the player s strong pieces. 3. Combination with the revealing mechanism. We calculate the probability and expected value of each unrevealed piece. 4. A less number of winning moves is preferred. 4. Calculate of the Degree of a Level s Difficulty It is important to control the degree of difficulty in a puzzle game. If a puzzle game is too difficult, the player may lose his patient; and if it is too easy, the player may feel boring. In this paper, we use the win ratio to - 57 -

represent the degree of difficulty. The difficulty of most levels is between 0.2 and 0.5, and that of some key levels is between 0.1 and 0.2. This section discusses how to calculate the degree of a level s difficulty. For example, the win ratios of level 100 and level 97 are 0.25 and 0.3 respectively. For the setting of each level, we simulate 1000 times and use the result to judge the difficulty of the level. The baseline is that the search depth set to 4. In this section, all the win ratios are respected to the simulated human player. Table 3 shows the win ratio for different search depth for a normal 4x4 Magic Chess. Table 4 shows the win ratio for changing a specific piece to a Wood. Table 3. Win ratio for different search depths. Search Depth 2 4 6 Baseline = 4 0.68 0.5 0.35 All NPC s pieces are protected by Gold magic, and remove one NPC s Minister. The board size is also an important factor of the difficulty. We use programs to estimate the average playing time of a game. Both sides set to complete a move in 3 seconds. Table 8 shows the average playing time of different board sizes for 100 games, respectively. Table 9 shows the difficulties of different board sizes. 0.2 Table 8. The average playing times of different board sizes. Type of Pieces The average playing time(seconds) of 4x4 55 of 5x5 75 of 6x6 125 Table 4. Change a specific piece to a Wood. Specific Piece Win Ratio rook knight cannon pawn 0.3 0.36 0.4 0.43 0.35 0.46 As mentioned in Section 2, NPC could use various magic on the player. The effects of Ice magic and Gold magic are shown in Table 5 and Table 6 respectively. Note that Ice-n means a piece cannot be moved within n plies for n = 1, 2, 3. Table 7 shows the effect of the combination of magic. Table 5. The effect of Ice magic for the player. Ice magic Ice-1 Ice-2 Ice-3 Baseline = 4 0.45 0.3 0.2 Table 6. Protect a specific NPC piece with Gold magic. Table 9. The Win Ratios of different board sizes. Type of Pieces The Win Ratio of 4x4 0.37 of 5x5 0.35 of 6x6 0.30 Minister Specific Piece Win Ratio minister rook knight cannon pawn 0.42 0.45 0.46 0.47 0.45 0.49 Table 7. The effect of the combination of magic. Initial Game Board Status Win Ratio Figure 3. An example of all NPC s pieces are protected by Gold magic. The winning rate is 0.1. Change the player s one Pawn and one Cannon to a Wood and Ice-2, respectively Change the player s one Guard and one Pawn to a Wood, respectively. Change the player s one Guard, one Minister and one Cannon to a Wood, respectively. Change the player s one Cannon and one Minister to a Wood and Ice-3, respectively. All NPC s pieces are protected by Gold magic, such as the example in Figure 3 0.3 0.19 0.15 0.16 0.1 As mansions in section 2, the rule of cannon is different to other pieces. In fact, the cannon is a special piece. There is no similar kind of piece in western chess and Shogi. In Magic Chess, many interesting initial board are made by adding cannons. Figure 4-7 are examples. - 58 -

Figure 4. An example with many cannons. The winning rate is 0.15. Figure 5. A many-cannons example. The winning rate is 0.65. Figure 6. A many-cannons example. The winning rate is almost 0. Figure 7. A many-cannons example. The winning rate is 0.05. 5. Conclusion In this paper, we propose the game of Magic Chess as well as its rules and various magic. We also have created 690 levels of difficulty according to the simulation results. Magic Chess did a success in Taiwan APP market. In the future, the player can also use the magic. For example, the player could use Wood magic to make NPC s piece become a Wood. It will bring player more enjoyment. Furthermore, we utilize Facebook to make our APP more popular, that is, a player will get more bonuses by automatically posting messages to Facebook. In order to make more non-chinese people could play magic chess, we plan to revise Chinese dark chess symbol to cute pets which have food chain that could remove pet stones. ACKNOWLEDGMENT The authors would like to thank anonymous referees for their valuable comments in improving the overall quality of this paper, and Ministry of Science and Technology of Taiwan for financial support of this research under the contract numbers 102-2221-E-259-011-MY2 and 101-2628-E-259-003-MY2. References [1] Bo-Nian Chen, Bing-Jie Shen, and Tsan-sheng Hsu, "Chinese Dark Chess," ICGA Journal. vol. 33, No.2, pp. 93 106, 2010. [2] Edward J. Powley, Peter I. Cowling, Daniel Whitehouse, Information capture and reuse strategies in Monte Carlo Tree Search with applications to games of hidden information, Artificial Intelligence, Vol. 217, December, 2014, pages 92-116. [3] Shi-Jim Yen, Cheng-Wei Chou, Jr-Chang Chen, I-Chen Wu, and Kuo-Yuan Kao, "Design and Implementation of Chinese Dark Chess Programs," IEEE Transactions on Computational Intelligence and AI in Games (IEEE TCIAIG), accepted. DOI 10.1109/TCIAIG.2014.2329034, 2014. [4] Shi-Jim Yen, Jr-Chang Chen, Tai-Ning Yang, Shun-Chin Hsu, "Computer Chinese Chess," ICGA Journal, vol. 27, no.1, pp. 3 18, 2004. [5] Shi-Jim Yen, Shih-Yuan Chiu, and I-Chen Wu, "MODARK Wins Chinese Dark Chess Tournament," ICGA Journal, vol. 33, no. 4, pp. 230 231. - 59 -

[6] Shi-Jim Yen, Tsan-Cheng Su and I-Chen Wu, "The TCGA 2011 Computer-Games Tournament," ICGA Journal, vol. 34, no. 2, 2011, pp. 108 110. [7] Russell, S. and Norvig, P., Artificial Intelligence: A Modern Approach 2/e, Prentice Hall, 2003. [8] Liil Corporation, Magic Chess APP( 魔法暗棋 ), https://play.google.com/store/apps/details?id=com.liil.min ichess&hl=zh-tw - 60 -