Java Intelligent four-player war game Design (with Project, and original PSD, design document)

Source: Internet
Author: User
Tags ming

This project is the use of Java technology + self-created "under the Assumption" algorithm developed by the man-machine war four sub-chess game client.

Specific items, as well as original PSD, design documents, at the end of the file Baidu Cloud connection.

I. Panel notes:

Group Name: Cst

Group leader: Chen Fei Liang ( C):

Crew:

Shenke ( S):

Tan Ming Airlines ( T):

two . Description of Division :

① algorithm thought:

The code realization of the program by three people to discuss the idea, wherein the members of the "Shenke" thought is particularly subtle, so that the code to achieve a more simple, on this basis, the team members Tan Ming Ai, thoughtful, considering a variety of special circumstances, so that the whole more intelligent. Team Leader Chen Fei is responsible for the design of the algorithm on their basis to improve.

② Game Interface:

the overall interface of the game is discussed by three people, team leader Chen Fei good use PS production.

③ Code Implementation on:

Ⅰ. the overall layout and architecture of the game is completed by the leader Chen Fei.

Ⅱ. The core of the game is the computer's next method, a total of seven steps

① assumes that the child is a computer, judging to be able to connect to four sub -Yutanming (realized)

② assume that the child is the player son, to determine whether to see if there is a player 4 children connected, that is not the position of the player will be four sub-situation, there is interception (Yutanming navigation)

③ exclude the state of the stepping stone, if the position is a player sub-position, the player can be four children, then the position priority is 9(implemented by Shenke)

④ excluding the most, but to the top also can not make up 4 of the sub- Yutanming (Implementation of the aircraft)

⑤ If the computer puts a child next, the computer can form 2 ways to four children at the same time , then set max_x[x] = 4, that is, the priority is 4. (implemented by Chen Fei)

⑥ If the player puts a child next, the player can simultaneously form 2 methods into four sub-blocks, then set max_x[x] = ten, which is the priority of ten (implemented by Chen Fei)

⑦ common attack, assuming that the computer according to Priority ( in the max_x column Priority ), the same levelis randomly lazi. (implemented by Shenke)

Three Course Design Idea explanation I. various classes

This program has designed a total of 6 classes, the main next 3 classes

1.

Where there are positional classes, i.e. Position class. and There is an integral type flag member Label_status in the Position class .

Label_status = 0 indicates null .

Label_status = 1 indicates the player's child .

Label_status = 2 indicates a computer child .

2.

The Game class is the main class, with the layout of the various controls, as well as the player and the computer's mobile method, and so on.

3.

Mainpanel class main panel

II. implementation of individual operations

1. Initialize

in the design of the main interface to initialize the first to put down each lattice represents the player and the computer sub- The Label member . also set to not visible , and label_status = 0. that is, the location is empty

2.

implementation: Make the player in the corresponding position The label or computer label is visible, changing the flag at the same time.

Player's son: by listening to the keyboard and mouse to move accordingly, to obtain the player's position

III. the computer.

The computer is the core of the entire program, the basic is to follow the people's thinking

set a _y[] array Each element is initialized to -1, indicating that the column has no location

1. find the location where each column can be placed

iterate through each row of a column (x:0--6) , find the line that can , That is, the child's y coordinates

Find the post-location assignment to _y[], i.e. _y[x] = y';

Of course , the y coordinate should be in the same position as the x + y

at the same time the x coordinates correspond to the position of 375 + * x

(This position is determined by the size of the checkerboard and the way the layout is buried)

2. to find out the maximum number of hyphens after each column discharges the brain .

defines a max_x store for each column (x : 0---7) where the parties to the maximum number of hyphens, each element is initialized to -10 ( Just take a number less than 0 can be arbitrarily taken, but to facilitate the later priority setting, can be -7-8 , etc. )

used three times Math.max can find out

Max_x[r] = Math.max (Math.max (you, You_xia), Math.max (Xia, You_shang));

3. Consideration of special circumstances

① assumes that the child is a computer, judging to be able to connect to four children

This.pos[x][y].setlabel_status (2);

Traversal lookup, set up, then Lazi, directly announce the result of the match.

If not, flag recovery

This.pos[x][y].setlabel_status (0);

The following are all the same things

② assume that the child is the player son, to determine whether to see if there is a player 4 children connected, that is not the position of the player will be four sub-situation, there is the interception

③ exclude the state of the stepping stone, if the position is a player sub-position, the player can be four children, then the position priority is -9

put the position of the max_x[x] =-9; (Pre- max_x element is initialized to -10 that is, unless there is no place under, just down here

④ exclude the most, but to the top can not make up 4 of the sub-

Max_x[x] = 0; the priority is smaller than the average, but higher than the stepping stone

⑤ If the computer puts a child next, the computer can form 2 ways to four children at the same time , then set max_x[x] = ten, that is, priority is 4

⑥ If the player puts a child next, the player can simultaneously form 2 methods into four sub-blocks, then set max_x[x] = ten, which is the priority of ten

⑦ General attack, assuming that the computer under the sub, the maximum number of locations ( in max_x There are columns of the largest ) random Lazi. (in the case of the previous stepping stone class, you can change The value in the max_x to change the priority)

if it is 2--4 column max_x + = 0.5; the same priority, the middle priority, and will not cross-level.

You can create an array A, assign the max_x data to the past, and then use the arrays.sort method to sort the last The last element, which is the a the maximum value, which is max_x Maximum Value

The specific code is written in the following order:

four . The process of developing a program, its characteristics, and the areas that need improvement

1. Growth Process

①. self-improvement

as a result of the online example to knock over the Gobang, so the efficiency is very high, in the teacher said after the publication of the topic, our group opened a meeting, the basic algorithm set. the group's "Shenke" thought, which was very important to our code implementation, identified 7 major methods at the first meeting, and a week later, the 1.0 version was written. Then all the way to check the gaps.

②. Complementary

This program has played against two websites of the game

(1) one is http://www.4399.com/flash/48470_1.htm , this site algorithm has an advantage is to understand occupy the middle position, than after, then decided in our 2--4 priority of the column +0.5 , so that it can form the same number of hyphens, more than the other position priority, as far as possible occupy the middle position, but the other position than in this position even more than a few times, will still be next to the sub more position. Since this site does not write the algorithm of stepping stone, so we change the winning percentage is 80% around.

(2) The second is http://www.7k7k.com/swf/50447.htm , the advantage of this site is to be able to actively form a double three, compared to the following, we have added two methods in our program:

However, the method of this site is another way is, after the next son into three children, we are forced to intercept, but also to his own feet, at this time we will lose.

at the same time, our program does not write to prevent ourselves from giving each other a stepping up to make it into a double three algorithm :

Therefore, after the consummation, our winning percentage can only wander between the 50--60%.

2. features of the program

The idea of "assuming the son" of This procedure has the advantage that it does not need to consider the specific situation, such as:

in method 6 , the following conditions can be intercepted:

1. level will have two methods into 4 Sub -

2. There are two ways to 4 in oblique direction

3. the two sides into 3 Sub -

........... and so on. That is, as long as the next son, can have two ways to block the four children, do not need to consider the specific situation, by the computer "assume the next" to enumerate, code efficiency is very high, and other groups of the program compared to the basic can be a code to play 200 The function of the line code.

3. where improvements are needed (1) method of improvement 8 ( 2 ) Write, intercept the player before the next son into three children, causing us to be forced to intercept, at the same time back to his own way of stepping

Project Connection Https://pan.baidu.com/s/1mM95FgUyeHWT6AhY8hA8CA

Java Intelligent four-player war game Design (with Project, and original PSD, design document)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.