用ASP实现网上"五子棋"大赛

“五子棋”是大家都非常熟悉的一种益智类游戏,相关的游戏软件也非常多,在此我向大家隆重推出一款新的纯“网络版”的五子棋,它利用ASP做为开发环境,因此在Internet上对战的时候无需下载客户端软件,只要你有一个浏览器就可以了。你也可以在局域网上进行这个游戏。

对于ASP,我不想做过多的说明,在以前的文章中,我已经说过很多。

游戏的过程是这样的,我们首先登录,然后可以选择战场,有“金星”、“木星”、“水星”、“火星”、“土星”等五个战场,如果你自认为是一个高手,可以选择金星,否则可以依次选择其它几个星球做为战场。如果这个星球上没有擂主,你就应该以擂主的身份进入,然后别人就可以和你进行对战了。当然,如果所有的星球上都已经开始了战争,那么你就只能等一会儿了。

如果你是以擂主身份进入的,你可以等待别人来和你对战,如果你是以攻擂手的身份登录,你可以很快的和擂主展开战斗。开始战斗后,由擂主执黑先行,然后由攻擂手出招,如此这般。当最后决出胜负的时候,会有相应的提示。

该站点有几个主要的文件是:

Index.asp 登录文件:

Index0.asp中间文件:

Match.asp 比赛文件:

Back0.jpg white0.jpg black0.jpg 中间用到的图形文件,分别指的棋盘,白子和黑子,如下图:

在程序的初始化的时候,将棋盘上分成若干的表格,将背景图片放入其中,形成一个棋盘,然后在放上一个棋子后,再将图片换上相应的白子或黑子就可以了。

先看看登录文件:

<%@ Language=VBScript %>

<HTML>

<HEAD>

<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">

<title>星球大战之“五子连珠”大赛!</title>

</HEAD>

<BODY>

<p align=center><font size=6>星球大战</font></P>

<table border=1 width=80% align=center>

<tr><td>星球</td><td>擂主</td><td>大战</td><td>攻擂</td></tr>

<tr>

<td>金星</td>

<td>

<%

if application("first1")="" then

%>

<form action=index0.asp?flag=First1 method=post>

<INPUT id=text1 name=txtFirst1 size=10><INPUT id=submit1 name=submit1

type=submit value=进入>

</form>

<%

else

response.write application("first1")

end if

%>

</td>

<td>大战</td>

<td>

<%

if application("second1")="" then

%>

<form action=index0.asp?flag=second1 method=post>

<INPUT id=text1 name=txtSecond1 size=10><INPUT id=submit1

name=submit1 type=submit value=进入>

</form>

<%

else

response.write application("Second1")

end if

%>

</td>

</tr>

<tr>

<td>木星</td>

<td>

<%

if application("first2")="" then

%>

<form action=index0.asp?flag=First2 method=post>

<INPUT id=text1 name=txtFirst2 size=10><INPUT id=submit1 name=submit1

type=submit value=进入>

</form>

<%

else

response.write application("first2")

end if

%>

</td>

<td>大战</td>

<td>

<%

if application("second2")="" then

%>

<form action=index0.asp?flag=second2 method=post>

<INPUT id=text1 name=txtSecond2 size=10><INPUT id=submit1

name=submit1 type=submit value=进入>

</form>

<%

else

response.write application("Second2")

end if

%>

</td>

</tr>

<tr>

<td>金星</td>

<td>

<%

if application("first3")="" then

%>

<form action=index0.asp?flag=First3 method=post>

<INPUT id=text1 name=txtFirst3 size=10><INPUT id=submit1 name=submit1

type=submit value=进入>

</form>

<%

else

response.write application("first3")

end if

%>

</td>

<td>大战</td>

<td>

<%

if application("second3")="" then

%>

<form action=index0.asp?flag=second3 method=post>

<INPUT id=text1 name=txtSecond3 size=10><INPUT id=submit1

name=submit1 type=submit value=进入>

</form>

<%

else

response.write application("Second3")

end if

%>

</td>

</tr>

<tr>

<td>金星</td>

<td>

<%

if application("first4")="" then

%>

<form action=index0.asp?flag=First4 method=post>

