Abstract
We can use java language to design the game of chess on eclipse platform and design a new rule for it : “Six in a Row”, this game is more complex than Five-in-a-Row,and we can add a function of Man-Machine Battle in the program.This paper which based on the practical programming experience introduce the algorithm of the above game. The basic mentality of the algorithm is creating a scoring table and all points of the chessboard are scored by using ergodic method.Finally, the machine will placing the chess in the point which have the highest score.This algorithm is clearly operable, and the machine has a high rate of winning when play with human.
Highlights
Introduction of Algorithm2.1 Overall IntroductionThe idea of the algorithm is that the machine scores points on the board at any time
The score is based on the score table.The score table is based on the data of everyone's battle and the six-piece chess design.It takes both offensive and defensive situations into account.The offense has a higher priority
A chessboard with a size of 19*19 was drawn using the AWT component in java, and the function buttons were drawn at the same time
Summary
The idea of the algorithm is that the machine scores points on the board at any time. If there is an adjacent chess piece of the same color, the variable "trans" will increase by 1.If "trans" equals to 6, it means that one side has won. It will return the color of the winner.If “trans”is less than 6,(it means that there is one or more chess piece of the other color adjacent to it,which is invalid) the "trans" will reset to zero.For vertical,it is similar to the transverse direction, but it is checked in the Y direction.The diagonal are the same——once we know the correspondence of the abscissa and ordinate.We can find the exact expression. LeftUPToDown=0; } if(leftUPToDown==6) return(var); } int leftDownToUP=0; for(int i=x+5,j=y+5;i>x-6&&j>y-6;i--,j--) { if(i=this.x||j=this.y) {
Published Version (Free)
Talk to us
Join us for a 30 min session where you can share your feedback and ask us any queries you have