--五子棋大赛 标准16×16棋盘
--只要编写一个下棋的存储过程,在存储过程中可以通过表xq获得前面的下棋步骤。
--表xq 字段 id 第几步 x、y横纵坐标决定落子位置,v 下棋者
--存储过程中需要赋值给@x,@y作为本次下棋的落点。
--累计下棋时间超过300秒算超时。
--落子超界或重复落子犯规认输。
if(object_id('five') is not null) drop procedure five
go
create procedure five(@eid nvarchar(100),@wid nvarchar(100))
as
begin
 declare @i int,@j int,@sql nvarchar(4000),@dt datetime
 declare @xq table(id int identity,x int,y int,v nvarchar(100))--下棋步骤,V表下棋者,用0和1表示
 declare @x int,@y int,@v nvarchar(100) --每次的下棋
 declare @vt int,@vt1 int,@vt2 int --下棋者的用时
 declare @js1 int,@js2 int,@js3 int,@js4 int --四个方向计数
 --初始化下棋步骤
 if(object_id(@eid+'_xq') is  null) begin print '机器人:'+@eid+'不存在!!!' return end
 if(object_id(@wid+'_xq') is  null) begin print '机器人:'+@wid+'不存在!!!' return end
 if(object_id('xq') is not null) drop table xq 
 create table xq(id int identity,x int,y int,v nvarchar(100)) -- 用于传递给下棋者 --开始下棋
 select @i = 0,@vt = 0,@vt1 = 0,@vt2 = 0 --每人300秒
 while @i between 0 and 255
 begin
  --清理下棋步骤,获得当前下棋者
  delete xq
  insert xq(x,y,v) select x,y,v  from @xq
  select @v = case @v when @eid then @wid else @eid end,@i = @i + 1
  --下棋
  select @sql='exec '+@v+'_xq @x out,@y out',@dt=getdate()
  exec sp_executesql @sql,N'@x int  output,@y int output',@x=@x output,@y=@y output
  if @v = @eid set @vt1=@vt1+datediff(s,@dt,getdate()) else set @vt2 = @vt2+datediff(s,@dt,getdate())
  --判断超时
  if @vt1 >@vt or @vt2 >@vt begin print '机器人:'+@v+'超时认输!' return end
  --判断是否犯规
  if @x not between 1 and 16 or @y not between 1 and 16 or exists(select 1 from @xq where x= @x and y=@y)
  begin print '机器人:'+@v+'落子犯规认输!' return end
  --判断是否赢
  insert @xq select @x,@y,@v
  select @js1 =0,@js2 =0,@js3=0,@js4 = 0,@j = -5
  while @j <4
   BEGIN
    set @j = @j + 1
    if exists(select 1 from @xq where y=@y + @j and x = @x + @j and @v = v) set @js1 = @js1 + 1 else set @js1 = 0
    if exists(select 1 from @xq where y=@y + @j and x = @x      and @v = v) set @js2 = @js2 + 1 else set @js1 = 0
    if exists(select 1 from @xq where y=@y      and x = @x + @j and @v = v) set @js3 = @js3 + 1 else set @js1 = 0
    if exists(select 1 from @xq where y=@y - @j and x = @x - @j and @v = v) set @js4 = @js4 + 1 else set @js1 = 0
    if @js1 = 5 or @js2 = 5 or @js3 = 5 or @js4 =5 select @i = @i+1000,@j = @j + 100
   END
  end
  if @i <1000 begin print @eid +' vs + '+@wid +' 平局!'  return end
  print char(10)+'  机器人:'+@v+' 在第'+rtrim(@i-1000)+'手时获胜!'
  print '┏┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┓'
  select @i = 0,@j = @j - 100
  while @i <16
  begin
   select @i = @i +1,@sql = '┣',@j=0
   while @j <16
   begin 
    select @j = @j +1,@v = -1
    select @v = v from @xq where x= @j and y = @i
    if @i= @y and @j = @x
          select @sql = @sql + case @v  when @eid then '○' when @wid then '□' else '╋' end
    else  select @sql = @sql + case @v  when @eid then '●' when @wid then '■' else '╋' end
   end
   print @sql+'┫'
  end
  print '┗┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┛'
end
go
if(object_id('cson1_xq') is not null) drop procedure cson1_xq
go
create procedure cson1_xq(@x int output,@y int output)
as
begin
  declare @i int
  select @i = 5
  while @i <16
   if exists(select 1 from xq where x = @i and y = @i ) set @i = @i +1
   else begin select @x= @i ,@y = @i return end
  select @x = @i,@y = @i
end
go
if(object_id('cson2_xq') is not null) drop procedure cson2_xq
go
create procedure cson2_xq(@x int output,@y int output)
as
begin
  declare @i int
  select @i = 7
  while @i < 16
   if exists(select 1 from xq where x = 6 and y = @i-1 ) set @i = @i +1
   else begin select @x= 6 ,@y = @i-1 return end
  select @x = @i,@y = @i
end
go
set nocount on
exec five 'cson1','cson2'
/*
  机器人:cson2 在第10手时获胜!
┏┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┓
┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
┣╋╋╋╋●╋╋╋╋╋╋╋╋╋╋╋┫
┣╋╋╋╋╋■╋╋╋╋╋╋╋╋╋╋┫
┣╋╋╋╋╋■●╋╋╋╋╋╋╋╋╋┫
┣╋╋╋╋╋■╋●╋╋╋╋╋╋╋╋┫
┣╋╋╋╋╋■╋╋●╋╋╋╋╋╋╋┫
┣╋╋╋╋╋□╋╋╋●╋╋╋╋╋╋┫
┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
┗┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┛
*/