<INPUT id=text1 name=txtFirst4 size=10><INPUT id=submit1 name=submit1

type=submit value=进入>

</form>

<%

else

response.write application("first4")

end if

%>

</td>

<td>大战</td>

<td>

<%

if application("second4")="" then

%>

<form action=index0.asp?flag=second4 method=post>

<INPUT id=text1 name=txtSecond4 size=10><INPUT id=submit1

name=submit1 type=submit value=进入>

</form>

<%

else

response.write application("Second4")

end if

%>

</td>

</tr>

<tr>

<td>金星</td>

<td>

<%

if application("first5")="" then

%>

<form action=index0.asp?flag=First5 method=post>

<INPUT id=text1 name=txtFirst5 size=10><INPUT id=submit1 name=submit1

type=submit value=进入>

</form>

<%

else

response.write application("first5")

end if

%>

</td>

<td>大战</td>

<td>

<%

if application("second5")="" then

%>

<form action=index0.asp?flag=second5 method=post>

<INPUT id=text1 name=txtSecond5 size=10><INPUT id=submit1

name=submit1 type=submit value=进入>

</form>

<%

else

response.write application("Second5")

end if

%>

</td>

</tr> 

</table>

</BODY>

</HTML>

这个文件不用做过多的说明,就是一个大的表格,大家可以从那里进入,如果某个位置已经被使用,则它会变成该大 侠的名字,不允许重复登录。在登录后进入

index0.asp,这是一个中间交换文件,在里面进行一些变量的处理及赋值,然后再进入match.asp,进行正式的比赛。我们来看一下index0.asp的内容:

<%@ Language=VBScript %>

<%

if Request.Form("txt" & request.querystring("flag"))<>"" then

'response.write "in!" & ""

session("nice")=Request.Form("txt" & request.querystring("flag"))

'response.write session("nice") & ""

'response.write application(request.querystring("flag"))

if application(request.querystring("flag"))="" then

application(request.querystring("flag"))=session("nice")

session("class")=right(request.querystring("flag"),1)

if left(request.querystring("flag"),1)="f" then

application(session("nice"))=false

elseif left(request.querystring("flag"),1)="s" then

application(session("nice"))=false

application(application("first" & session("class")))=true

end if

Response.Redirect "match.asp"

end if

 

end if

%>

<HTML>

</HTML>

该程序中,用session(“nice”)来记录您登录的大名,以后的处理中,很多都要用到它,用它来区分很多的用户。如果您是从擂主的位置进入,则您的权利是

first,否则是second,用session("class")来记录位于哪个战场场,“金”“木”

“水”“火”“土”分别表示为1、2、3、4、5,因为有多个战场可能同时开战,如果不能正确地区分开,则可能导致一片混乱。application(session("nice"))是一个逻辑型变量,用真假来表示您是否可以出棋,如果是假,您要等待一个,如果是真,您就可以下棋了。只有一个战场上的两个人都进入了以后,擂主方可以下棋,而且只有当擂主出子以后,攻擂手才可以下棋。准备好以后,下面就进入赛场,请看文件match.asp

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<meta name="GENERATOR" content="Microsoft FrontPage 4.0">

<meta name="ProgId" content="FrontPage.Editor.Document">

<META http-equiv=refresh content=3>

<title>连珠大赛...</title>

</head>

<%

Response.Write "擂主:" & application("first" & session("class"))

& "    攻擂:" & application("second" & session

("class"))

if Request.QueryString("pos")<>"" then

application("pos" & session("class") & Request.QueryString("pos"))

=true

end if

%>

<body>

<%

'Response.Write application("aaa")

if application("first" & session("class"))=session("nice") then

color="black"

if Request.QueryString("pos")<>"" then

if session("last")="" then session("last")="abc"

if session("last")<> Request.QueryString("pos") then

application(application("first" & session("class")))=false

if application("second" & session("class"))<>"" then application

(application("second" & session("class")))=true

session("last")=Request.QueryString("pos")

END IF

end if

else

if application("second" & session("class"))=session("nice") then

color="white"

if Request.QueryString("pos")<>"" then

'if session("last")="" then session("last")="abc"

if session("last")<> Request.QueryString("pos") then

application(application("first" & session("class")))=true

application(application("second" & session("class")))=false

