C # Implementation of Chinese chess program development notes

Source: Internet
Author: User
Tags abstract bool

Recently, and friends to play chess, and then think of this years old code (some of these code refer to some of the network posts), once because do not know how to achieve man-machine war and give up to continue research. Now, this friend, gave me back to the interest, so come here please help, how to achieve man-machine war, let the computer automatically?

At present, has completed the black, the red two square chess rules, but has not realized the human-machine to fight, at present only everybody fights, namely a chess game rules board.

In order to facilitate everyone to give me a break, I first said the principle of their own program:

1, 32 pieces are specific classes, and are inherited from the chessworldbase.

Pawn base class

Using System;
Using System.Collections;
Using System.Windows.Forms;

Namespace Zivsoft.Business.Chess
{
<summary>
Pieces
</summary>
Internal abstract class Chesswordbase:ichess
{
public const int xboardlength = 9;
public const int yboardlength = 10;
public static ArrayList all = new ArrayList ();


<summary>
Within the Board range
</summary>
<returns></returns>
Public virtual bool Check ()
{
if (this. X > 9) | | (This. X < 1))
{
return false;
}
if (this. Y > 10) | | (This. Y < 1))
{
return false;
}
return true;
}

<summary>
Be eaten
</summary>
public virtual void Destroy ()
{
This. Isdogfall = false;
This. X = 0;
This. Y = 0;
}


public virtual void Init ()
{
This. Isdogfall = true;
This. X = 0;
This. Y = 0;
}


#region Ichess Members
<summary>
///
</summary>
public bool Isredchess
{
Get
Set
}

<summary>
///
</summary>
public bool Isdogfall
{
Get
Set
}

<summary>
Attack
</summary>
public bool Isattack
{
Get
Set
}

public int NEXTX
{
Get
Set
}

public int Nexty
{
Get
Set
}

public int X
{
Get
Set
}

public int Y
{
Get
Set
}

<summary>
///
</summary>
public string Name
{
Get
Set
}

Public abstract ArrayList getnextlocation ();


public void Move (int ix,int iy)
{
This. MoveNext ();
if (this. Check (ix, IY, Getnextlocation ()))
{
X = IX;
Y = iy;
}
}

private void MoveNext ()
{
This. NEXTX = this. X
This. Nexty = this. Y
}

public abstract bool Check (int x, int y, ArrayList al);

public void Move (int iX, int IY, Object QZ)
{
if (QZ = null)
{
This. Move (IX, IY);
}
Else
{
This. MoveNext ();
if (this. Check (IX, IY, Getnextlocation ()))
{
X = IX;
Y = IY;
((chesswordbase) QZ). Destroy ();
}
}
}

#endregion
}
}

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.