呵呵 欢迎大家编写自己的AI程序,对战。 C#开发

 

游戏平台  https://files.cnblogs.com/feathersky/ChessChallenge.rar   部分图片从网上下载的 呵呵

 


 

下面是对战代码的规范,可以自行添加其他函数。 作成类库形式即可。改名字,复制到player目录下即可。

 using System;
using System.Collections.Generic;

using System.Text;


//4
个地方不可修改,其他地方可随意修改, 产生出的ChessPlayer.dll 可随意改名, 放入player目录下,即可载入五子棋对战平台


namespace ChessPlayer       //命名空间不可更改
{
    
public class Player     //类名不可更改
    {


        
//此函数声明不可更改
        public string Communicate(string sentence)   
        {
            
if(sentence.Equals("name",StringComparison.OrdinalIgnoreCase) )   return "Computer001";

            
return "Nothing";
        }




        
//此函数声明不可更改
        public int[] WhereToPlace(int[,] board, int color)      //轮到你走棋,传入 棋盘 以及你的棋子颜色,  传出 你要走哪里    0=empty, 1=black, 2= white
        {
            

            
int Row = board.GetLength(0);
            
int Col = board.GetLength(1);


            
//随机产生一个空位
            Random rand = new Random();
           

            
for (int i = 0; i < 500; i++)
            {
                
int x = rand.Next(Row);

                
int y = rand.Next(Col);

                
if (board[x, y] == 0return new int[] { x, y };
            }

            
return new int[] { 00 };
        }
    }
}

 

 

posted on 2009-12-11 11:03  feathersky  阅读(1241)  评论(0编辑  收藏  举报