session("last")=Request.QueryString("pos")

END IF

end if

else

if application("second" & session("class"))="" then

application("second" & session("class"))=session("nice")

color="white"

if Request.QueryString("pos")<>"" then

if session("last")="" then session("last")="abc"

if session("last")<> Request.QueryString("pos") then

application(application("first" & session("class")))=true

application(application("second" & session("class")))=false

session("last")=Request.QueryString("pos")

END IF

end if

else

color=""

end if

end if

end if

Response.Write "<table width=400 height=400 border=0 cellspacing=0

cellpadding=0>"

for i=1 to 16

Response.Write "<tr>"

for j=1 to 16

if application("pos" & session("class") & cstr(i) & "_" & cstr(j))=""

then

application("color" & session("class") & "_" & Request.QueryString

("pos"))=color

Response.Write "<td width=25 height=25>"

'response.write application(application("first" & session("class")))

if application(session("nice"))=true then

response.write "<a href=match.asp?pos=" & cstr(i) & "_" & cstr(j)

& "><img border=0 src=back0.jpg width=25 height=25></a>"

else

response.write "<img border=0 src=back0.jpg width=25 height=25>"

end if

response.write "</td>"

else

Response.Write "<td width=25 height=25><img border=0 src=" &

application("color" & session("class") & "_" & cstr(i) & "_" & cstr

(j)) & "0.jpg width=25 height=25></td>" & chr(13)

end if

next

Response.Write "</tr>"

next

Response.Write "</table>"

'判断输赢

if application("first" & session("class"))=session("nice") then

m="black"

h="white"

else

h="black"

m="white"

end if

'横向判断"-"

for i=1 to 15

win=false

loss=false

five_me=0

five_he=0

for j=1 to 15

if application("color" & session("class") & "_" & cstr(i) & "_" & cstr

(j))=m then

five_me=five_me+1

five_he=0

elseif application("color" & session("class") & "_" & cstr(i) & "_" &

cstr(j))=h then

five_me=0

five_he=five_he+1

else

five_me=0

five_he=0

end if

if five_me=5 then

win=true

loss=false

exit for

elseif five_he=5 then

win=false

loss=true

exit for

end if

next

if win or loss then exit for

next

if win then

response.write "你赢了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

if loss then

response.write "对不起,你输了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

'列向判断"|"

for j=1 to 15

win=false

loss=false

five_me=0

five_he=0

for i=1 to 15

if application("color" & session("class") & "_" & cstr(i) & "_" & cstr

(j))=m then

five_me=five_me+1

five_he=0

elseif application("color" & session("class") & "_" & cstr(i) & "_" &

cstr(j))=h then

five_me=0

five_he=five_he+1

else

five_me=0

five_he=0

end if

if five_me=5 then

win=true

loss=false

exit for

elseif five_he=5 then

win=false

loss=true

exit for

end if

next

if win or loss then exit for

next

if win then

response.write "你赢了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

if loss then

response.write "对不起,你输了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

'斜向判断"/"

for i=1 to 11

win=false

loss=false

five_me=0

five_he=0

for j=i+4 to 1 step -1

if application("color" & session("class") & "_" & cstr(j) & "_" & cstr

(i+5-j))=m then

five_me=five_me+1

five_he=0

elseif application("color" & session("class") & "_" & cstr(j) & "_" &

cstr(i+5-j))=h then

five_me=0

five_he=five_he+1

else

five_me=0

five_he=0

end if

if five_me=5 then

win=true

loss=false

exit for

elseif five_he=5 then

win=false

loss=true

exit for

end if

next

if win or loss then exit for

next

if win then

response.write "你赢了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

if loss then

response.write "对不起,你输了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

'斜向判断""

for i=1 to 11

win=false

loss=false

five_me=0

five_he=0

for j=12-i to 15

if application("color" & session("class") & "_" & cstr(13-i-j) & "_"

& cstr(j))=m then

five_me=five_me+1

five_he=0

elseif application("color" & session("class") & "_" & cstr(13-i-j)

& "_" & cstr(j))=h then

five_me=0

five_he=five_he+1

else

five_me=0

five_he=0

end if

if five_me=5 then

win=true

loss=false

exit for

