home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / GoMoku.dxr / 00033_gameMovie3.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  20.1 KB  |  445 lines

  1. global gGameBoard, gKounterH, gKounterV, gPosH, gPosV, gPuppeter, singleUndo, gPlaying, gSingleMove, gCompsTurn, gEKountH, gEKountV, gEPuppet, gEMoves, gEWinX, gEWinY, gETrys, gEholdX, gEholdY, gELineH, gELineV, gELineHolder, gELineDirection, gGo4WinV, gGo4WinH, gCheckPLines, gNuLine, gBalls, gNuMapPosX, gNuMapPosY, gKountY, gKountX, gSaveLength, gLineDot, gAdd5Xs, gKount2, gFullBoard, gSpecial
  2.  
  3. on PlayerMove
  4.   if gSingleMove = 1 then
  5.     if the mouseDown then
  6.       repeat with gKounterV = 1 to 13
  7.         repeat with gKounterH = 1 to 13
  8.           if gGameBoard[gKounterV][gKounterH] = 0 then
  9.             if (the mouseH < (55 + 12 + (gKounterH * 30))) and (the mouseH > (55 - 12 + (gKounterH * 30))) and (the mouseV > (7 - 12 + (gKounterV * 30))) and (the mouseV < (7 + 12 + (gKounterV * 30))) then
  10.               puppetSound(1, "move peg")
  11.               gGameBoard[gKounterV][gKounterH] = 1
  12.               gPosH = gKounterH
  13.               gPosV = gKounterV
  14.               gSingleMove = 0
  15.               if singleUndo = 1 then
  16.                 gCompsTurn = 1
  17.               end if
  18.               singleUndo = 1
  19.               sprite(gPuppeter).puppet = 1
  20.               sprite(gPuppeter).member = "black bead"
  21.               sprite(gPuppeter).loc = point(55 + (gKounterH * 30), 7 + (gKounterV * 30))
  22.               gPuppeter = gPuppeter + 1
  23.               updateStage()
  24.             end if
  25.           end if
  26.         end repeat
  27.       end repeat
  28.     end if
  29.   end if
  30.   if the mouseUp then
  31.     gSingleMove = 1
  32.   end if
  33. end
  34.  
  35. on AI_Block
  36.   repeat with gGo4WinV = 1 to 13
  37.     repeat with gGo4WinH = 1 to 13
  38.       if gGameBoard[gGo4WinV][gGo4WinH] = 1 then
  39.         if gGo4WinH <= 9 then
  40.           if (gGameBoard[gGo4WinV][gGo4WinH + 1] = 1) and (gGameBoard[gGo4WinV][gGo4WinH + 2] <> 2) and (gGameBoard[gGo4WinV][gGo4WinH + 2] = 0) then
  41.             gBalls = 2
  42.           end if
  43.           if (gGameBoard[gGo4WinV][gGo4WinH + 1] = 1) and (gGameBoard[gGo4WinV][gGo4WinH + 2] = 1) and (gGameBoard[gGo4WinV][gGo4WinH + 3] = 0) then
  44.             gBalls = 3
  45.           end if
  46.           if (gGameBoard[gGo4WinV][gGo4WinH + 1] = 1) and (gGameBoard[gGo4WinV][gGo4WinH + 2] = 1) and (gGameBoard[gGo4WinV][gGo4WinH + 3] = 1) and (gGameBoard[gGo4WinV][gGo4WinH + 4] = 0) then
  47.             gBalls = 4
  48.           end if
  49.           if (gGameBoard[gGo4WinV][gGo4WinH + 1] = 1) and (gGameBoard[gGo4WinV][gGo4WinH + 2] = 0) and (gGameBoard[gGo4WinV][gGo4WinH + 3] = 1) and (gGameBoard[gGo4WinV][gGo4WinH + 4] = 1) then
  50.             gBalls = 4
  51.             gSpecial = 2
  52.           end if
  53.           if (gGameBoard[gGo4WinV][gGo4WinH + 1] = 1) and (gGameBoard[gGo4WinV][gGo4WinH + 2] = 0) and (gGameBoard[gGo4WinV][gGo4WinH + 3] = 1) then
  54.             gBalls = 3
  55.             gSpecial = 1
  56.           end if
  57.         else
  58.           if gGo4WinH = 10 then
  59.             if (gGameBoard[gGo4WinV][gGo4WinH + 1] = 1) and (gGameBoard[gGo4WinV][gGo4WinH + 2] <> 2) and (gGameBoard[gGo4WinV][gGo4WinH + 2] = 0) then
  60.               gBalls = 2
  61.               if (gGameBoard[gGo4WinV][gGo4WinH + 2] = 1) and (gGameBoard[gGo4WinV][gGo4WinH + 3] <> 2) and (gGameBoard[gGo4WinV][gGo4WinH + 3] = 0) then
  62.                 gBalls = 3
  63.               end if
  64.             end if
  65.           else
  66.             if gGo4WinH = 11 then
  67.               if (gGameBoard[gGo4WinV][gGo4WinH + 1] = 1) and (gGameBoard[gGo4WinV][gGo4WinH + 2] <> 2) and (gGameBoard[gGo4WinV][gGo4WinH + 2] = 0) then
  68.                 gBalls = 2
  69.               end if
  70.             end if
  71.           end if
  72.         end if
  73.         if gBalls >= gSaveLength then
  74.           gNuMapPosY = gGo4WinV
  75.           gNuMapPosX = gGo4WinH + (gBalls - gSpecial)
  76.           gSaveLength = gBalls
  77.           gEKountV = gNuMapPosY
  78.           gEKountH = gNuMapPosX
  79.         end if
  80.         gBalls = 1
  81.         gSpecial = 0
  82.         if (gGo4WinH <= 9) and (gGo4WinV >= 5) then
  83.           if (gGameBoard[gGo4WinV - 1][gGo4WinH + 1] = 1) and (gGameBoard[gGo4WinV - 2][gGo4WinH + 2] <> 2) and (gGameBoard[gGo4WinV - 2][gGo4WinH + 2] = 0) then
  84.             gBalls = 2
  85.           end if
  86.           if (gGameBoard[gGo4WinV - 1][gGo4WinH + 1] = 1) and (gGameBoard[gGo4WinV - 2][gGo4WinH + 2] = 1) and (gGameBoard[gGo4WinV - 3][gGo4WinH + 3] = 0) then
  87.             gBalls = 3
  88.           end if
  89.           if (gGameBoard[gGo4WinV - 1][gGo4WinH + 1] = 1) and (gGameBoard[gGo4WinV - 2][gGo4WinH + 2] = 1) and (gGameBoard[gGo4WinV - 3][gGo4WinH + 3] = 1) and (gGameBoard[gGo4WinV - 4][gGo4WinH + 4] = 0) then
  90.             gBalls = 4
  91.           end if
  92.           if (gGameBoard[gGo4WinV - 1][gGo4WinH + 1] = 1) and (gGameBoard[gGo4WinV - 2][gGo4WinH + 2] = 0) and (gGameBoard[gGo4WinV - 3][gGo4WinH + 3] = 1) and (gGameBoard[gGo4WinV - 4][gGo4WinH + 4] = 1) then
  93.             gBalls = 4
  94.             gSpecial = 2
  95.           end if
  96.           if (gGameBoard[gGo4WinV - 1][gGo4WinH + 1] = 1) and (gGameBoard[gGo4WinV - 2][gGo4WinH + 2] = 0) and (gGameBoard[gGo4WinV - 3][gGo4WinH + 3] = 1) then
  97.             gBalls = 3
  98.             gSpecial = 1
  99.           end if
  100.         else
  101.           if (gGo4WinH = 10) and (gGo4WinV = 4) then
  102.             if (gGameBoard[gGo4WinV - 1][gGo4WinH + 1] = 1) and (gGameBoard[gGo4WinV - 2][gGo4WinH + 2] <> 2) and (gGameBoard[gGo4WinV - 2][gGo4WinH + 2] = 0) then
  103.               gBalls = 2
  104.               if (gGameBoard[gGo4WinV - 2][gGo4WinH + 2] = 1) and (gGameBoard[gGo4WinV - 3][gGo4WinH + 3] <> 2) and (gGameBoard[gGo4WinV - 3][gGo4WinH + 3] = 0) then
  105.                 gBalls = 3
  106.               end if
  107.             end if
  108.           else
  109.             if (gGo4WinH = 11) and (gGo4WinV = 3) then
  110.               if (gGameBoard[gGo4WinV - 1][gGo4WinH + 1] = 1) and (gGameBoard[gGo4WinV - 2][gGo4WinH + 2] <> 2) and (gGameBoard[gGo4WinV - 2][gGo4WinH + 2] = 0) then
  111.                 gBalls = 2
  112.               end if
  113.             end if
  114.           end if
  115.         end if
  116.         if gBalls >= gSaveLength then
  117.           gNuMapPosY = gGo4WinV - (gBalls - gSpecial)
  118.           gNuMapPosX = gGo4WinH + (gBalls - gSpecial)
  119.           gSaveLength = gBalls
  120.           gEKountV = gNuMapPosY
  121.           gEKountH = gNuMapPosX
  122.         end if
  123.         gBalls = 1
  124.         gSpecial = 0
  125.         if gGo4WinV >= 5 then
  126.           if (gGameBoard[gGo4WinV - 1][gGo4WinH] = 1) and (gGameBoard[gGo4WinV - 2][gGo4WinH] <> 2) and (gGameBoard[gGo4WinV - 2][gGo4WinH] = 0) then
  127.             gBalls = 2
  128.           end if
  129.           if (gGameBoard[gGo4WinV - 1][gGo4WinH] = 1) and (gGameBoard[gGo4WinV - 2][gGo4WinH] = 1) and (gGameBoard[gGo4WinV - 3][gGo4WinH] = 0) then
  130.             gBalls = 3
  131.           end if
  132.           if (gGameBoard[gGo4WinV - 1][gGo4WinH] = 1) and (gGameBoard[gGo4WinV - 2][gGo4WinH] = 1) and (gGameBoard[gGo4WinV - 3][gGo4WinH] = 1) and (gGameBoard[gGo4WinV - 4][gGo4WinH] = 0) then
  133.             gBalls = 4
  134.           end if
  135.           if (gGameBoard[gGo4WinV - 1][gGo4WinH] = 1) and (gGameBoard[gGo4WinV - 2][gGo4WinH] = 0) and (gGameBoard[gGo4WinV - 3][gGo4WinH] = 1) and (gGameBoard[gGo4WinV - 4][gGo4WinH] = 1) then
  136.             gBalls = 4
  137.             gSpecial = 2
  138.           end if
  139.           if (gGameBoard[gGo4WinV - 1][gGo4WinH] = 1) and (gGameBoard[gGo4WinV - 2][gGo4WinH] = 0) and (gGameBoard[gGo4WinV - 3][gGo4WinH] = 1) then
  140.             gBalls = 3
  141.             gSpecial = 1
  142.           end if
  143.         else
  144.           if gGo4WinV = 4 then
  145.             if (gGameBoard[gGo4WinV - 1][gGo4WinH] = 1) and (gGameBoard[gGo4WinV - 2][gGo4WinH] <> 2) and (gGameBoard[gGo4WinV - 2][gGo4WinH] = 0) then
  146.               gBalls = 2
  147.               if (gGameBoard[gGo4WinV - 2][gGo4WinH] = 1) and (gGameBoard[gGo4WinV - 3][gGo4WinH] <> 2) and (gGameBoard[gGo4WinV - 3][gGo4WinH] = 0) then
  148.                 gBalls = 3
  149.               end if
  150.             end if
  151.           else
  152.             if gGo4WinV = 3 then
  153.               if (gGameBoard[gGo4WinV - 1][gGo4WinH] = 1) and (gGameBoard[gGo4WinV - 2][gGo4WinH] <> 2) and (gGameBoard[gGo4WinV - 2][gGo4WinH] = 0) then
  154.                 gBalls = 2
  155.               end if
  156.             end if
  157.           end if
  158.         end if
  159.         if gBalls >= gSaveLength then
  160.           gNuMapPosY = gGo4WinV - (gBalls - gSpecial)
  161.           gNuMapPosX = gGo4WinH
  162.           gSaveLength = gBalls
  163.           gEKountV = gNuMapPosY
  164.           gEKountH = gNuMapPosX
  165.         end if
  166.         gBalls = 1
  167.         gSpecial = 0
  168.         if (gGo4WinH >= 5) and (gGo4WinV >= 5) then
  169.           if (gGameBoard[gGo4WinV - 1][gGo4WinH - 1] = 1) and (gGameBoard[gGo4WinV - 2][gGo4WinH - 2] <> 2) and (gGameBoard[gGo4WinV - 2][gGo4WinH - 2] = 0) then
  170.             gBalls = 2
  171.           end if
  172.           if (gGameBoard[gGo4WinV - 1][gGo4WinH - 1] = 1) and (gGameBoard[gGo4WinV - 2][gGo4WinH - 2] = 1) and (gGameBoard[gGo4WinV - 3][gGo4WinH - 3] = 0) then
  173.             gBalls = 3
  174.           end if
  175.           if (gGameBoard[gGo4WinV - 1][gGo4WinH - 1] = 1) and (gGameBoard[gGo4WinV - 2][gGo4WinH - 2] = 1) and (gGameBoard[gGo4WinV - 3][gGo4WinH - 3] = 1) and (gGameBoard[gGo4WinV - 4][gGo4WinH - 4] = 0) then
  176.             gBalls = 4
  177.           end if
  178.           if (gGameBoard[gGo4WinV - 1][gGo4WinH - 1] = 1) and (gGameBoard[gGo4WinV - 2][gGo4WinH - 2] = 0) and (gGameBoard[gGo4WinV - 3][gGo4WinH - 3] = 1) and (gGameBoard[gGo4WinV - 4][gGo4WinH - 4] = 1) then
  179.             gBalls = 4
  180.             gSpecial = 2
  181.           end if
  182.           if (gGameBoard[gGo4WinV - 1][gGo4WinH - 1] = 1) and (gGameBoard[gGo4WinV - 2][gGo4WinH - 2] = 0) and (gGameBoard[gGo4WinV - 3][gGo4WinH - 3] = 1) then
  183.             gBalls = 3
  184.             gSpecial = 1
  185.           end if
  186.         else
  187.           if (gGo4WinH = 4) and (gGo4WinV = 4) then
  188.             if (gGameBoard[gGo4WinV - 1][gGo4WinH - 1] = 1) and (gGameBoard[gGo4WinV - 2][gGo4WinH - 2] <> 2) and (gGameBoard[gGo4WinV - 2][gGo4WinH - 2] = 0) then
  189.               gBalls = 2
  190.               if (gGameBoard[gGo4WinV - 2][gGo4WinH - 2] = 1) and (gGameBoard[gGo4WinV - 3][gGo4WinH - 3] <> 2) and (gGameBoard[gGo4WinV - 3][gGo4WinH - 3] = 0) then
  191.                 gBalls = 3
  192.               end if
  193.             end if
  194.           else
  195.             if (gGo4WinH = 3) and (gGo4WinV = 3) then
  196.               if (gGameBoard[gGo4WinV - 1][gGo4WinH - 1] = 1) and (gGameBoard[gGo4WinV - 2][gGo4WinH - 2] <> 2) and (gGameBoard[gGo4WinV - 2][gGo4WinH - 2] = 0) then
  197.                 gBalls = 2
  198.               end if
  199.             end if
  200.           end if
  201.         end if
  202.         if gBalls >= gSaveLength then
  203.           gNuMapPosY = gGo4WinV - (gBalls - gSpecial)
  204.           gNuMapPosX = gGo4WinH - (gBalls - gSpecial)
  205.           gSaveLength = gBalls
  206.           gEKountV = gNuMapPosY
  207.           gEKountH = gNuMapPosX
  208.         end if
  209.         gBalls = 1
  210.         gSpecial = 0
  211.         if gGo4WinH >= 5 then
  212.           if (gGameBoard[gGo4WinV][gGo4WinH - 1] = 1) and (gGameBoard[gGo4WinV][gGo4WinH - 2] <> 2) and (gGameBoard[gGo4WinV][gGo4WinH - 2] = 0) then
  213.             gBalls = 2
  214.           end if
  215.           if (gGameBoard[gGo4WinV][gGo4WinH - 1] = 1) and (gGameBoard[gGo4WinV][gGo4WinH - 2] = 1) and (gGameBoard[gGo4WinV][gGo4WinH - 3] = 0) then
  216.             gBalls = 3
  217.           end if
  218.           if (gGameBoard[gGo4WinV][gGo4WinH - 1] = 1) and (gGameBoard[gGo4WinV][gGo4WinH - 2] = 1) and (gGameBoard[gGo4WinV][gGo4WinH - 3] = 1) and (gGameBoard[gGo4WinV][gGo4WinH - 4] = 0) then
  219.             gBalls = 4
  220.           end if
  221.           if (gGameBoard[gGo4WinV][gGo4WinH - 1] = 1) and (gGameBoard[gGo4WinV][gGo4WinH - 2] = 0) and (gGameBoard[gGo4WinV][gGo4WinH - 3] = 1) and (gGameBoard[gGo4WinV][gGo4WinH - 4] = 1) then
  222.             gBalls = 4
  223.             gSpecial = 2
  224.           end if
  225.           if (gGameBoard[gGo4WinV][gGo4WinH - 1] = 1) and (gGameBoard[gGo4WinV][gGo4WinH - 2] = 0) and (gGameBoard[gGo4WinV][gGo4WinH - 3] = 1) then
  226.             gBalls = 3
  227.             gSpecial = 1
  228.           end if
  229.         else
  230.           if gGo4WinH = 4 then
  231.             if (gGameBoard[gGo4WinV][gGo4WinH - 1] = 1) and (gGameBoard[gGo4WinV][gGo4WinH - 2] <> 2) and (gGameBoard[gGo4WinV][gGo4WinH - 2] = 0) then
  232.               gBalls = 2
  233.               if (gGameBoard[gGo4WinV][gGo4WinH - 2] = 1) and (gGameBoard[gGo4WinV][gGo4WinH - 3] <> 2) and (gGameBoard[gGo4WinV][gGo4WinH - 3] = 0) then
  234.                 gBalls = 3
  235.               end if
  236.             end if
  237.           else
  238.             if gGo4WinH = 3 then
  239.               if (gGameBoard[gGo4WinV][gGo4WinH - 1] = 1) and (gGameBoard[gGo4WinV][gGo4WinH - 2] <> 2) and (gGameBoard[gGo4WinV][gGo4WinH - 2] = 0) then
  240.                 gBalls = 2
  241.               end if
  242.             end if
  243.           end if
  244.         end if
  245.         if gBalls >= gSaveLength then
  246.           gNuMapPosY = gGo4WinV
  247.           gNuMapPosX = gGo4WinH - (gBalls - gSpecial)
  248.           gSaveLength = gBalls
  249.           gEKountV = gNuMapPosY
  250.           gEKountH = gNuMapPosX
  251.         end if
  252.         gBalls = 1
  253.         gSpecial = 0
  254.         if (gGo4WinH >= 5) and (gGo4WinV <= 9) then
  255.           if (gGameBoard[gGo4WinV + 1][gGo4WinH - 1] = 1) and (gGameBoard[gGo4WinV + 2][gGo4WinH - 2] <> 2) and (gGameBoard[gGo4WinV + 2][gGo4WinH - 2] = 0) then
  256.             gBalls = 2
  257.           end if
  258.           if (gGameBoard[gGo4WinV + 1][gGo4WinH - 1] = 1) and (gGameBoard[gGo4WinV + 2][gGo4WinH - 2] = 1) and (gGameBoard[gGo4WinV + 3][gGo4WinH - 3] = 0) then
  259.             gBalls = 3
  260.           end if
  261.           if (gGameBoard[gGo4WinV + 1][gGo4WinH - 1] = 1) and (gGameBoard[gGo4WinV + 2][gGo4WinH - 2] = 1) and (gGameBoard[gGo4WinV + 3][gGo4WinH - 3] = 1) and (gGameBoard[gGo4WinV + 4][gGo4WinH - 4] = 0) then
  262.             gBalls = 4
  263.           end if
  264.           if (gGameBoard[gGo4WinV + 1][gGo4WinH - 1] = 1) and (gGameBoard[gGo4WinV + 2][gGo4WinH - 2] = 0) and (gGameBoard[gGo4WinV + 3][gGo4WinH - 3] = 1) and (gGameBoard[gGo4WinV + 4][gGo4WinH - 4] = 1) then
  265.             gBalls = 4
  266.             gSpecial = 2
  267.           end if
  268.           if (gGameBoard[gGo4WinV + 1][gGo4WinH - 1] = 1) and (gGameBoard[gGo4WinV + 2][gGo4WinH - 2] = 0) and (gGameBoard[gGo4WinV + 3][gGo4WinH - 3] = 1) then
  269.             gBalls = 3
  270.             gSpecial = 1
  271.           end if
  272.         else
  273.           if (gGo4WinH = 4) and (gGo4WinV = 10) then
  274.             if (gGameBoard[gGo4WinV + 1][gGo4WinH - 1] = 1) and (gGameBoard[gGo4WinV + 2][gGo4WinH - 2] <> 2) and (gGameBoard[gGo4WinV + 2][gGo4WinH - 2] = 0) then
  275.               gBalls = 2
  276.               if (gGameBoard[gGo4WinV + 2][gGo4WinH - 2] = 1) and (gGameBoard[gGo4WinV + 3][gGo4WinH - 3] <> 2) and (gGameBoard[gGo4WinV + 3][gGo4WinH - 3] = 0) then
  277.                 gBalls = 3
  278.               end if
  279.             end if
  280.           else
  281.             if (gGo4WinH = 3) and (gGo4WinV = 11) then
  282.               if (gGameBoard[gGo4WinV + 1][gGo4WinH - 1] = 1) and (gGameBoard[gGo4WinV + 2][gGo4WinH - 2] <> 2) and (gGameBoard[gGo4WinV + 2][gGo4WinH - 2] = 0) then
  283.                 gBalls = 2
  284.               end if
  285.             end if
  286.           end if
  287.         end if
  288.         if gBalls >= gSaveLength then
  289.           gNuMapPosY = gGo4WinV + (gBalls - gSpecial)
  290.           gNuMapPosX = gGo4WinH - (gBalls - gSpecial)
  291.           gSaveLength = gBalls
  292.           gEKountV = gNuMapPosY
  293.           gEKountH = gNuMapPosX
  294.         end if
  295.         gBalls = 1
  296.         gSpecial = 0
  297.         if gGo4WinV <= 9 then
  298.           if (gGameBoard[gGo4WinV + 1][gGo4WinH] = 1) and (gGameBoard[gGo4WinV + 2][gGo4WinH] <> 2) and (gGameBoard[gGo4WinV + 2][gGo4WinH] = 0) then
  299.             gBalls = 2
  300.           end if
  301.           if (gGameBoard[gGo4WinV + 1][gGo4WinH] = 1) and (gGameBoard[gGo4WinV + 2][gGo4WinH] = 1) and (gGameBoard[gGo4WinV + 3][gGo4WinH] = 0) then
  302.             gBalls = 3
  303.           end if
  304.           if (gGameBoard[gGo4WinV + 1][gGo4WinH] = 1) and (gGameBoard[gGo4WinV + 2][gGo4WinH] = 1) and (gGameBoard[gGo4WinV + 3][gGo4WinH] = 1) and (gGameBoard[gGo4WinV + 4][gGo4WinH] = 0) then
  305.             gBalls = 4
  306.           end if
  307.           if (gGameBoard[gGo4WinV + 1][gGo4WinH] = 1) and (gGameBoard[gGo4WinV + 2][gGo4WinH] = 0) and (gGameBoard[gGo4WinV + 3][gGo4WinH] = 1) and (gGameBoard[gGo4WinV + 4][gGo4WinH] = 1) then
  308.             gBalls = 4
  309.             gSpecial = 2
  310.           end if
  311.           if (gGameBoard[gGo4WinV + 1][gGo4WinH] = 1) and (gGameBoard[gGo4WinV + 2][gGo4WinH] = 0) and (gGameBoard[gGo4WinV + 3][gGo4WinH] = 1) then
  312.             gBalls = 3
  313.             gSpecial = 1
  314.           end if
  315.         else
  316.           if gGo4WinV = 10 then
  317.             if (gGameBoard[gGo4WinV + 1][gGo4WinH] = 1) and (gGameBoard[gGo4WinV + 2][gGo4WinH] <> 2) and (gGameBoard[gGo4WinV + 2][gGo4WinH] = 0) then
  318.               gBalls = 2
  319.               if (gGameBoard[gGo4WinV + 2][gGo4WinH] = 1) and (gGameBoard[gGo4WinV + 3][gGo4WinH] <> 2) and (gGameBoard[gGo4WinV + 3][gGo4WinH] = 0) then
  320.                 gBalls = 3
  321.               end if
  322.             end if
  323.           else
  324.             if gGo4WinV = 11 then
  325.               if (gGameBoard[gGo4WinV + 1][gGo4WinH] = 1) and (gGameBoard[gGo4WinV + 2][gGo4WinH] <> 2) and (gGameBoard[gGo4WinV + 2][gGo4WinH] = 0) then
  326.                 gBalls = 2
  327.               end if
  328.             end if
  329.           end if
  330.         end if
  331.         if gBalls >= gSaveLength then
  332.           gNuMapPosY = gGo4WinV + (gBalls - gSpecial)
  333.           gNuMapPosX = gGo4WinH
  334.           gSaveLength = gBalls
  335.           gEKountV = gNuMapPosY
  336.           gEKountH = gNuMapPosX
  337.         end if
  338.         gBalls = 1
  339.         gSpecial = 0
  340.         if (gGo4WinH <= 9) and (gGo4WinV <= 9) then
  341.           if (gGameBoard[gGo4WinV + 1][gGo4WinH + 1] = 1) and (gGameBoard[gGo4WinV + 2][gGo4WinH + 2] <> 2) and (gGameBoard[gGo4WinV + 2][gGo4WinH + 2] = 0) then
  342.             gBalls = 2
  343.           end if
  344.           if (gGameBoard[gGo4WinV + 1][gGo4WinH + 1] = 1) and (gGameBoard[gGo4WinV + 2][gGo4WinH + 2] = 1) and (gGameBoard[gGo4WinV + 3][gGo4WinH + 3] = 0) then
  345.             gBalls = 3
  346.           end if
  347.           if (gGameBoard[gGo4WinV + 1][gGo4WinH + 1] = 1) and (gGameBoard[gGo4WinV + 2][gGo4WinH + 2] = 1) and (gGameBoard[gGo4WinV + 3][gGo4WinH + 3] = 1) and (gGameBoard[gGo4WinV + 4][gGo4WinH + 4] = 0) then
  348.             gBalls = 4
  349.           end if
  350.           if (gGameBoard[gGo4WinV + 1][gGo4WinH + 1] = 1) and (gGameBoard[gGo4WinV + 2][gGo4WinH + 2] = 0) and (gGameBoard[gGo4WinV + 3][gGo4WinH + 3] = 1) and (gGameBoard[gGo4WinV + 4][gGo4WinH + 4] = 1) then
  351.             gBalls = 4
  352.             gSpecial = 2
  353.           end if
  354.           if (gGameBoard[gGo4WinV + 1][gGo4WinH + 1] = 1) and (gGameBoard[gGo4WinV + 2][gGo4WinH + 2] = 0) and (gGameBoard[gGo4WinV + 3][gGo4WinH + 3] = 1) then
  355.             gBalls = 3
  356.             gSpecial = 1
  357.           end if
  358.         else
  359.           if (gGo4WinH = 10) and (gGo4WinV = 10) then
  360.             if (gGameBoard[gGo4WinV + 1][gGo4WinH + 1] = 1) and (gGameBoard[gGo4WinV + 2][gGo4WinH + 2] <> 2) and (gGameBoard[gGo4WinV + 2][gGo4WinH + 2] = 0) then
  361.               gBalls = 2
  362.               if (gGameBoard[gGo4WinV + 2][gGo4WinH + 2] = 1) and (gGameBoard[gGo4WinV + 3][gGo4WinH + 3] <> 2) and (gGameBoard[gGo4WinV + 3][gGo4WinH + 3] = 0) then
  363.                 gBalls = 3
  364.               end if
  365.             end if
  366.           else
  367.             if (gGo4WinH = 11) and (gGo4WinV = 11) then
  368.               if (gGameBoard[gGo4WinV + 1][gGo4WinH + 1] = 1) and (gGameBoard[gGo4WinV + 2][gGo4WinH + 2] <> 2) and (gGameBoard[gGo4WinV + 2][gGo4WinH + 2] = 0) then
  369.                 gBalls = 2
  370.               end if
  371.             end if
  372.           end if
  373.         end if
  374.         if gBalls >= gSaveLength then
  375.           gNuMapPosY = gGo4WinV + (gBalls - gSpecial)
  376.           gNuMapPosX = gGo4WinH + (gBalls - gSpecial)
  377.           gSaveLength = gBalls
  378.           gEKountV = gNuMapPosY
  379.           gEKountH = gNuMapPosX
  380.         end if
  381.         gBalls = 1
  382.         gSpecial = 0
  383.       end if
  384.     end repeat
  385.   end repeat
  386.   if gSaveLength <= 2 then
  387.     EnemyGo4Win()
  388.   end if
  389.   gSaveLength = 1
  390. end
  391.  
  392. on AI_Build
  393.   if gEMoves <= 1 then
  394.     selectLine()
  395.     gEKountV = gELineV
  396.     gEKountH = gELineH
  397.   else
  398.     repeat while gGameBoard[gELineV][gELineH] <> 0
  399.       case gELineDirection of
  400.         6:
  401.           Direction_Right()
  402.         9:
  403.           Direction_Up_Right()
  404.         8:
  405.           Direction_Up()
  406.         7:
  407.           Direction_Up_Left()
  408.         4:
  409.           Direction_Left()
  410.         1:
  411.           Direction_Down_Left()
  412.         2:
  413.           Direction_Down()
  414.         3:
  415.           Direction_Down_Right()
  416.         5:
  417.           Direction_Right()
  418.       end case
  419.     end repeat
  420.   end if
  421.   gEKountV = gELineV
  422.   gEKountH = gELineH
  423. end
  424.  
  425. on selectLine
  426.   gELineV = random(5) + 4
  427.   gELineH = random(5) + 4
  428. end
  429.  
  430. on AI_Random
  431.   gEKountV = random(13)
  432.   gEKountH = random(13)
  433.   repeat while gGameBoard[gEKountV][gEKountH] <> 0
  434.     gEKountV = random(13)
  435.     gEKountH = random(13)
  436.     if gFullBoard >= 169 then
  437.       gFullBoard = 0
  438.       gPlaying = 0
  439.       go(37)
  440.       put "4"
  441.     end if
  442.     put "0"
  443.   end repeat
  444. end
  445.