Piškvorky v ASP - Builder.cz - Informacni server o programovani

Odběr fotomagazínu

Fotografický magazín "iZIN IDIF" každý týden ve Vašem e-mailu.
Co nového ve světě fotografie!

 

Zadejte Vaši e-mailovou adresu:

Kamarád fotí rád?

Přihlas ho k odběru fotomagazínu!

 

Zadejte e-mailovou adresu kamaráda:



Web

Piškvorky v ASP

1. srpna 2000, 00.00 | Plný zdrojový kód oblíbené hry. Nevěříte že něco takového lze vytvořit pouze pomocí ASP?

Autorem tohoto kódu je spam_email('.com', '@', 'eastbiz', 'guderna');
Funkční verzi lze vyzkoušet na url:
http://62.168.28.249/gomoku/gomoku.asp
Hodně zábavy!!


Guderna - GOMOKU / Piskvorky




a:hover {background-color:#cccccc; color:"Black";
text-decoration:none}	



<%	

Const O_POCITAC = 1
Const X_PROTIHRAC = 2
Const prazdne = 0
Dim mvarVysledek
Dim B1, B2, B3, I, J, M1, M2, T1, S1, S2, S3, K, LL, Y1, I5, J5, I8, I7, J7,
J8, M
Dim iii, K1, POC, I11, J11, I22, J22, ii, jj, I1, J1, I2, J2, NN
Dim K2, R1, N 

Function cIntIq(Cislo)
	cIntIq = 0
	On Error Resume Next
	cIntIq = cLng(Cislo) 
End Function
'===========================================================================
==
Private Sub podpr1()
'===========================================================================
==
 I1 = I - 4
 If I1 < 1 Then I1 = 1
 I2 = I + 4
 If I2 > B1 Then I2 = B1
 J1 = J - 4
 If J1 < 1 Then J1 = 1
 J2 = J + 4
 If J2 > B1 Then J2 = B1
 S2 = I - I1
 If (J - J1) < S2 Then S2 = J - J1
 S3 = I2 - I
 If (J - J1) < S3 Then S3 = J - J1
End Sub

'===========================================================================
==
Private Sub PODPR3()
'===========================================================================
==
 podpr1
 PA(I, J) = 0
 PB(I, J) = 0
 For M = I To I2
  If PV(M, J) <= 0 Then PA(I, J) = PA(I, J) + PW(PX(M, J) + 1)
  If PX(M, J) <= 0 Then PB(I, J) = PB(I, J) + PW(PV(M, J) + 1)
 Next
 For S1 = 0 To S3
  If PT(I + S1, J - S1) <= 0 Then PA(I, J) = PA(I, J) + PW(PU(I + S1, J -
S1) + 1)
  If PU(I + S1, J - S1) <= 0 Then PB(I, J) = PB(I, J) + PW(PT(I + S1, J -
S1) + 1)
 Next
 For NN = J1 To J
  If PR(I, NN) <= 0 Then PA(I, J) = PA(I, J) + PW(PS(I, NN) + 1)
  If PS(I, NN) <= 0 Then PB(I, J) = PB(I, J) + PW(PR(I, NN) + 1)
 Next
 For S1 = 0 To S2
  If PO(I - S1, J - S1) <= 0 Then PA(I, J) = PA(I, J) + PW(PQ(I - S1, J -
S1) + 1)
  If PQ(I - S1, J - S1) <= 0 Then PB(I, J) = PB(I, J) + PW(PO(I - S1, J -
S1) + 1)
 Next
End Sub

'===========================================================================
==
Private Sub PODPR2()
'===========================================================================
==
 I5 = I: J5 = J: I7 = I1: I8 = I2: J7 = J1: J8 = J2: J = J5
 For I = I5 + 1 To I8
  PODPR3
 Next
 For I = I7 To I5 - 1
  PODPR3
 Next
 I = I5
 For J = J5 + 1 To J8
  PODPR3
 Next
 For J = J7 To J5 - 1
  PODPR3
 Next
 For T1 = 1 To 4
  If (J5 + T1) <= B1 Then
   If (I5 + T1) <= B1 Then
    I = I5 + T1: J = J5 + T1
    PODPR3
    End If
   If (I5 - T1) >= 1 Then
    I = I5 - T1: J = J5 + T1
    PODPR3
    End If
  End If
  If (J5 - T1) >= 1 Then
   If (I5 + T1) <= B1 Then
    I = I5 + T1: J = J5 - T1
    PODPR3
    End If
   If (I5 - T1) >= 1 Then
    I = I5 - T1: J = J5 - T1
    PODPR3
    End If
   End If
  Next
End Sub

'**************************************************

Public Sub ginit(gi, gj)
 nmax = 20
