COMP 4801 Final Year Project Interim Report -...
Transcript of COMP 4801 Final Year Project Interim Report -...
1
COMP 4801
Final Year Project
Interim Report
Chess Making Engine - Chreator
A convenient tool for making or designing any chess
type you would like to have
Supervisor
Dr. KP Chan
Groupmate
Fung Wai Him 3035074971 Li Chun Kit 3035074311
20th Jan, 2016
2
Table of content
Summary 3
Background and Introduction 4
Objectives 5
Program Structure
General architecture
GUI
Chess playing Program
7
7
8
11
Development progress 13
Conclusion 14
Figure List 1a. Screenshot of aihorizon.com. Tutorials on AI implementation
1b. Screenshot of XiangQi Wizard
2. General architecture of Chreator
3. “Chessboard” tab in operation
4. General program flow of Chreator GUI
5a. Chess playing program (Western Chess) without Debug mode
5b. Chess playing program (Xiang Qi) with Debug mode ON
3
Summary
Artificial intelligent (AI) develops rapidly and more students participate in the
learning process. Learning materials available are either purely algorithms or
completed Chess game programs. This paper introduces our product for easily making
and designing Chess Games - Chreator, which can produce a basic framework of
chess games easily. We hope Chreator could assist facilitating the development of AI
evaluation functions and implementation. Furthermore, it could help people with
fewer programming knowledge and resources to enjoy the happiness of making their
own chess games.
Until now, all user interfaces of chess game executable have been implemented. Users
can now use the Chreator to quickly setup the chess board by simply providing a
picture and by clicking, dragging and dropping to specify its size, position and so on.
As for the chess game executable, functions in the library work properly and can
provide designated features to facilitate the movement of pieces and AI
implementation. Chess pieces access, movement, removal, chess board virtualization,
game tree applications can be done with simple function calls. The chess playing part
can be operated normally. General chess games’ features, especially undo function,
are usually functioning without modifying any code.
4
Background and Introduction
Artificial intelligent (AI) develops rapidly and acts a more important role nowadays.
AI can be used for single player gaming AI implementation, result prediction,
situation virtualization and decision making. As a result, learning and improving the
implementation of AI becomes a topic being concerned.
For an AI beginner to start with, Chess game implementation is straightforward, easy
and classical study case to work on. There are simple chess game making tutorials and
chess game software available. Examples are aihorizon.com and XiangQi Wizard
respectively. The first one provides step by step instructions of code implementation
and code header files for building the whole chess game including chess board, chess
piece, AI, data structure and other corresponding components, which are usually not
the concerns of an AI developer. The second one provides an executable with AI
thinking steps illustrated. This kind of game executable provides only limited chess
types and unmodifiable AI implementation, although the difficulty of the AI can be
selected.
Fig.1a: Screenshot of aihorizon.com. Tutorials
on AI implementation. Working principles and
template header code for implementing the core
part of the Chess game can be downloaded.
Fig.1b: Screenshot of XiangQi Wizard. All UI
and fixed Chinese Chess and AI are
implemented.
5
As a result, the above tools are not ideal enough for AI developers to get start with.
Online tutorials require users to build the whole structure of the final chess game
executable by own. Code for displaying the data to UI, connection between the data
structure, AI algorithm and user input have to be implemented. This wastes a lot of
time for users to handle the non-AI related functions. Moreover, extra libraries and
code solutions may need to be searched for solving the technical problems. This
increases the chance of crashing and number of bugs of the final product.
Chess gaming program downloaded from the Internet is also not satisfactory. The
unmodifiable AI algorithm prohibits the user from testing their implementations. On
the other hand, the limited chess types discourage users from studying other chess
cases for the sake of enhancing their studies. This also discourages users from
designing new chess games.
Objectives
In order to tackle the problem observed, our project focuses on two major software
development goals: Developing a Chess game executable with a highly object-
oriented structure, which suits most kinds of chess game; and developing a Chess
making tool, Chreator, to generate the source codes of a chess game executable for
most types of chess game with pre-coded UI and game settings based on the user
configuration.
Chreator has a library of functions which builds the structure of a chess playing game.
Chreator provides a GUI with well-defined layout for user to setup the basic chess
board, chess piece, chess placing points, edges between points and simple game rules.
As a result, users easily access the provided UI library functions and template model
6
structure for data structure and AI, to build their chess playing programs by simple
API calls, but without writing huge amount of codes for UI interaction
implementation and coordination of all the object components themselves. This saves
time from the simple but necessary coding.
Chreator is also able to open, save and compile chess game executable source code.
This allows them to test for their designs conveniently. Users can use Chreator to
open the old project and change the settings for later modification.
To conclude, Chreator is a platform for all people who are interested in making chess
playing game or program. It allows making of most chess types and their AI in a
flexible way by providing convenient chess game construction methods.
In the remaining parts of the report, program structure and methodology of Chreator,
the current progress and encountered difficulties will be discussed.
7
Program structure
General structure
Chreator is basically a collection of low-level functions and a user interface for
accessing. These functions summarize common features and rules of different chess
playing game. Therefore, users can simply pass corresponding parameters to the
functions and generate a chess playing program. In order to enhance user experience
of using Chreator, a GUI is provided for inputting those parameters and generating
corresponding source code. On the other hand, users are also allowed to directly
modify the source code. The parameters shown on the GUI would change
automatically after saving. Finally, users could compile the source code to a chess
playing program (Refer to Fig. 2).
Fig. 2: General architecture of Chreator. An abstract overview of operating Chreator is
illustrated. The design aims to provide a middleman for easing the difficulties of making
chess game.
Library functions
These are pre-defined functions which generalize common features found in chess
games. Functions used to facilitate the implementation of AI are also stored in this
8
location. Users are strongly discouraged to modify these codes to retain the programs’
stabilities. Several examples are listed as follow:
undoLastMove(): after executing this function, the most recent move will be
undone.
updateLegalMove(): after executing this function, the arraylist storing all legal
moves of the selected piece will be updated.
computerMakeMove(): user could specify how the computer move, parameter
could also passed as AI object.
GUI
The GUI of Chreator consists of five major parts. They are named as “Project
settings”, “Chessboard”, “Chess pieces”, “Game rule” and “AI”.
Project settings tab
Once Chreator is started, the “Project settings” screen would appear. Users can
choose to open a new or an existing project and specify its starting location. If a new
project is being opened, users can choose whether to use a template at this stage. Then
the type of chess game has to be selected. There are three major chess types in
Chreator. They are “piece adding”, “piece moving” and the combination of the
former two. After doing all these settings, users will be directed to the “Chessboard”
tab. Users could later return to this tab for compiling the project to form the resulted
chess playing program (Refer to Appendix Fig. 1).
Chessboard tab
The “Chessboard” tab requires users to upload a picture in JPEG form. The picture is
used to form the chessboard background. The way of setting the nodes for placing a
chess piece (These nodes will be called as “movable nodes” in later sessions if are
mentioned) is as fallow (Refer to Fig. 3):
1. Users specify the size of chessboard (n x m)
9
2. A n x m grid would be generated on screen as a frame
3. Users move the whole frame on the uploaded picture to do rough adjustment
of all movable points’ positions
4. Users drag the points in the grid to do fine adjustment of each movable
point’s position
5. Users create additional points that are not able to be described as n x m
structure by simply clicking on the screen.
6. Users delete useless points
7. Users draw direction lines to specify edges (reachable points) of the
movable points. These lines are generated automatically in step 2. Users
would do fine adjustment in relation to step 5.
8. Board setting is finished and users proceed to the next step.
Fig. 3: “Chessboard” tab in operation. Blue dots represent moveable points. Red lines
represent possible direction relevant to a point. Structure of a board stored in computer is
clearly shown.
By offering this board setting method, we hope to provide users with high efficiency
together with convenience when setting up the board.
10
Chess Piece tab
After establishing the chessboard, users can continue to build the next component,
chess pieces. Users would have to specify a piece’s name and outlook. If its initial
position is required, or any moving rule is needed, users may also specify in the
corresponding places. Moving rules and other special conditions of a piece (e.g.
Promotion of Western Chess) are usually defined in function forms. Although this
increases the flexibility of implementation, its convenience is being lowed. Thus
helping tools would be provided to help developing pieces’ moving rules. These tools
summarize some general moving rules. For examples,
stopWhenMeetingFirstPieceOnDirection(dir), allPointsOnDirection(dir), etc.
Moreover, as same kinds of pieces may appear on both players’ sides, a “clone piece”
button is available (Refer to Appendix Fig. 2).
General rule tab
Users are able to construct certain game rules in “Game rule” tab. Examples includes
time constraints, special moving rules involving interaction with particular
board position and conditions to be checked in each round. Most importantly,
winning or ending criteria will be defined in this tab (Refer to Appendix Fig. 3).
AI tab
The final tab is the “AI” tab. This tab is a Java code editor. Users with programming
knowledge can establish algorithms of AI here. Users can skip implementing this part
if AI is not required. However, users cannot play against the computer if this part is
not implemented. As game tree searching is one of the most common AI algorithms,
simple alpha-beta pruning searching would be implemented. Users need to write their
evaluation functions only.
11
GUI flow overview
The general flow of creating a chess playing game is shown as follow:
Fig. 4: General program flow of Chreator GUI. This summarizes the operating
procedures when a user is using Chreator. Most of the procedures are bidirectional for
convenience.
Chess playing program
The resulted chess playing program contains several general features. Users can undo
moves, save current state and view AI thinking process (if has implemented & is
playing against computer). Moving history would also be shown on the screen.
Furthermore, debug mode is developed to enhance the effectiveness of development
process. Piece placing point with their ID number (not reference in Java) will be
printed on screen (Refer to Fig. 5a).
12
Fig. 5a: Chess playing program (Western Chess) without Debug mode. Several
features are pre-installed on UI to enhance playing & developing experience. Users
can monitor resources used by displaying data in the spaces provided. This aims to
lower the burden of development.
Fig. 5b: Chess playing program (Xiang Qi) with Debug mode ON. Blue dots represent
13
all points on board. Red dots represents available moving points of selected piece.
Users can inspect the setting comfortably.
Development progress
Chess game executable
All designated user interfaces of the chess game executable have been implemented.
At the same time, all features necessary for playing a piece capturing games are
supported. Changing of chess game (e.g. from Xiang Qi to Western Chess) can be
done by modifying several java source files, which facilitate further establishment of
connecting Chreator and chess game executable.
Chreator
The GUIs of “project setting” and “board setting” tabs are complete. The “board
setting” can provide designated features. Miscellaneous features such as fast-keys will
continue to be added. On the other hand, the “piece setting”, “rules setting” and “AI
setting” tabs are still under construction. However, their designs are basically
confirmed.
Limitations
According to current design, the implementation of moving rules on piece tab would
have very few differences with simple coding. This differs from our original objective:
to lower the difficulties of development. In order to offer compensation, more pre-
defined codes will be installed in Chreator. Users can access these helping tools by
clicking buttons provided. Corresponding codes will appear on screen afterwards.
14
Future Development
In the meantime, Chreator and the chess game executable are still two separate
programs. The immediate next step is to establish connection between them. Chreator
will be able to generate the chess game executable after this step.
After that, we would continue to enrich the content of the chess game executable by
providing more gaming features. For examples, game situation editing and pre-
installed game tree searching algorithm. Online competing would also be added as a
bonus if time is allowed.
Furthermore, we would summarize more moving rules found on existing chess games
and add them into Chreator. We believe that providing more functions could enhance
makers’ experience.
Finally, testing will be performed to check against the coordination between AI
implementation and pre-defined functions in the chess game executable.
Conclusion To conclude, Chreator would have to focus more on its efficiency on building chess
game. At the same time, its methods of accessing and constructing rules have to be
refined more. After the above enhancement, more new features will be added to the
chess game executable, such as an online against function allowing users to share and
play with each other and game situation editing.