解决方案 »

  1.   

    --五子棋大赛 标准16×16棋盘
    --只要编写一个下棋的存储过程,在存储过程中可以通过表获得前面的下棋步骤。
    --xq id 第几步 x、y横纵坐标决定落子位置,v 下棋者
    --存储过程中需要赋值给@x,@y作为本次下棋的落点。
    --累计下棋时间超过300秒算超时。
    --落子超界或重复落子犯规认输。
    if(object_id('five') is not null) drop procedure five
    go
    create procedure five(@eid nvarchar(100),@wid nvarchar(100))
    as
    begin
     declare @i int,@j int,@sql nvarchar(4000),@dt datetime
     declare @xq table(id int identity,x int,y int,v nvarchar(100))--下棋步骤,V表下棋者,用0和1表示
     declare @x int,@y int,@v nvarchar(100) --每次的下棋
     declare @vt int,@vt1 int,@vt2 int --下棋者的用时
     declare @js1 int,@js2 int,@js3 int,@js4 int --四个方向计数
     --初始化下棋步骤
     if(object_id(@eid+'_xq') is  null) begin print '机器人:'+@eid+'不存在!!!' return end
     if(object_id(@wid+'_xq') is  null) begin print '机器人:'+@wid+'不存在!!!' return end
     if(object_id('xq') is not null) drop table xq 
     create table xq(id int identity,x int,y int,v nvarchar(100)) -- 用于传递给下棋者 --开始下棋
     select @i = 0,@vt = 300,@vt1 = 0,@vt2 = 0 --每人300秒
     while @i between 0 and 255
     begin
      --清理下棋步骤,获得当前下棋者
      delete xq
      insert xq(x,y,v) select x,y,v  from @xq
      select @v = case @v when @eid then @wid else @eid end,@i = @i + 1
      --下棋
      select @sql='exec '+@v+'_xq @x out,@y out',@dt=getdate()
      exec sp_executesql @sql,N'@x int  output,@y int output',@x=@x output,@y=@y output
      if @v = @eid set @vt1=@vt1+datediff(s,@dt,getdate()) else set @vt2 = @vt2+datediff(s,@dt,getdate())
      --判断超时
      if @vt1 >@vt or @vt2 >@vt begin print '机器人:'+@v+'超时认输!'+rtrim(@x)+' '+rtrim(@y) return end
      --判断是否犯规
      if @x not between 1 and 16 or @y not between 1 and 16 or exists(select 1 from @xq where x= @x and y=@y)
      begin print '机器人:'+@v+'落子犯规认输!'+rtrim(@x)+' '+rtrim(@y) return end
      --判断是否赢
      insert @xq select @x,@y,@v
      select @js1 =0,@js2 =0,@js3=0,@js4 = 0,@j = -5
      while @j <4
       BEGIN
        set @j = @j + 1
        if exists(select 1 from @xq where y=@y + @j and x = @x + @j and @v = v) set @js1 = @js1 + 1 else set @js1 = 0
        if exists(select 1 from @xq where y=@y + @j and x = @x      and @v = v) set @js2 = @js2 + 1 else set @js2 = 0
        if exists(select 1 from @xq where y=@y      and x = @x + @j and @v = v) set @js3 = @js3 + 1 else set @js3 = 0
        if exists(select 1 from @xq where y=@y - @j and x = @x - @j and @v = v) set @js4 = @js4 + 1 else set @js4 = 0
        if @js1 = 5 or @js2 = 5 or @js3 = 5 or @js4 =5 select @i = @i+1000,@j = @j + 100
       END
      end
      if @i <1000 begin print @eid +' vs + '+@wid +' 平局!'  return end
      print char(10)+'  机器人:'+@v+' 在第'+rtrim(@i-1000)+'手时获胜!'
      print '┏┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┓'
      select @i = 0,@j = @j - 100
      while @i <16
      begin
       select @i = @i +1,@sql = '┣',@j=0
       while @j <16
       begin 
        select @j = @j +1,@v = -1
        select @v = v from @xq where x= @j and y = @i
        if @i= @y and @j = @x
              select @sql = @sql + case @v  when @eid then '○' when @wid then '□' else '╋' end
        else  select @sql = @sql + case @v  when @eid then '●' when @wid then '■' else '╋' end
       end
       print @sql+'┫'
      end
      print '┗┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┛'
    end
    go
      

  2.   

    19楼的代码有问题,楼主再改改,等你改好了,我写个作弊代码,,,
    exec five 'cson2','cson2'/*
      机器人:cson2 在第5手时获胜!
    ┏┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┓
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋● ╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋● ╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋● ╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋● ╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋○ ╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┗┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┛
    */
      

  3.   

    增加随机改名功能,避免作弊。--五子棋大赛 标准16×16棋盘
    --只要编写一个下棋的存储过程,在存储过程中可以通过表获得前面的下棋步骤。
    --xq id 第几步 x、y横纵坐标决定落子位置,v 下棋者
    --存储过程中需要赋值给@x,@y作为本次下棋的落点。
    --累计下棋时间超过300秒算超时。
    --落子超界或重复落子犯规认输。
    if(object_id('five') is not null) drop procedure five
    go
    create procedure five(@eid nvarchar(100),@wid nvarchar(100))
    as
    begin
     declare @i int,@j int,@sql nvarchar(4000),@dt datetime,@neweid varchar(100),@newwid varchar(100)
     declare @xq table(id int identity,x int,y int,v nvarchar(100))--下棋步骤,V表下棋者,用0和1表示
     declare @x int,@y int,@v nvarchar(100),@vsp varchar(100) --每次的下棋
     declare @vt int,@vt1 int,@vt2 int --下棋者的用时
     declare @js1 int,@js2 int,@js3 int,@js4 int --四个方向计数
     --初始化下棋步骤
     if @eid = @wid begin print '不支持自己打自己!' return end 
     if(object_id(@eid+'_xq') is  null) begin print '机器人:'+@eid+'不存在!!!' return end
     if(object_id(@wid+'_xq') is  null) begin print '机器人:'+@wid+'不存在!!!' return end
     --防作弊,随机改名
     select @neweid = 'esp'+left(newid(),4)
     if(object_id(@neweid) is not null) begin set @sql = 'drop proc '+@neweid exec(@sql) end
     set @sql = @eid+'_xq' exec sp_rename @sql,@neweid
     select @newwid = 'wsp'+left(newid(),4)
     if(object_id(@newwid) is not null) begin set @sql = 'drop proc '+@newwid exec(@sql) end
     set @sql = @wid+'_xq' exec sp_rename @sql,@newwid if(object_id('xq') is not null) drop table xq 
     create table xq(id int identity,x int,y int,v nvarchar(100)) -- 用于传递给下棋者 --开始下棋
     select @i = 0,@vt = 300,@vt1 = 0,@vt2 = 0 --每人300秒
     while @i between 0 and 255
     begin
      --清理下棋步骤,获得当前下棋者
      delete xq
      insert xq(x,y,v) select x,y,v  from @xq
      select @v   = case @v when @eid then @wid else @eid end,@i = @i + 1
      select @vsp = case @v when @eid then @neweid else @newwid end
      --下棋
      select @sql='exec '+@vsp+' @x out,@y out',@dt=getdate()
      exec sp_executesql @sql,N'@x int  output,@y int output',@x=@x output,@y=@y output
      if @v = @eid set @vt1=@vt1+datediff(s,@dt,getdate()) else set @vt2 = @vt2+datediff(s,@dt,getdate())
      --判断超时
      if @vt1 >@vt or @vt2 >@vt begin print '机器人:'+@v+'超时认输!'+rtrim(@x)+' '+rtrim(@y) set @i=1000 continue end
      --判断是否犯规
      if @x not between 1 and 16 or @y not between 1 and 16 or exists(select 1 from @xq where x= @x and y=@y)
      begin print '机器人:'+@v+'落子犯规认输!'+rtrim(@x)+' '+rtrim(@y) set @i=1000 continue end
      --判断是否赢
      insert @xq select @x,@y,@v
      select @js1 =0,@js2 =0,@js3=0,@js4 = 0,@j = -5
      while @j <4
       BEGIN
        set @j = @j + 1
        if exists(select 1 from @xq where y=@y + @j and x = @x + @j and @v = v) set @js1 = @js1 + 1 else set @js1 = 0
        if exists(select 1 from @xq where y=@y + @j and x = @x      and @v = v) set @js2 = @js2 + 1 else set @js2 = 0
        if exists(select 1 from @xq where y=@y      and x = @x + @j and @v = v) set @js3 = @js3 + 1 else set @js3 = 0
        if exists(select 1 from @xq where y=@y - @j and x = @x - @j and @v = v) set @js4 = @js4 + 1 else set @js4 = 0
        if @js1 = 5 or @js2 = 5 or @js3 = 5 or @js4 =5 select @i = @i+1000,@j = @j + 100
       END
      end
      set @sql = @eid+'_xq' exec sp_rename @neweid,@sql
      set @sql = @wid+'_xq' exec sp_rename @newwid,@sql
      if @i <1000 begin print @eid +' vs + '+@wid +' 平局!'  return end
      print char(10)+'  机器人:'+@v+' 在第'+rtrim(@i-1000)+'手时获胜!'
      print '┏┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┓'
      select @i = 0,@j = @j - 100
      while @i <16
      begin
       select @i = @i +1,@sql = '┣',@j=0
       while @j <16
       begin 
        select @j = @j +1,@v = -1
        select @v = v from @xq where x= @j and y = @i
        if @i= @y and @j = @x
              select @sql = @sql + case @v  when @eid then '○' when @wid then '□' else '╋' end
        else  select @sql = @sql + case @v  when @eid then '●' when @wid then '■' else '╋' end
       end
       print @sql+'┫'
      end
      print '┗┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┛'
    end
    go
      

  4.   

    if(object_id('cson1_xq') is not null) drop procedure cson1_xq
    go
    create procedure cson1_xq(@x int output,@y int output)
    as
    begin
      declare @i int,@x1 int,@y1 int ,@j int,@v varchar(100)
      declare @js1 int,@js2 int,@js3 int,@js4 int,@js int,@fx int,@r int,@c int
      select @x1 = 8,@y1 = 9,@v = ''
      select @x1 = x,@y1 = y,@v= v from xq where id = (select max(id) from xq)
      select @js1 =0,@js2 =0,@js3=0,@js4 = 0,@js=0,@i = -4
      while @i<=4 
      begin 
       if exists(select 1 from xq where x= @x1+@i  and y=@y1+@i  and v = @v) select @js1=@js1+1 else begin if @js1>@js  select @fx = 1,@js = @js1 set @js1 = 0 end
       if exists(select 1 from xq where x= @x1     and y=@y1+@i  and v = @v) select @js2=@js2+1 else begin if @js2>@js  select @fx = 2,@js = @js2 set @js2 = 0 end
       if exists(select 1 from xq where x= @x1+@i  and y=@y1     and v = @v) select @js3=@js3+1 else begin if @js3>@js  select @fx = 3,@js = @js3 set @js3 = 0 end
       if exists(select 1 from xq where x= @x1-@i  and y=@y1-@i  and v = @v) select @js4=@js4+1 else begin if @js4>@js  select @fx = 4,@js = @js4 set @js4 = 0 end
       set @i = @i +1
      end 
      if @js1 > @js select @fx = 1,@js = @js1
      if @js2 > @js select @fx = 2,@js = @js2
      if @js3 > @js select @fx = 3,@js = @js3
      if @js4 > @js select @fx = 4,@js = @js4
      if @fx=1 select @r =  1,@c =  1
      if @fx=2 select @r =  1,@c =  0
      if @fx=3 select @r =  0,@c =  1
      if @fx=4 select @r = -1,@c = -1
      select @i = -4
      while @i <=4
      begin 
        select @x=@x1+@i*@c,@y = @y1+@i*@r
        if (@x between 1 and 16) and (@y between 1 and 16) and (not exists(select 1 from xq where x =@x and y = @y)) return
        set @i = @i +1
      end
      select @x1 = 8,@y1=8,@i= 1
      while @i <=8
      begin
       select @x = case when @x1>@i then @x1 - @i else 1 end,@y= case when @y1>@i then @y1-@i else 1 end
       if @x between 1 and 16 and @y between 1 and 16  and not exists (select 1 from xq where x= @x and y = @y) return
       select @x = case when @x1>@i then @x1 - @i else 1 end,@y=@y1    if @x between 1 and 16 and @y between 1 and 16  and not exists (select 1 from xq where x= @x and y = @y) return
       select @x = case when @x1>@i then @x1 - @i else 1 end,@y=@y1+@i if @x between 1 and 16 and @y between 1 and 16  and not exists (select 1 from xq where x= @x and y = @y) return
       select @x = @x1     ,@y= case when @y1>@i then @y1-@i else 1 end if @x between 1 and 16 and @y between 1 and 16  and not exists (select 1 from xq where x= @x and y = @y) return
       select @x = @x1     ,@y=@y1    if @x between 1 and 16 and @y between 1 and 16  and not exists (select 1 from xq where x= @x and y = @y) return
       select @x = @x1     ,@y=@y1+@i if @x between 1 and 16 and @y between 1 and 16  and not exists (select 1 from xq where x= @x and y = @y) return
       select @x = @x1 + @i,@y= case when @y1>@i then @y1-@i else 1 end if @x between 1 and 16 and @y between 1 and 16  and not exists (select 1 from xq where x= @x and y = @y) return
       select @x = @x1 + @i,@y=@y1    if @x between 1 and 16 and @y between 1 and 16  and not exists (select 1 from xq where x= @x and y = @y) return
       select @x = @x1 + @i,@y=@y1+@i if @x between 1 and 16 and @y between 1 and 16  and not exists (select 1 from xq where x= @x and y = @y) return
       select @i = @i + 1
      end
    end
    go
    if(object_id('cson2_xq') is not null) drop procedure cson2_xq
    go
    create procedure cson2_xq(@x int output,@y int output)
    as
    begin
      declare @i int,@x1 int,@y1 int ,@j int,@v varchar(100)
      declare @js1 int,@js2 int,@js3 int,@js4 int,@js int,@fx int,@r int,@c int
      select @x1 = 8,@y1 = 9,@v = ''
      select @x1 = x,@y1 = y,@v= v from xq where id = (select max(id) from xq)
      select @js1 =0,@js2 =0,@js3=0,@js4 = 0,@js=0,@i = -4
      while @i<=4 
      begin 
       if exists(select 1 from xq where x= @x1+@i  and y=@y1+@i  and v = @v) select @js1=@js1+1 else begin if @js1>@js  select @fx = 1,@js = @js1 set @js1 = 0 end
       if exists(select 1 from xq where x= @x1     and y=@y1+@i  and v = @v) select @js2=@js2+1 else begin if @js2>@js  select @fx = 2,@js = @js2 set @js2 = 0 end
       if exists(select 1 from xq where x= @x1+@i  and y=@y1     and v = @v) select @js3=@js3+1 else begin if @js3>@js  select @fx = 3,@js = @js3 set @js3 = 0 end
       if exists(select 1 from xq where x= @x1-@i  and y=@y1-@i  and v = @v) select @js4=@js4+1 else begin if @js4>@js  select @fx = 4,@js = @js4 set @js4 = 0 end
       set @i = @i +1
      end 
      if @js1 > @js select @fx = 1,@js = @js1
      if @js2 > @js select @fx = 2,@js = @js2
      if @js3 > @js select @fx = 3,@js = @js3
      if @js4 > @js select @fx = 4,@js = @js4
      if @fx=1 select @r =  1,@c =  1
      if @fx=2 select @r =  1,@c =  0
      if @fx=3 select @r =  0,@c =  1
      if @fx=4 select @r = -1,@c = -1
      select @i = -4
      while @i <=4
      begin 
        select @x=@x1+@i*@c,@y = @y1+@i*@r
        if (@x between 1 and 16) and (@y between 1 and 16) and (not exists(select 1 from xq where x =@x and y = @y)) return
        set @i = @i +1
      end
      select @x1 = 8,@y1=8,@i= 8
      while @i >0
      begin
       select @x = case when @x1>@i then @x1 - @i else 1 end,@y= case when @y1>@i then @y1-@i else 1 end
       if @x between 1 and 16 and @y between 1 and 16  and not exists (select 1 from xq where x= @x and y = @y) return
       select @x = case when @x1>@i then @x1 - @i else 1 end,@y=@y1    if @x between 1 and 16 and @y between 1 and 16  and not exists (select 1 from xq where x= @x and y = @y) return
       select @x = case when @x1>@i then @x1 - @i else 1 end,@y=@y1+@i if @x between 1 and 16 and @y between 1 and 16  and not exists (select 1 from xq where x= @x and y = @y) return
       select @x = @x1     ,@y= case when @y1>@i then @y1-@i else 1 end if @x between 1 and 16 and @y between 1 and 16  and not exists (select 1 from xq where x= @x and y = @y) return
       select @x = @x1     ,@y=@y1    if @x between 1 and 16 and @y between 1 and 16  and not exists (select 1 from xq where x= @x and y = @y) return
       select @x = @x1     ,@y=@y1+@i if @x between 1 and 16 and @y between 1 and 16  and not exists (select 1 from xq where x= @x and y = @y) return
       select @x = @x1 + @i,@y= case when @y1>@i then @y1-@i else 1 end if @x between 1 and 16 and @y between 1 and 16  and not exists (select 1 from xq where x= @x and y = @y) return
       select @x = @x1 + @i,@y=@y1    if @x between 1 and 16 and @y between 1 and 16  and not exists (select 1 from xq where x= @x and y = @y) return
       select @x = @x1 + @i,@y=@y1+@i if @x between 1 and 16 and @y between 1 and 16  and not exists (select 1 from xq where x= @x and y = @y) return
       select @i = @i-1
      end
      select * from xq order by x,y
      print rtrim(@x)+'dsds'
    end
    go
    set nocount on
    exec five 'cson1','cson2'
    /*
      机器人:cson2 在第84手时获胜!
    ┏┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┓
    ┣●■╋╋╋╋●╋╋╋╋╋╋╋╋╋┫
    ┣■■●╋╋╋╋■╋╋╋╋╋╋╋╋┫
    ┣●●■╋╋╋╋╋●╋╋╋╋╋╋╋┫
    ┣●●●■■●■╋╋■╋╋╋╋╋╋┫
    ┣●■╋●●╋■╋╋╋╋╋╋╋╋╋┫
    ┣□●╋■■●╋●╋╋╋╋╋╋╋╋┫
    ┣■■●╋■■●╋╋╋╋╋╋╋╋╋┫
    ┣■●╋■╋╋●●╋╋╋╋╋╋╋╋┫
    ┣■■●╋■╋●■■╋╋╋╋╋╋╋┫
    ┣■●╋╋╋╋╋■●■╋╋╋╋╋╋┫
    ┣●■●╋╋╋╋╋╋╋■╋╋╋╋╋┫
    ┣■●╋╋●╋╋●╋╋╋●╋╋╋╋┫
    ┣●■╋╋■╋╋╋╋╋╋╋●╋╋╋┫
    ┣●●■╋●╋╋╋╋╋╋╋╋●╋╋┫
    ┣■■●●■●■╋╋╋╋╋╋╋■╋┫
    ┣■●╋■●╋╋╋╋╋╋╋╋╋╋■┫
    ┗┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┛
    */
      

  5.   

    --五子棋大赛 标准16×16棋盘
    --只要编写一个下棋的存储过程,在存储过程中可以通过表获得前面的下棋步骤。
    --xq id 第几步 x、y横纵坐标决定落子位置,v 下棋者
    --存储过程中需要赋值给@x,@y作为本次下棋的落点。
    --累计下棋时间超过300秒算超时。
    --落子超界或重复落子犯规认输。
    --增加防作弊功能,目前无法阻止出错性破坏代码
    if(object_id('five') is not null) drop procedure five
    go
    create procedure five(@eid nvarchar(100),@wid nvarchar(100))
    as
    begin
     declare @i int,@j int,@sql nvarchar(4000),@dt datetime,@neweid varchar(100),@newwid varchar(100)
     declare @xq table(id int identity,x int,y int,v nvarchar(100))--下棋步骤,V表下棋者,用0和1表示
     declare @x int,@y int,@v nvarchar(100),@vsp varchar(100) --每次的下棋
     declare @vt int,@vt1 int,@vt2 int --下棋者的用时
     declare @js1 int,@js2 int,@js3 int,@js4 int --四个方向计数
     --初始化下棋步骤
     if @eid = @wid begin print '不支持自己打自己!' return end 
     if(object_id(@eid+'_xq') is  null) begin print '机器人:'+@eid+'不存在!!!' return end
     if(object_id(@wid+'_xq') is  null) begin print '机器人:'+@wid+'不存在!!!' return end
     --防作弊,改名
     select @neweid = 'esp'+left(newid(),4)
     if(object_id(@neweid) is not null) begin set @sql = 'drop proc '+@neweid exec(@sql) end
     set @sql = @eid+'_xq' exec sp_rename @sql,@neweid
     select @newwid = 'wsp'+left(newid(),4)
     if(object_id(@newwid) is not null) begin set @sql = 'drop proc '+@newwid exec(@sql) end
     set @sql = @wid+'_xq' exec sp_rename @sql,@newwid if(object_id('xq') is not null) drop table xq 
     create table xq(id int identity,x int,y int,v nvarchar(100)) -- 用于传递给下棋者 --开始下棋
     select @i = 0,@vt = 300,@vt1 = 0,@vt2 = 0 --每人300秒
     while @i between 0 and 255
     begin
      --清理下棋步骤,获得当前下棋者
      delete xq
      insert xq(x,y,v) select x,y,v  from @xq
      select @v   = case @v when @eid then @wid else @eid end,@i = @i + 1
      select @vsp = case @v when @eid then @neweid else @newwid end
      --下棋
      select @sql='exec '+@vsp+' @x out,@y out',@dt=getdate()
      exec sp_executesql @sql,N'@x int  output,@y int output',@x=@x output,@y=@y output
      if @v = @eid set @vt1=@vt1+datediff(s,@dt,getdate()) else set @vt2 = @vt2+datediff(s,@dt,getdate())
      --判断超时
      if @vt1 >@vt or @vt2 >@vt begin  set @i=998 continue end
      --判断是否犯规
      if @x not between 1 and 16 or @y not between 1 and 16 or exists(select 1 from @xq where x= @x and y=@y)
      begin set @i=999 continue end
      --判断是否赢
      insert @xq select @x,@y,@v
      select @js1 =0,@js2 =0,@js3=0,@js4 = 0,@j = -5
      while @j <4
       BEGIN
        set @j = @j + 1
        if exists(select 1 from @xq where y=@y + @j and x = @x + @j and @v = v) set @js1 = @js1 + 1 else set @js1 = 0
        if exists(select 1 from @xq where y=@y + @j and x = @x      and @v = v) set @js2 = @js2 + 1 else set @js2 = 0
        if exists(select 1 from @xq where y=@y      and x = @x + @j and @v = v) set @js3 = @js3 + 1 else set @js3 = 0
        if exists(select 1 from @xq where y=@y - @j and x = @x - @j and @v = v) set @js4 = @js4 + 1 else set @js4 = 0
        if @js1 = 5 or @js2 = 5 or @js3 = 5 or @js4 =5 select @i = @i+1000,@j = @j + 100
       END
      end
      set @sql = @eid+'_xq' exec sp_rename @neweid,@sql
      set @sql = @wid+'_xq' exec sp_rename @newwid,@sql
      if @i = 998 begin print char(10)+'机器人:'+@v+'超时认输!'+rtrim(@x)+' '+rtrim(@y) return end
      if @i = 999 begin print char(10)+'机器人:'+@v+'落子犯规认输!'+rtrim(@x)+' '+rtrim(@y) return end
      if @i <1000 begin print @eid +' vs + '+@wid +' 平局!'  return end
      print char(10)+'  机器人:'+@v+' 在第'+rtrim(@i-1000)+'手时获胜!'
      print '┏┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┓'
      select @i = 0,@j = @j - 100
      while @i <16
      begin
       select @i = @i +1,@sql = '┣',@j=0
       while @j <16
       begin 
        select @j = @j +1,@v = -1
        select @v = v from @xq where x= @j and y = @i
        if @i= @y and @j = @x
              select @sql = @sql + case @v  when @eid then '○' when @wid then '□' else '╋' end
        else  select @sql = @sql + case @v  when @eid then '●' when @wid then '■' else '╋' end
       end
       print @sql+'┫'
      end
      print '┗┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┛'
    end
    go
      

  6.   

    --五子棋大赛 标准16×16棋盘
    --只要编写一个下棋的存储过程,在存储过程中可以通过表获得前面的下棋步骤。
    --xq id 第几步 x、y横纵坐标决定落子位置,v 下棋者
    --存储过程中需要赋值给@x,@y作为本次下棋的落点。
    --累计下棋时间超过300秒算超时。
    --落子超界或重复落子犯规认输。
    --含有防作弊功能,目前无法阻止出错性破坏代码
    if(object_id('five') is not null) drop procedure five
    go
    create procedure five(@eid nvarchar(100),@wid nvarchar(100))
    as
    begin
     declare @i int,@j int,@sql nvarchar(4000),@dt datetime,@neweid varchar(100),@newwid varchar(100)
     declare @xq table(id int identity,x int,y int,v nvarchar(100))--下棋步骤,V表下棋者,用0和1表示
     declare @x int,@y int,@v nvarchar(100),@vsp varchar(100) --每次的下棋
     declare @vt int,@vt1 int,@vt2 int --下棋者的用时
     declare @js1 int,@js2 int,@js3 int,@js4 int --四个方向计数
     --初始化下棋步骤
     if @eid = @wid begin print '不支持自己打自己!' return end 
     if(object_id(@eid+'_xq') is  null) begin print '机器人:'+@eid+'不存在!!!' return end
     if(object_id(@wid+'_xq') is  null) begin print '机器人:'+@wid+'不存在!!!' return end
     --防作弊,改名
     select @neweid = left(newid(),8)
     if(object_id(@neweid) is not null) begin set @sql = 'drop proc '+@neweid exec(@sql) end
     set @sql = @eid+'_xq' exec sp_rename @sql,@neweid
     select @newwid = left(newid(),8)
     if(object_id(@newwid) is not null) begin set @sql = 'drop proc '+@newwid exec(@sql) end
     set @sql = @wid+'_xq' exec sp_rename @sql,@newwid if(object_id('xq') is not null) drop table xq 
     create table xq(id int identity,x int,y int,v nvarchar(100)) -- 用于传递给下棋者 --开始下棋
     select @i = 0,@vt = 300,@vt1 = 0,@vt2 = 0 --每人300秒
     while @i between 0 and 255
     begin
      --清理下棋步骤,获得当前下棋者
      delete xq
      insert xq(x,y,v) select x,y,v  from @xq
      select @v   = case @v when @eid then @wid else @eid end,@i = @i + 1
      select @vsp = case @v when @eid then @neweid else @newwid end
      --下棋
      select @sql='exec '+@vsp+' @x out,@y out',@dt=getdate()
      exec sp_executesql @sql,N'@x int  output,@y int output',@x=@x output,@y=@y output
      if @v = @eid set @vt1=@vt1+datediff(s,@dt,getdate()) else set @vt2 = @vt2+datediff(s,@dt,getdate())
      --判断超时
      if @vt1 >@vt or @vt2 >@vt begin  set @i=998 continue end
      --判断是否犯规
      if @x not between 1 and 16 or @y not between 1 and 16 or exists(select 1 from @xq where x= @x and y=@y)
      begin set @i=999 continue end
      --判断是否赢
      insert @xq select @x,@y,@v
      select @js1 =0,@js2 =0,@js3=0,@js4 = 0,@j = -5
      while @j <4
       BEGIN
        set @j = @j + 1
        if exists(select 1 from @xq where y=@y + @j and x = @x + @j and @v = v) set @js1 = @js1 + 1 else set @js1 = 0
        if exists(select 1 from @xq where y=@y + @j and x = @x      and @v = v) set @js2 = @js2 + 1 else set @js2 = 0
        if exists(select 1 from @xq where y=@y      and x = @x + @j and @v = v) set @js3 = @js3 + 1 else set @js3 = 0
        if exists(select 1 from @xq where y=@y - @j and x = @x - @j and @v = v) set @js4 = @js4 + 1 else set @js4 = 0
        if @js1 = 5 or @js2 = 5 or @js3 = 5 or @js4 =5 select @i = @i+1000,@j = @j + 100
       END
      end
      set @sql = @eid+'_xq' exec sp_rename @neweid,@sql
      set @sql = @wid+'_xq' exec sp_rename @newwid,@sql
      if @i = 998 begin print char(10)+'机器人:'+@v+'超时认输!'+rtrim(@x)+' '+rtrim(@y) return end
      if @i = 999 begin print char(10)+'机器人:'+@v+'落子犯规认输!'+rtrim(@x)+' '+rtrim(@y) return end
      if @i <1000 begin print @eid +' vs + '+@wid +' 平局!'  return end
      print char(10)+'  机器人:'+@v+' 在第'+rtrim(@i-1000)+'手时获胜!'
      print '┏┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┓'
      select @i = 0,@j = @j - 100
      while @i <16
      begin
       select @i = @i +1,@sql = '┣',@j=0
       while @j <16
       begin 
        select @j = @j +1,@v = -1
        select @v = v from @xq where x= @j and y = @i
        if @i= @y and @j = @x
              select @sql = @sql + case @v  when @eid then '○' when @wid then '□' else '╋' end
        else  select @sql = @sql + case @v  when @eid then '●' when @wid then '■' else '╋' end
       end
       print @sql+'┫'
      end
      print '┗┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┛'
    end
    go
      

  7.   

    --五子棋大赛 标准16×16棋盘
    --只要编写一个下棋的存储过程,在存储过程中可以通过表获得前面的下棋步骤。
    --xq id 第几步 x、y横纵坐标决定落子位置,v 下棋者
    --存储过程中需要赋值给@x,@y作为本次下棋的落点。
    --累计下棋时间超过300秒算超时。
    --落子超界或重复落子犯规认输。
    --含有防作弊功能,目前无法阻止出错性破坏代码
    if(object_id('five') is not null) drop procedure five
    go
    create procedure five(@eid nvarchar(100),@wid nvarchar(100))
    as
    begin
     declare @i int,@j int,@sql nvarchar(4000),@dt datetime,@neweid varchar(100),@newwid varchar(100)
     declare @xq table(id int identity,x int,y int,v nvarchar(100))--下棋步骤,V表下棋者,用0和1表示
     declare @x int,@y int,@v nvarchar(100),@vsp varchar(100) --每次的下棋
     declare @vt int,@vt1 int,@vt2 int --下棋者的用时
     declare @js1 int,@js2 int,@js3 int,@js4 int --四个方向计数
     --初始化下棋步骤
     if @eid = @wid begin print '不支持自己打自己!' return end 
     if(object_id(@eid+'_xq') is  null) begin print '机器人:'+@eid+'不存在!!!' return end
     if(object_id(@wid+'_xq') is  null) begin print '机器人:'+@wid+'不存在!!!' return end
     --防作弊,改名
     select @neweid = left(newid(),8)
     if(object_id(@neweid) is not null) begin set @sql = 'drop proc ['+@neweid+']' exec(@sql) end
     set @sql = @eid+'_xq' exec sp_rename @sql,@neweid
     select @newwid = left(newid(),8)
     if(object_id(@newwid) is not null) begin set @sql = 'drop proc ['+@newwid+']' exec(@sql) end
     set @sql = @wid+'_xq' exec sp_rename @sql,@newwid if(object_id('xq') is not null) drop table xq 
     create table xq(id int identity,x int,y int,v nvarchar(100)) -- 用于传递给下棋者 --开始下棋
     select @i = 0,@vt = 300,@vt1 = 0,@vt2 = 0 --每人300秒
     while @i between 0 and 255
     begin
      --清理下棋步骤,获得当前下棋者
      delete xq
      insert xq(x,y,v) select x,y,v  from @xq
      select @v   = case @v when @eid then @wid else @eid end,@i = @i + 1
      select @vsp = case @v when @eid then @neweid else @newwid end
      --下棋
      select @sql='exec ['+@vsp+'] @x out,@y out',@dt=getdate()
      exec sp_executesql @sql,N'@x int  output,@y int output',@x=@x output,@y=@y output
      if @v = @eid set @vt1=@vt1+datediff(s,@dt,getdate()) else set @vt2 = @vt2+datediff(s,@dt,getdate())
      --判断超时
      if @vt1 >@vt or @vt2 >@vt begin  set @i=998 continue end
      --判断是否犯规
      if @x not between 1 and 16 or @y not between 1 and 16 or exists(select 1 from @xq where x= @x and y=@y)
      begin set @i=999 continue end
      --判断是否赢
      insert @xq select @x,@y,@v
      select @js1 =0,@js2 =0,@js3=0,@js4 = 0,@j = -5
      while @j <4
       BEGIN
        set @j = @j + 1
        if exists(select 1 from @xq where y=@y + @j and x = @x + @j and @v = v) set @js1 = @js1 + 1 else set @js1 = 0
        if exists(select 1 from @xq where y=@y + @j and x = @x      and @v = v) set @js2 = @js2 + 1 else set @js2 = 0
        if exists(select 1 from @xq where y=@y      and x = @x + @j and @v = v) set @js3 = @js3 + 1 else set @js3 = 0
        if exists(select 1 from @xq where y=@y - @j and x = @x - @j and @v = v) set @js4 = @js4 + 1 else set @js4 = 0
        if @js1 = 5 or @js2 = 5 or @js3 = 5 or @js4 =5 select @i = @i+1000,@j = @j + 100
       END
      end
      set @sql = @eid+'_xq' exec sp_rename @neweid,@sql
      set @sql = @wid+'_xq' exec sp_rename @newwid,@sql
      if @i = 998 begin print char(10)+'机器人:'+@v+'超时认输!'+rtrim(@x)+' '+rtrim(@y) return end
      if @i = 999 begin print char(10)+'机器人:'+@v+'落子犯规认输!'+rtrim(@x)+' '+rtrim(@y) return end
      if @i <1000 begin print @eid +' vs + '+@wid +' 平局!'  return end
      print char(10)+'  机器人:'+@v+' 在第'+rtrim(@i-1000)+'手时获胜!'
      print '┏┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┓'
      select @i = 0,@j = @j - 100
      while @i <16
      begin
       select @i = @i +1,@sql = '┣',@j=0
       while @j <16
       begin 
        select @j = @j +1,@v = -1
        select @v = v from @xq where x= @j and y = @i
        if @i= @y and @j = @x
              select @sql = @sql + case @v  when @eid then '○' when @wid then '□' else '╋' end
        else  select @sql = @sql + case @v  when @eid then '●' when @wid then '■' else '╋' end
       end
       print @sql+'┫'
      end
      print '┗┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┛'
    end
    go
      

  8.   

    随机落子,竟然屡战屡胜!
    if(object_id('killer_xq') is not null) drop procedure killer_xq
    go
    create procedure killer_xq(@x int output,@y int output)
    as
    begin
    declare @xq table(x int, y int, v nvarchar(100))
     
    declare @x1 int,@y1 int
    select @x1=1
    while @x1<=8
    begin
    set @y1=1
    while @y1<=8 
    begin
    insert @xq(x,y) select @x1,@y1
    set @y1=@y1+1
    end
    set @x1=@x1+1
    end select @x=x, @y=y from @xq T
    where not exists(select 1 from xq where xq.x=T.x and xq.y=T.y)
    order by newid()

    print 'I will kill all the robots!'
    end
    go
      

  9.   

    exec five 'killer','cson2'
    /*
      机器人:killer 在第63手时获胜!
    ┏┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┓
    ┣●■■●■■●╋╋╋╋╋╋╋╋╋┫
    ┣■■●■●●●■■╋╋╋╋╋╋╋┫
    ┣■●■■●■■╋╋╋╋╋╋╋╋╋┫
    ┣╋●╋╋●●■╋╋╋╋╋╋╋╋╋┫
    ┣■●●●■●●●╋╋╋╋╋╋╋╋┫
    ┣■●■●●●●○╋╋╋╋╋╋╋╋┫
    ┣■■●●■╋●╋■╋╋╋╋╋╋╋┫
    ┣■●■●●■●●╋╋╋╋╋╋╋╋┫
    ┣╋■╋╋■╋╋■╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋■╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣■╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┗┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┛
      机器人:killer 在第59手时获胜!
    ┏┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┓
    ┣■■●■■■●■╋╋╋╋╋╋╋╋┫
    ┣●●■■╋●●■╋╋╋╋╋╋╋╋┫
    ┣●■■●●●■●╋╋╋╋╋╋╋╋┫
    ┣■●■●╋●╋●╋╋╋╋╋╋╋╋┫
    ┣●●■■●■╋●╋╋╋╋╋╋╋╋┫
    ┣■■●●■■╋●╋■╋╋╋╋╋╋┫
    ┣■●■■╋●●■╋╋╋╋╋╋╋╋┫
    ┣■■○●●●●■╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┗┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┛
      机器人:killer 在第77手时获胜!
    ┏┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┓
    ┣■●●■■●●●■╋╋╋╋╋╋╋┫
    ┣●■■■●●●●■■╋╋╋╋╋╋┫
    ┣●●●■■○■●╋╋╋╋╋╋╋╋┫
    ┣■■■●●●■●■╋╋╋╋╋╋╋┫
    ┣●●■●●●●■╋╋╋╋╋╋╋╋┫
    ┣■■●■■●●●■╋╋╋╋╋╋╋┫
    ┣■●■●●●■■╋╋╋╋╋╋╋╋┫
    ┣●■●●●■●●╋■╋╋╋╋╋╋┫
    ┣■╋╋■╋■╋■╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋■╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣■╋╋╋╋╋╋■╋╋╋╋╋╋╋╋┫
    ┗┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┛  机器人:killer 在第51手时获胜!
    ┏┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┓
    ┣■■●●■●╋■╋╋╋╋╋╋╋╋┫
    ┣■●■●╋●■■╋╋╋╋╋╋╋╋┫
    ┣●■■■╋●●■╋╋╋╋╋╋╋╋┫
    ┣■■●●●■■●╋╋╋╋╋╋╋╋┫
    ┣■●╋╋●●■●╋╋╋╋╋╋╋╋┫
    ┣●╋●╋╋■●●╋■╋╋╋╋╋╋┫
    ┣╋╋╋■●╋╋●╋╋■╋╋╋╋╋┫
    ┣●╋╋╋╋●╋○■╋╋╋╋╋╋╋┫
    ┣╋■╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋■╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┗┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┛  机器人:killer 在第45手时获胜!
    ┏┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┓
    ┣■╋■╋╋■■■╋╋╋╋╋╋╋╋┫
    ┣■╋╋■■╋╋●╋╋╋╋╋╋╋╋┫
    ┣●■●●■●╋●╋╋╋╋╋╋╋╋┫
    ┣●■╋╋╋●╋●╋╋╋╋╋╋╋╋┫
    ┣■■■╋╋●●■╋╋╋╋╋╋╋╋┫
    ┣●●○●●╋╋●╋╋╋╋╋╋╋╋┫
    ┣●╋╋╋●╋╋●╋╋╋╋╋╋╋╋┫
    ┣╋■■■╋●●●╋■╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋■╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋■╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋■╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┗┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┛
    */
      

  10.   

    看来先落子还是有很大的优势,我的机器人先落子时,赢的概率很大,后落子则要小一些,,,
    exec five 'cson2', 'killer'
    /*
      机器人:killer 在第58手时获胜!
    ┏┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┓
    ┣●●●●■■●●●╋╋╋╋╋╋╋┫
    ┣■●╋●╋●●■╋╋╋╋╋╋╋╋┫
    ┣●●●■■■●■╋╋╋╋╋╋╋╋┫
    ┣●╋●■╋╋■●╋╋╋╋╋╋╋╋┫
    ┣●■■■●■●■╋╋╋╋╋╋╋╋┫
    ┣●■●■■■╋●╋╋╋╋╋╋╋╋┫
    ┣■╋■□╋■■■╋╋╋╋╋╋╋╋┫
    ┣●●■●╋■■■╋╋╋╋╋╋╋╋┫
    ┣╋╋●╋╋╋╋●╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┗┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┛
      机器人:killer 在第70手时获胜!
    ┏┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┓
    ┣●●■■●●●■╋╋╋╋╋╋╋╋┫
    ┣■■■●●●●■╋╋╋╋╋╋╋╋┫
    ┣●■●●●■■●●╋╋╋╋╋╋╋┫
    ┣╋■●■■■●■╋╋╋╋╋╋╋╋┫
    ┣╋■●■■■■●╋╋╋╋╋╋╋╋┫
    ┣●●■╋□■■■╋╋╋╋╋╋╋╋┫
    ┣●■■■■●■■╋╋╋╋╋╋╋╋┫
    ┣●●■●■■■●╋╋╋╋╋╋╋╋┫
    ┣╋●╋╋╋╋●●●╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋●╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋●╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣●╋╋╋╋╋╋●╋╋╋╋╋╋╋╋┫
    ┗┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┛
     
      机器人:cson2 在第45手时获胜!
    ┏┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┓
    ┣●●●●■╋╋■╋╋╋╋╋╋╋╋┫
    ┣╋╋■●╋●╋╋╋╋╋╋╋╋╋╋┫
    ┣■●■●●■●╋╋╋╋╋╋╋╋╋┫
    ┣╋●●●╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣●■●○■■■╋╋╋╋╋╋╋╋╋┫
    ┣●■●╋■╋╋■╋╋╋╋╋╋╋╋┫
    ┣■■■●╋■■╋╋╋╋╋╋╋╋╋┫
    ┣●●■■●╋■■╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋●╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┗┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┛   机器人:cson2 在第31手时获胜!
    ┏┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┳┓
    ┣●●■╋●■╋╋╋╋╋╋╋╋╋╋┫
    ┣●╋●○●●●╋╋╋╋╋╋╋╋╋┫
    ┣╋●╋╋╋■■╋╋╋╋╋╋╋╋╋┫
    ┣●●■╋■╋╋■╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋■■╋●╋╋╋╋╋╋╋╋┫
    ┣●╋╋╋╋╋■╋╋╋╋╋╋╋╋╋┫
    ┣●■╋■╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋■●╋╋■╋■╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┣╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋╋┫
    ┗┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┻┛
    */
      

  11.   

    高端软件技术,建议大家可以去看看:http://www.ciitc.com