' ja = 0: ty = 0
 B1 = nmax: PW(1) = 0: PW(2) = 5: PW(3) = 25
 PW(4) = 80: PW(5) = 1000: B2 = 5
 K1 = 4: K2 = 4.5
 POC = 0
 I = nmax \ 2 - 3 + Int((6 * Rnd) + 1)       ' zacatecni postaveni
 J = nmax \ 2 - 3 + Int((6 * Rnd) + 1)
' debugprint(i & "," & j)
 gi = I
 gj = J
 For I = 1 To nmax
  For J = 1 To nmax
   PX(I, J) = 0: PV(I, J) = 0: PU(I, J) = 0: PT(I, J) = 0: PS(I, J) = 0:
PR(I, J) = 0
   PQ(I, J) = 0: PO(I, J) = 0: hraci_pole(I, J) = 0: PA(I, J) = 0: PB(I, J)
= 0
  Next 
 Next 
End Sub

'**************************************************

Public Function gtah(gi, gj)
POC = POC + 1
I = gi: J = gj
hraci_pole(I, J) = O_POCITAC
podpr1
For K = I To I2
If K >= 5 Then
  If PX(K, J) >= 4 Then
    gtah = 1
    ty = ty + 1
    Exit Function
'                            {GOTO vyhral_jste}
  Else
    PX(K, J) = PX(K, J) + 1
  End If
End If
Next
For S1 = 0 To S3
 If ((I + S1) >= 5) And ((J - S1) <= (B1 - 4)) Then
   If PU(I + S1, J - S1) >= 4 Then
     gtah = 1
     ty = ty + 1
     Exit Function
'                            {GOTO vyhral_jste}
   Else
     PU(I + S1, J - S1) = PU(I + S1, J - S1) + 1
   End If
 End If
Next
For LL = J1 To J
 If LL <= (B1 - 4) Then
   If PS(I, LL) >= 4 Then
     gtah = 1
     ty = ty + 1
     Exit Function
'                            {GOTO vyhral_jste}
   Else
     PS(I, LL) = PS(I, LL) + 1
   End If
 End If
Next
For S1 = 0 To S2
 If ((I - S1) <= (B1 - 4)) And ((J - S1) <= (B1 - 4)) Then
   If PQ(I - S1, J - S1) >= 4 Then
     gtah = 1
     ty = ty + 1
     Exit Function
'                            {GOTO vyhral_jste}
   Else
     PQ(I - S1, J - S1) = PQ(I - S1, J - S1) + 1
   End If
 End If
Next
PODPR2
K1 = 4
opakuj=true
'L5:
'********************
while opakuj
M1 = 0: M2 = 0
 For K = 1 To B1
  For LL = 1 To B1
    iii = PA(K, LL) + PB(K, LL) \ K1
    If (iii >= M1) And (hraci_pole(K, LL) = prazdne) Then
      If (iii = M1) And (iii > 0) Then
       If Int(Rnd + 0.5) Then I11 = K: J11 = LL
      Else
       I11 = K: J11 = LL
      End If
      M1 = PA(K, LL) + PB(K, LL) \ K1
    End If
    iii = PB(K, LL) + PA(K, LL) \ K1
    If (iii >= M2) And (hraci_pole(K, LL) = prazdne) Then
     If (iii = M2) And (iii > 0) Then
       If Int(Rnd + 0.5) Then I22 = K: J22 = LL
      Else
       I22 = K: J22 = LL
      End If
      M2 = PB(K, LL) + (PA(K, LL) \ K1)
    End If
  Next
Next 
M1 = M1 - (PB(I11, J11) \ K1)
M2 = M2 - (PA(I22, J22) \ K1)
' rozhodne se jestli bude branit nebo utocit
If (((M1 <= 90) And (M2 > 19)) Or (M2 >= M1) Or ((M2 >= 160) And (M1 <
1000)) Or (M2 >= 1000) Or ((M2 >= 70) And (M1 <= 135)) Or ((M2 >= 100) And
(M1 <= 145)) Or ((M2 >= 130) And (M1 <= 155)) Or ((M2 >= 40) And (M1 <=
110))) And ((M1 <= 190) Or (M2 > 185)) And (POC > 3) Then
    I = I22
    J = J22
   Else
    I = I11
    J = J11
   End If
If hraci_pole(I, J) <> prazdne Then
 If K1 < 99 Then
  K1 = K1 + 1
'  GoTo L5
  opakuj=true	
 Else
'  {hlaseni(440,100,' To nem  smysl ')}
   gtah = 3
   Exit Function
 End If
else
  opakuj=false
End If
wend
 '***********
If (M1 < 20) And (M2 = 0) And (POC > 10) Then
'  {hlaseni(440,100,' REMIZA')}
  gtah = 4
  Exit Function
End If
hraci_pole(I, J) = X_PROTIHRAC
ii = I: jj = J
podpr1
For K = I To I2
 If K >= 5 Then
  If PV(K, J) >= 4 Then
	ja = ja + 1
	gi = I: gj = J
	gtah = 2
