Easy to write their own tractor algorithm, the algorithm war

Source: Internet
Author: User
Tags contains dotnet implement interface
Algorithm

The tractor game is a widely circulated tractor game, some areas are also called upgrades or double pull (some say upgrades and tractors are different), the tractor game in the basic rules of change, mainly to increase the fun of the game, such as some regions can be a J in the end, will be the banker from the J to 2, but also some can pull from a to J , q to 6 and so on.

The tractor battle is a tractor game developed using the dotnet framework, it realized the basic rules of the tractor game, eliminated 2 is the main function, added some light master, Flow Bureau rules set, there are some of the selection of the bottom of the algorithm, must hit the number of settings, purchase the end of the rules of choice, You can also use robots to help you play cards, showing current progress and so on.

In terms of interface, the tractor war provides the card back making function, you can only click a few mouse, you will be able to your machine favorite digital photos made into a card back, you can also enjoy the fun of music at cards.

For dotnet program developers, you can also use the tractor War plug-in mechanism to develop your own card algorithm plug-in. You only need to implement an algorithm interface, this algorithm interface defines two methods, you only need to implement these two algorithms, you can complete your own think more powerful card algorithm. Interestingly, you can also play algorithmic games with other people to decide whose algorithms are superior.

This interface is described below, along with a simple and less-than-valid algorithm implementation.

If you're going to write a tractor algorithm, you'll need to introduce Kuaff.Tractor.Plugins.dll, which contains Kuaff.Tractor.Plugins. Iuseralgorithm interface.

This interface is defined as:

Using System;
Using System.Collections;
Using System.Text;

Namespace Kuaff.Tractor.Plugins
{
public interface Iuseralgorithm
{
<summary>
Algorithm author
</summary>
String Author
{
Get
}
<summary>
The email address of the algorithm author
</summary>
String Email
{
Get
}
<summary>
Algorithm name
</summary>
String Name
{
Get
}
<summary>
Algorithm Introduction
</summary>
String Description
{
Get
}

<summary>
First the algorithm of the card.
</summary>
<param name= "who" > Current user who, 1 for the South, 2 for the North, 3 for the West, 4 for the club </param>
<param name= "Suit" > The color of the current main card, 1 for the Hearts, 2 for spades, 3 for the square, 4 for the plum, 5 for the King (no main) </param>
<param name= "Rank" > currently dozen, 0 for playing 2,1 for playing 3,2 for playing 4 ... 11 for playing k,12 a,53 for playing King </param>
<param name= "Master" > who is currently the banker, 1 for the South, 2 for the North, 3 for the West, 4 for the club </param>
<param name= "Sendcards" > at present a bureau has been out of the cards, Sendcards[0] for the south, Sendcards[1] for the North home, Sendcards[2] for the west, Sendcards[3] for the club </param>
<param name= "MyCards" > The hand of this user </param>
<returns></returns>
ArrayList shouldsendcards (int who, int suit, int rank, int master, string[] sendcards, string mycards);

<summary>
The algorithm to change the cards of your own (not the first one)
</summary>
<param name= "who" > Current user who, 1 for the South, 2 for the North, 3 for the West, 4 for the club </param>
<param name= "Suit" > The color of the current main card, 1 for the Hearts, 2 for spades, 3 for the square, 4 for the plum, 5 for the King (no main) </param>
<param name= "Rank" > currently dozen, 0 for playing 2,1 for playing 3,2 for playing 4 ... 11 for playing k,12 a,53 for playing King </param>
<param name= "Master" > who is currently the banker, 1 for the South, 2 for the North, 3 for the West, 4 for the club </param>
<param name= "Whoisfirst" > who first out of the cards, 1 for the South home, 2 for the North, 3 for the West, 4 for the club's </param>
<param name= "Sendcards" > at present a bureau has been out of the cards, Sendcards[0] for the south, Sendcards[1] for the North home, Sendcards[2] for the west, Sendcards[3] for the club </param>
<param name= "Currentsendcards" > the first and their own home out of the cards </param>
<param name= "MyCards" > The hand of this user </param>
<returns></returns>
ArrayList mustsendcards (int who, int suit, int rank, int master, int whoisfirst, string[] sendcards, arraylist[] Currentse Ndcards, string mycards);
}
}

It first defines a few attributes, which represent the name of the algorithm author and the email, the name of the algorithm, and a brief introduction.

The Shouldsendcards method defines the first card algorithm. For example, the owner of the first card, call Shouldsendcards get the club should be out of the cards, and then call Mustsendcards get North home should be out of the cards, and then call Mustsendcards get the West should be out of the card, Then call Mustsendcards get South home should be out of the card, the program then calculate, get the next time the first, and then through Shouldsendcards get the first out of the card ... Again and again, until the hands of the cards out.

Through the introduction of the above paragraph, you also understand the meaning of the Mustsendcards method, is not the first should be a card algorithm.

The following Sampleuseralgorithm class is simply a class that implements this interface. Its source code can be obtained in the game's sources directory, and the compiled accessories are placed in the plugins directory. You compile the plug-in must be placed in the plugins directory, the game can read the plugins file under the DLL file, analysis and the written plug-in class.

This sampleuseralgorithm class is simple because its first card algorithm is to pick a card on the out, and the card algorithm assumed the first out of a card, their own casually out of a card of this suit. You can improve on this plugin.

Game Download address (contains the interface and a simple algorithm to achieve the source code): Click here, download address 2, download address three, download address four, software version 1.2.0.356.

Compile your plug-in into a DLL in the game's plugins directory, set up a party in the program with the algorithm you write, you can and the program built in the algorithm to battle. If your algorithm is not the way (such as the first out of the tractor, you have a tractor but not out), that your algorithm is not perfect, the program will automatically change the algorithm to the program's built-in algorithm.



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.