elseif five_he=5 then

win=false

loss=true

exit for

end if

next

if win or loss then exit for

next

if win then

response.write "你赢了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

if loss then

response.write "对不起,你输了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

%>

</body>

</html>

如果某点没有棋子,则加上一个超连接,根据擂主与攻擂手的区别放上一个不同颜色的棋子。最后的一段是用来判断输与赢,分为横,列和两个斜线方向。具体内容看一下就可以明白。

最后要说的一点就是global.asa ,这是站点上的一个核心文件,为了在退出棋局后,将位置留给别人,需要在sesison_onend中加入代码进行处理,如下:

<script language=vbscript runat = server>

sub application_onstart

session.timeout=1

end sub

sub session_onstart

if application("num")="" then

application("num")=0

end if

application("num")=application("num")+1

end sub

</script>

<script language=vbscript runat = server>

sub session_onend

if application("num")="" then

application("num")=0

end if

application("num")=application("num")-1

if application("first1")=session("nice") then

application("first1")=""

elseif application("second1")=session("nice") then

application("second1")=""

elseif application("first2")=session("nice") then

application("first2")=""

elseif application("second2")=session("nice") then

application("second2")=""

elseif application("first3")=session("nice") then

application("first3")=""

elseif application("second3")=session("nice") then

application("second3")=""

elseif application("first4")=session("nice") then

application("first4")=""

elseif application("second4")=session("nice") then

application("second4")=""

elseif application("first5")=session("nice") then

application("first5")=""

elseif application("second5")=session("nice") then

application("second5")=""

end if

for i=1 to 15

for j=1 to 15

application("color" & session("class") & "_" & cstr(i) & "_" & cstr

(J))=""

application("pos" & session("class") & cstr(i) & "_" & cstr(j))=""

next

next

application(session("nice"))=""

end sub

</script>

以上就是几个主要的文件,大家可以一试。什么,想做围棋?把棋盘改一下就可以了。

以上是三联网为您介绍的用ASP实现网上“五子棋”大赛,希望对您有所帮助。

“五子棋”是大家都非常熟悉的一种益智类游戏,相关的游戏软件也非常多,在此我向大家隆重推出一款新的纯“网络版”的五子棋,它利用ASP做为开发环境,因此在Internet上对战的时候无需下载客户端软件,只要你有一个浏览器就可以了。你也可以在局域网上进行这个游戏。

对于ASP,我不想做过多的说明,在以前的文章中,我已经说过很多。

游戏的过程是这样的,我们首先登录,然后可以选择战场,有“金星”、“木星”、“水星”、“火星”、“土星”等五个战场,如果你自认为是一个高手,可以选择金星,否则可以依次选择其它几个星球做为战场。如果这个星球上没有擂主,你就应该以擂主的身份进入,然后别人就可以和你进行对战了。当然,如果所有的星球上都已经开始了战争,那么你就只能等一会儿了。

如果你是以擂主身份进入的,你可以等待别人来和你对战,如果你是以攻擂手的身份登录,你可以很快的和擂主展开战斗。开始战斗后,由擂主执黑先行,然后由攻擂手出招,如此这般。当最后决出胜负的时候,会有相应的提示。

该站点有几个主要的文件是:

Index.asp 登录文件:

Index0.asp中间文件:

Match.asp 比赛文件:

Back0.jpg white0.jpg black0.jpg 中间用到的图形文件,分别指的棋盘,白子和黑子,如下图:

在程序的初始化的时候,将棋盘上分成若干的表格,将背景图片放入其中,形成一个棋盘,然后在放上一个棋子后,再将图片换上相应的白子或黑子就可以了。

先看看登录文件:

<%@ Language=VBScript %>

<HTML>

<HEAD>

<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">

<title>星球大战之“五子连珠”大赛!</title>

</HEAD>

<BODY>

<p align=center><font size=6>星球大战</font></P>

<table border=1 width=80% align=center>

<tr><td>星球</td><td>擂主</td><td>大战</td><td>攻擂</td></tr>

<tr>

<td>金星</td>

<td>

<%

if application("first1")="" then

%>

<form action=index0.asp?flag=First1 method=post>

<INPUT id=text1 name=txtFirst1 size=10><INPUT id=submit1 name=submit1