'   GoTo vyhral_jsem
	exit function
  Else
   PV(K, J) = PV(K, J) + 1
  End If
 End If
Next
For S1 = 0 To S3
 If ((I + S1) >= 5) And ((J - S1) <= (B1 - 4)) Then
   If PT(I + S1, J - S1) >= 4 Then
'     GoTo vyhral_jsem
	ja = ja + 1
	gi = I: gj = J
	gtah = 2
	exit function
   Else
     PT(I + S1, J - S1) = PT(I + S1, J - S1) + 1
   End If
 End If
Next
For LL = J1 To J
 If LL <= (B1 - 4) Then
  If PR(I, LL) >= 4 Then
	ja = ja + 1
	gi = I: gj = J
	gtah = 2
'   GoTo vyhral_jsem
	exit function
  Else
    PR(I, LL) = PR(I, LL) + 1
  End If
 End If
Next
For S1 = 0 To S2
 If ((I - S1) <= (B1 - 4)) And ((J - S1) <= (B1 - 4)) Then
   If PO(I - S1, J - S1) >= 4 Then
	ja = ja + 1
	gi = I: gj = J
	gtah = 2
'   GoTo vyhral_jsem
	exit function
   Else
     PO(I - S1, J - S1) = PO(I - S1, J - S1) + 1
   End If
 End If
Next
PODPR2
I = ii: J = jj
gi = I
gj = J
gtah = 0
Exit Function

vyhral_jste:
ty = ty + 1
gtah = 1
Exit Function

vyhral_jsem:
ja = ja + 1
gi = I: gj = J
gtah = 2
End Function

'******************************
nmax = 20
pocet = 20
session("ja")=cIntIq(session("ja"))
session("ty")=cIntIq(session("TY"))
if (request("New")="yes")or(request("Msg")<>"Nová hra") then
session("Start")=0
msg="Nová hra"
if not session("Start")=1 then
	session("POC") = 0
	reDim PA(25, 25)
	reDim PB(25, 25)
	reDim PO(25, 25)
	reDim PQ(25, 25)
	reDim PR(25, 25)
	reDim PS(25, 25)
	reDim PT(25, 25)
	reDim PV(25, 25)
	reDim PU(25, 25)
	reDim PX(25, 25)
    reDim PD(6)
	reDim PE(6)
	reDim PW(6)
	reDim PC(6)
	redim hraci_pole(25,25)
 session("Start")=1
 flag = 0
 ginit I, J
else
	poc=session("poc")
	PA=session("PA")
	PB=session("PB")
	PO=session("PO")
	PQ=session("PQ")
	PR=session("PR")
	PS=session("PS")
	PT=session("PT")
	PV=session("PV")
	PU=session("PU")
	PX=session("PX")
	PD=session("PD")
	PE=session("PE")
	PW=session("PW")
	PC=session("PC")
    hraci_pole=session("hraci_pole")
end if
 B1 = nmax: PW(1) = 0: PW(2) = 5: PW(3) = 25
 PW(4) = 80: PW(5) = 1000: B2 = 5
 K1 = 4: K2 = 4.5
 x=cIntIq(request("X"))
 y=cIntIq(request("Y"))
 
 if (hraci_pole(x,y)=0)and(x>0)and(y>0) then
  if (x<>0)  then
	 session("oldx")=x
	 session("oldy")=y
	 iii=gtah(x,y)
	 Select Case iii
	  Case 0
	    hraci_pole(x, y) = 2
	  Case 1
	    session("ty") = session("ty") + 1
	    Msg=" Vyhral jste !!"
	  Case 2
	    session("ja") = session("ja") + 1
 	    Msg=" Vyhral jsem !!"
	  End Select
   end if	  
 end if 
session("hraci_pole")=hraci_pole
session("PA")=PA
session("PB")=PB
session("PO")=PO
session("PQ")=PQ
session("PR")=PR
session("PS")=PS
session("PT")=PT
session("PV")=PV
session("PU")=PU
session("PX")=PX
session("PD")=PD
session("PE")=PE
session("PW")=PW
session("PC")=PC
session("poc")=poc
%>




GOMOKU
<% for i=1 to nmax %> <% for j=1 to nmax %> <% next %> <% next %>
bgcolor="#eab5a8" <%end if%> onClick="Tah(<%=i%>,<%=j%>)"><% Select case hraci_pole(i,j) case 0 %> <% Case 1 %>O<% Case 2 %>X<% end select %>

<%=msg%>      Score= <%=session("ja")%> : <%=session("ty")%>       ©Ing Ivo Guderna

Tématické zařazení:

 » Rubriky  » Web  

 » Rubriky  » ASP  

 » Rubriky  » Windows  

 

 

 

Nejčtenější články
Nejlépe hodnocené články

 

Přihlášení k mému účtu

Uživatelské jméno:

Heslo: