Unity3d game: Wolves eat sheep games

Source: Internet
Author: User

Brief introduction

Chinese name: Wolf and Sheep

English Name: Wolves&sheep

Game type: Casual/Chess

Number of players: Single or Double.

Game Download: Windows, Android

Game Description: Childhood and small partners often play a game, the game is easy to understand and varied.

The first section of the game rules

The chessboard can be drawn with small stones in the dirt, and the wolves and sheep in the pieces can be replaced with twigs or pebbles.

  Get ready

Find two large stones as wolves, 24 small stones are sheep, wolves and sheep must be placed at the intersection of the grid, at most one piece on each intersection.

  Start

Two wolves were placed on the top and bottom two necks, the sheep 8 placed in the middle of the intersection of a circle, the Wolf first walk after the sheep alternately

The wolf jumps over the sheep and eats the sheep, the wolf only jumps along the straight line of the picture and jumps over a point, and the sheep can only walk a lattice.

Sheep are not allowed to go first, each time put a, the sheep all put out to go, but also each walk a lattice

  Outcome

If Wolves have nowhere to go, the sheep win the race.

Wolves eat the sheep or the sheep concede, the wolf wins the game

Figure 1-1 Openings

Section II Programming

Class libraries involving the core logic of the game are first coded and tested on the WPF platform.

  Basic functions

Checkerboard representation: Using the appropriate data structure to represent the board

Mobile Judgment: Detects whether the user moves is compliant with the move rule

User view: View displays the board and detects the user's input

Chess mode

Everyone play chess: Support the two players take turns

Man-Machine chess: robot difficulty level optional

Chess function

Tip: The AI gives away chess tips

Undo: Can go back to the previous situation

Termination: Immediate termination of the game

Figure 2-1 ending the race

Section three AI algorithms

AI search algorithm draws on the mature depth-first search algorithm in Chinese chess.

  Search algorithm

Alpha-beta Pruning

  Situation generation

Gradual generation based on rules

  Situation Assessment

Piece base force: Each piece has a basic value

Pawn position Valuation: Evaluate the value of a piece in different positions

Chess relationship Valuation: Assessing the interplay between pieces, such as wolves that pose a threat to more sheep

Figure 3-1 Search algorithm debug output

Fourth Section Unity3d

The game core Logic class library that we developed with VisualStudio can be compiled into a DLL file and then referenced in the Unity3d project.

  How to reference. NET class Library

Project properties, applications, Target framework, drop-down list, select the. NET Framework 3.5

Copy all files from the output directory to the Assets\plugins folder of the Unity project after successful compilation

Unity3d will automatically complete the import, and finally, import the namespace of the class library project in the C # script

  If the VB.net project, you also need to manually edit the. vbproj file to turn on VBRuntime embed compilation mode

  <PropertyGroup>    <VBRuntime>Embed</VBRuntime>  </PropertyGroup>

  Generic Game Scripts

Background music: Music that toggles the scene to be continuously played click View Code

Element scaling: Allows users to zoom in-game UI elements click to view Code

Two-person online: Support LAN create game room to play online game click to view Code

Figure 4-1 External class Library project properties

Appendix

Chess Encyclopedia: computer game

GitHub Open Source (WPF): Experdot.wolfgame

GitHub Open Source (unity3d): ExperDot.WolfGame.Unity

Note: UI element style is not unified, the author is also very weak AH (old??????) Old

Unity3d game: Wolves eat sheep games

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.