type=submit value=进入>

</form>

<%

else

response.write application("first1")

end if

%>

</td>

<td>大战</td>

<td>

<%

if application("second1")="" then

%>

<form action=index0.asp?flag=second1 method=post>

<INPUT id=text1 name=txtSecond1 size=10><INPUT id=submit1

name=submit1 type=submit value=进入>

</form>

<%

else

response.write application("Second1")

end if

%>

</td>

</tr>

<tr>

<td>木星</td>

<td>

<%

if application("first2")="" then

%>

<form action=index0.asp?flag=First2 method=post>

<INPUT id=text1 name=txtFirst2 size=10><INPUT id=submit1 name=submit1

type=submit value=进入>

</form>

<%

else

response.write application("first2")

end if

%>

</td>

<td>大战</td>

<td>

<%

if application("second2")="" then

%>

<form action=index0.asp?flag=second2 method=post>

<INPUT id=text1 name=txtSecond2 size=10><INPUT id=submit1

name=submit1 type=submit value=进入>

</form>

<%

else

response.write application("Second2")

end if

%>

</td>

</tr>

<tr>

<td>金星</td>

<td>

<%

if application("first3")="" then

%>

<form action=index0.asp?flag=First3 method=post>

<INPUT id=text1 name=txtFirst3 size=10><INPUT id=submit1 name=submit1

type=submit value=进入>

</form>

<%

else

response.write application("first3")

end if

%>

</td>

<td>大战</td>

<td>

<%

if application("second3")="" then

%>

<form action=index0.asp?flag=second3 method=post>

<INPUT id=text1 name=txtSecond3 size=10><INPUT id=submit1

name=submit1 type=submit value=进入>

</form>

<%

else

response.write application("Second3")

end if

%>

</td>

</tr>

<tr>

<td>金星</td>

<td>

<%

if application("first4")="" then

%>

<form action=index0.asp?flag=First4 method=post>

<INPUT id=text1 name=txtFirst4 size=10><INPUT id=submit1 name=submit1

type=submit value=进入>

</form>

<%

else

response.write application("first4")

end if

%>

</td>

<td>大战</td>

<td>

<%

if application("second4")="" then

%>

<form action=index0.asp?flag=second4 method=post>

<INPUT id=text1 name=txtSecond4 size=10><INPUT id=submit1

name=submit1 type=submit value=进入>

</form>

<%

else

response.write application("Second4")

end if

%>

</td>

</tr>

<tr>

<td>金星</td>

<td>

<%

if application("first5")="" then

%>

<form action=index0.asp?flag=First5 method=post>

<INPUT id=text1 name=txtFirst5 size=10><INPUT id=submit1 name=submit1

type=submit value=进入>

</form>

<%

else

response.write application("first5")

end if

%>

</td>

<td>大战</td>

<td>

<%

if application("second5")="" then

%>

<form action=index0.asp?flag=second5 method=post>

<INPUT id=text1 name=txtSecond5 size=10><INPUT id=submit1

name=submit1 type=submit value=进入>

</form>

<%

else

response.write application("Second5")

end if

%>

</td>

</tr> 

</table>

</BODY>

</HTML>

这个文件不用做过多的说明,就是一个大的表格,大家可以从那里进入,如果某个位置已经被使用,则它会变成该大 侠的名字,不允许重复登录。在登录后进入

index0.asp,这是一个中间交换文件,在里面进行一些变量的处理及赋值,然后再进入match.asp,进行正式的比赛。我们来看一下index0.asp的内容:

<%@ Language=VBScript %>

<%

if Request.Form("txt" & request.querystring("flag"))<>"" then

'response.write "in!" & ""

session("nice")=Request.Form("txt" & request.querystring("flag"))

'response.write session("nice") & ""

'response.write application(request.querystring("flag"))

if application(request.querystring("flag"))="" then

application(request.querystring("flag"))=session("nice")

session("class")=right(request.querystring("flag"),1)

if left(request.querystring("flag"),1)="f" then

application(session("nice"))=false

elseif left(request.querystring("flag"),1)="s" then

application(session("nice"))=false

application(application("first" & session("class")))=true

end if

Response.Redirect "match.asp"

end if

 

