Introduction of an Android mini-game-interactive man-machine battle Gobang

Source: Internet
Author: User

Article reprinted to CSDN community Luo Shenyang's Android tour, original address: http://blog.csdn.net/luoshengyang/article/details/6589025

Learning Android system Development, wrote a small game-interactive man-machine battle Gobang, entertain themselves. The reason is called Interactive man-machine battle Gobang, one is because before entering the man-machine battle mode, you can set a good start, at the same time, in the course of the battle, you can see the machine thinking process, but also can identify each lazi point of the advantages and disadvantages, and second, because the machine can add game experience, making the machine more and more I hope that the students who like Gobang can enjoy it, and it is also very suitable for entry-level exercises.

First show this gobang the main interface, due to entertain the small game, the interface is relatively humble, not reach the effect of product release, forgive me!

First. Download this Gobang game in csdn, download the link:

http://download.csdn.net/source/3423512

After downloading, decompression, there are three files, respectively, renju.apk, renju.gif and interactive man-machine battle Gobang. docx, where renju.apk is our Android Gobang game program.

Second. If you have an Android SDK environment, first create a 2.1 API version of the emulator. Open the cmd Command window and go to the Tools folder in the SDK directory, for example, if your SDK directory is on D:\android-sdk-windows then go to the D:\android-sdk-windows\tools directory.

1. First execute the Android list target to view the target Platform List command:

As can be seen from here, the target ID of the 2.1 API is 3.

2. Execute the android create avd–n android2.1–t 3 command to create a simulator named android2.1:

3. Execute the start/b android2.1 command to run the simulator in the background:

4. If there is an ADB tool in the tools directory, place the renju.apk file in the tools directory, otherwise, place the renju.apk file in the D:\android-sdk-windows\platform-tools directory and enter the D:\ In the Android-sdk-windows\platform-tools directory, perform the ADB install renju.apk command installed renju.apk on the simulator:

Third. If there is no Android SDK environment, please go to Sina love ask:

Http://ishare.iask.sina.com.cn/f/16902616.html

Http://ishare.iask.sina.com.cn/f/16902614.html

Download the Android 2.1 API simulator (production method reference production can be independently distributed Android Simulator article), after decompression, you can refer to the Readme file inside to run the simulator and install the renju.apk file.

1. Assume that the compression package is unpacked and placed under the D:\AndroidEmulator directory. Open cmd Command window, go to D:\AndroidEmulator directory, execute start/b emulator.exe-sysdir d:\AndroidEmulator-system images\system.img-data Images\userdata.img-ramdisk Images\ramdisk.img-kernel Images\kernel-qemu-skindir D:\AndroidEmulator\skins-skin The HVGA command runs the emulator in the background:

2. After the simulator is running, it has built-in Renju application, no need to install, if not, execute the ADB install renju\renju.apk command.

Fourth. After performing the first or second step, the interactive man-machine battle Gobang is installed, and on the home screen, you can see the Renju application as shown in:

Fifth. Use the method.

Click on the Renju icon on the home screen to open the program:

Press and hold the mouse, move on the board, the mouse position will have a "+" icon to follow the mouse movement; release the mouse, you can select a drop point:

There are five buttons on the main interface:

Start: Click to start the Man-machine battle

Shoot: When the "+" icon appears on the board, click on the button to drop a pawn in the "+" position, Renju will automatically calculate whether the current should be white or black chess

Undo: Undo, click Once regret one step chess

Reset: Start the game again

Annotation: Show/Hide the score of each Lazi point on the current board, the first number indicates the black score, and the second number indicates the white score. The h at the back of the number represents 100, such as 5h, that is divided into 500, similarly, K means that 1000,w represents 10000. The larger the score, the greater the Lazi point advantage, as shown in:

There are two modes of the program, one is the manual battle mode, the other is the man-machine battle mode. Open the program, the default is Everyone mode, click the Start button to enter the man-machine battle mode, into the man-machine mode of battle mode, can not switch to everyone mode. In man-machine versus mode, the computer uses black chess.

Click the menu button on the right side of the keyboard area to display menus with four items:

Importing Opening: Import start

Exporting Opening: Save the start. is not available when the current chessboard is empty

Add to Experiences: Add computer experience. is not available when the board is empty or has only one pawn

Manage Experiences: Managing Computer experience

Click on the exportingopening menu to save your start:

Enter the opening name in the pop-up box and click the OK button.

Click on the importing Opening menu, the Start list appears, select one of the openings, you can import the start:

Click the Add to Experiences menu to add computer experience. For example, when the following chess game appears:

Click the Add to Experiences menu and enter the experience name in the popup box:

Click the OK button to save your experience.
When the next time you enter the man-machine versus mode, if the computer finds the current checkerboard situation as shown:

Automatically drops a black on the "+" position.
Click on the Add to experiences menu to view a list of current computer experiences:

Sixth. The principle of man-machine battle. Simply put, it is through the winning table method, when the turn of the machine Lazi, in the winning table to find the highest score value Lazi point, drop a pawn, and then use the machine to predict the other side of the next possible Lazi point, simulate the other side of the next piece, then judge who gets the advantage, if the machine is at a disadvantage, and then back Find the score value of the Lazi point, drop a pawn, the same, predict the other side of the next possible Lazi point, and simulate the other side of the next piece, then judge who gets the advantage, and so on, this is the backtracking algorithm. So, overall, the machine's intelligence comes from the winning table + backtracking algorithm, with time to describe it in detail, thanks for the attention.

Welcome to Exchange and cooperation, email: [Email protected]

Lao Luo's Sina Weibo: Http://weibo.com/shengyangluo, welcome attention!

Introducing an Android mini-game-interactive man-machine vs Gobang

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.