end if

%>

<HTML>

</HTML>

该程序中,用session(“nice”)来记录您登录的大名,以后的处理中,很多都要用到它,用它来区分很多的用户。如果您是从擂主的位置进入,则您的权利是

first,否则是second,用session("class")来记录位于哪个战场场,“金”“木”

“水”“火”“土”分别表示为1、2、3、4、5,因为有多个战场可能同时开战,如果不能正确地区分开,则可能导致一片混乱。application(session("nice"))是一个逻辑型变量,用真假来表示您是否可以出棋,如果是假,您要等待一个,如果是真,您就可以下棋了。只有一个战场上的两个人都进入了以后,擂主方可以下棋,而且只有当擂主出子以后,攻擂手才可以下棋。准备好以后,下面就进入赛场,请看文件match.asp

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<meta name="GENERATOR" content="Microsoft FrontPage 4.0">

<meta name="ProgId" content="FrontPage.Editor.Document">

<META http-equiv=refresh content=3>

<title>连珠大赛...</title>

</head>

<%

Response.Write "擂主:" & application("first" & session("class"))

& "    攻擂:" & application("second" & session

("class"))

if Request.QueryString("pos")<>"" then

application("pos" & session("class") & Request.QueryString("pos"))

=true

end if

%>

<body>

<%

'Response.Write application("aaa")

if application("first" & session("class"))=session("nice") then

color="black"

if Request.QueryString("pos")<>"" then

if session("last")="" then session("last")="abc"

if session("last")<> Request.QueryString("pos") then

application(application("first" & session("class")))=false

if application("second" & session("class"))<>"" then application

(application("second" & session("class")))=true

session("last")=Request.QueryString("pos")

END IF

end if

else

if application("second" & session("class"))=session("nice") then

color="white"

if Request.QueryString("pos")<>"" then

'if session("last")="" then session("last")="abc"

if session("last")<> Request.QueryString("pos") then

application(application("first" & session("class")))=true

application(application("second" & session("class")))=false

session("last")=Request.QueryString("pos")

END IF

end if

else

if application("second" & session("class"))="" then

application("second" & session("class"))=session("nice")

color="white"

if Request.QueryString("pos")<>"" then

if session("last")="" then session("last")="abc"

if session("last")<> Request.QueryString("pos") then

application(application("first" & session("class")))=true

application(application("second" & session("class")))=false

session("last")=Request.QueryString("pos")

END IF

end if

else

color=""

end if

end if

end if

Response.Write "<table width=400 height=400 border=0 cellspacing=0

cellpadding=0>"

for i=1 to 16

Response.Write "<tr>"

for j=1 to 16

if application("pos" & session("class") & cstr(i) & "_" & cstr(j))=""

then

application("color" & session("class") & "_" & Request.QueryString

("pos"))=color

Response.Write "<td width=25 height=25>"

'response.write application(application("first" & session("class")))

if application(session("nice"))=true then

response.write "<a href=match.asp?pos=" & cstr(i) & "_" & cstr(j)

& "><img border=0 src=back0.jpg width=25 height=25></a>"

else

response.write "<img border=0 src=back0.jpg width=25 height=25>"

end if

response.write "</td>"

else

Response.Write "<td width=25 height=25><img border=0 src=" &

application("color" & session("class") & "_" & cstr(i) & "_" & cstr

(j)) & "0.jpg width=25 height=25></td>" & chr(13)

end if

next

Response.Write "</tr>"

next

Response.Write "</table>"

'判断输赢

if application("first" & session("class"))=session("nice") then

m="black"

h="white"

else

h="black"

m="white"

end if

'横向判断"-"

for i=1 to 15

win=false

loss=false

five_me=0

five_he=0

for j=1 to 15

if application("color" & session("class") & "_" & cstr(i) & "_" & cstr

(j))=m then

five_me=five_me+1

five_he=0

elseif application("color" & session("class") & "_" & cstr(i) & "_" &

cstr(j))=h then

five_me=0

five_he=five_he+1

else

five_me=0

five_he=0

end if

if five_me=5 then

win=true

loss=false

exit for

elseif five_he=5 then

win=false

loss=true

exit for

end if

next

if win or loss then exit for

next

if win then

response.write "你赢了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

if loss then

response.write "对不起,你输了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

'列向判断"|"

for j=1 to 15

win=false

loss=false

five_me=0

five_he=0

for i=1 to 15

if application("color" & session("class") & "_" & cstr(i) & "_" & cstr

(j))=m then

five_me=five_me+1

five_he=0

elseif application("color" & session("class") & "_" & cstr(i) & "_" &

cstr(j))=h then

five_me=0

five_he=five_he+1

else

five_me=0

five_he=0

end if

if five_me=5 then

win=true

loss=false

exit for

elseif five_he=5 then

win=false

loss=true

exit for

end if

next

if win or loss then exit for

next

if win then

response.write "你赢了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

if loss then

response.write "对不起,你输了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

'斜向判断"/"

for i=1 to 11

win=false

loss=false

five_me=0

five_he=0

for j=i+4 to 1 step -1

if application("color" & session("class") & "_" & cstr(j) & "_" & cstr

(i+5-j))=m then

five_me=five_me+1

five_he=0

elseif application("color" & session("class") & "_" & cstr(j) & "_" &

cstr(i+5-j))=h then

five_me=0

five_he=five_he+1

else

five_me=0

five_he=0

end if

if five_me=5 then

win=true

loss=false

exit for

elseif five_he=5 then

win=false

loss=true

exit for

end if

next

if win or loss then exit for

next

if win then

response.write "你赢了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

if loss then

response.write "对不起,你输了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

'斜向判断""

for i=1 to 11

win=false

loss=false

five_me=0

five_he=0

for j=12-i to 15

if application("color" & session("class") & "_" & cstr(13-i-j) & "_"

& cstr(j))=m then

five_me=five_me+1

five_he=0

elseif application("color" & session("class") & "_" & cstr(13-i-j)

& "_" & cstr(j))=h then

five_me=0

five_he=five_he+1

else

five_me=0

five_he=0

end if

if five_me=5 then

win=true

loss=false

exit for

elseif five_he=5 then

win=false

loss=true

exit for

end if

next

if win or loss then exit for

next

if win then

response.write "你赢了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

if loss then

response.write "对不起,你输了!"

application(application("first" & session("class")))=false

application(application("second" & session("class")))=false

end if

%>

</body>

</html>

如果某点没有棋子,则加上一个超连接,根据擂主与攻擂手的区别放上一个不同颜色的棋子。最后的一段是用来判断输与赢,分为横,列和两个斜线方向。具体内容看一下就可以明白。

最后要说的一点就是global.asa ,这是站点上的一个核心文件,为了在退出棋局后,将位置留给别人,需要在sesison_onend中加入代码进行处理,如下:

<script language=vbscript runat = server>

sub application_onstart

session.timeout=1

end sub

sub session_onstart

if application("num")="" then

application("num")=0

end if

application("num")=application("num")+1

end sub

</script>

<script language=vbscript runat = server>

sub session_onend

if application("num")="" then

application("num")=0

end if

application("num")=application("num")-1

if application("first1")=session("nice") then

application("first1")=""

elseif application("second1")=session("nice") then

application("second1")=""

elseif application("first2")=session("nice") then

application("first2")=""

elseif application("second2")=session("nice") then

application("second2")=""

elseif application("first3")=session("nice") then

application("first3")=""

elseif application("second3")=session("nice") then

application("second3")=""

elseif application("first4")=session("nice") then

application("first4")=""

elseif application("second4")=session("nice") then

application("second4")=""

elseif application("first5")=session("nice") then

application("first5")=""

elseif application("second5")=session("nice") then

application("second5")=""

end if

for i=1 to 15

for j=1 to 15

application("color" & session("class") & "_" & cstr(i) & "_" & cstr

(J))=""

application("pos" & session("class") & cstr(i) & "_" & cstr(j))=""

next

next

application(session("nice"))=""

end sub

</script>

以上就是几个主要的文件,大家可以一试。什么,想做围棋?把棋盘改一下就可以了。

以上是三联网为您介绍的用ASP实现网上“五子棋”大赛,希望对您有所帮助。


相关内容

  • N多毕业设计题目
  • 基于Ajax技术的WEB应用的设计 又快到毕业的时候了,大家该准备做毕业设计了.大学问问特意收集了一些毕业设计(论文)的题目,供大家选择. VB售楼管理系统 VB无纸化考试系统 VB小区物业管理系统 VB航空公司管理信息系统 VB计算机机房管理系统 VB房地产评估系统VB+SQL2000 VB光盘信 ...

  • 学习英语的软件
  • 看到很多朋友在网上苦苦寻找学习英语的软件,本人不才平时有收集软件的癖好外加由于偶然的机会混进外企已然三年,但是英语差一直未能获得更高的发展,所以一直在努力提高英语水平,积攒了不少英语学习软件.自用后感觉颇有效果. 今天整理了一下贡献给大家,给大家推荐八十款英语学习软件,其中有练习口语的,有练习听力的 ...

  • web前端研发工程师-简历示例
  • 服桥 凛言苯挖喻仟 质剃魔泊哟 济虏振冶水妓 闭家铆雄饰 议阑糠惮掌牡 教绸矿弯故 涎蜡慢趋抗 彭冕陷蜜闭各 枕格凛西御 股尊拥席泞锥 搜智虫阔酸 跪曝遮气锻控 僻唆喂殷俺 糟点英脾拈褐 番蓟话勤岩 药蒸滩桩喉胜 镇碌逃井遮 健抑仆轴黄 酒靴巍寄蹦乃 影匪学娄光 歉矽爱刃纷藕 嗽比落哈粗 呆淬楷婶沟 ...

  • 博睿棋牌社活动策划书
  • "大国手"深圳职业技术学院 棋类大赛 策 划 书 博睿棋牌协会 一. 活动背景 中国文化人历来推崇艺术素养的琴.棋.书.画.棋在其中占据了独特的地位.棋作为体育项目之一,也是随着国运的变动而起起伏伏.陈毅元帅说过:"国运昌,棋运盛."如今中国进步发展了,在大家 ...

  • 电子竞技大赛策划书
  • 一.活动名称:海洋与环境学院电子竞技大赛 二.活动目的与活动背景:随着电脑和因特网的普及,依靠网络进行的电子竞技作为一项新兴体育活动已经在全球范围内迅猛发展.当今,电子竞技已经成为一项世界性的竞技项目. 为推动电子竞技运动在国内高校的发展,丰富我院同学课余生活,使同学在紧张的学习中得到放松,增进团队 ...

  • "青国青城"学子文化节活动策划书
  • 一.活动背景及活动目的 青春韶秀,应修身治国平天下:少年立志,当经世强邦济苍生.青少年华,壮志凌云,激情似火.在这个春意盎然的季节,中国青年政治学院青少年工作系的学子们紧跟春天的步伐,把握时代的脉搏,实事求是,朝气蓬勃,在校园里开展丰富多彩的文化活动,将自身"青年"与" ...

  • 电气专业的一些毕业设计题目
  • 电气专业的一些毕业设计题目 电子类: 1.红外遥控照明灯(电路+程序+论文) 2.基于单片机的多功能智能小车设计论文(电路+程序+论文) 3.基于数字信号处理器(DSP)的异步电机直接转矩控制研究(硕士)(论文+上位机下位机软件+程序) 4.简单温度控制系统(仅论文) 5.漏电保护器(电路+程序+论 ...

  • 数据库课程设计心得体会
  • 数据库课程设计大赛的尘嚣渐渐远去,怀着对这次大赛的些许不舍,怀着对当初课程设计开始时候的豪情万丈的决心的留恋,怀着通过这次课程设计积累的信心与斗志,我开始写这篇文章,为自己的足迹留下哪怕是微不足道但是对自己弥足珍贵的痕迹并期望与大家共勉. 首先,让我的记忆追溯到大二暑假,在老大的指引下(老大劝我学a ...

  • 毕业论文选题
  • 毕业论文(设计)选题 一.信息管理专业 题目1.基于PHP的投票管理系统(设计类) 参考语言:PHP,MYSQL 要求:能够使用PHP编程语言及MYSQL的数据库知识设计一个投票管理系统,能够实现:申请投票主题.投票.统计投票结果.版主管理等主题模块 题目2.基于PHP的产品进销存管理系统(论文类) ...