1. JavaScript / Говнокод #1297

    +151.3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    function Cross(value) {
      if (value == 0) document.pole0.src = x.src;
      if (value == 1) document.pole1.src = x.src;
      if (value == 2) document.pole2.src = x.src;
      if (value == 3) document.pole3.src = x.src;
      if (value == 4) document.pole4.src = x.src;
      if (value == 5) document.pole5.src = x.src;
      if (value == 6) document.pole6.src = x.src;
      if (value == 7) document.pole7.src = x.src;
      if (value == 8) document.pole8.src = x.src;
    }
    
    function Zero(value) {
      if (value == 0) document.pole0.src = o.src;
      if (value == 1) document.pole1.src = o.src;
      if (value == 2) document.pole2.src = o.src;
      if (value == 3) document.pole3.src = o.src;
      if (value == 4) document.pole4.src = o.src;
      if (value == 5) document.pole5.src = o.src;
      if (value == 6) document.pole6.src = o.src;
      if (value == 7) document.pole7.src = o.src;
      if (value == 8) document.pole8.src = o.src;
    }
    
    function CheckVictory() {
      if (cell[0] == cell[1] && cell[1] == cell[2] && cell[2] > 0) return true; 
      if (cell[3] == cell[4] && cell[4] == cell[5] && cell[5] > 0) return true;
      if (cell[6] == cell[7] && cell[7] == cell[8] && cell[8] > 0) return true;
      if (cell[6] == cell[3] && cell[3] == cell[0] && cell[0] > 0) return true;
      if (cell[7] == cell[4] && cell[4] == cell[1] && cell[1] > 0) return true;
      if (cell[8] == cell[5] && cell[5] == cell[2] && cell[2] > 0) return true;
      if (cell[6] == cell[4] && cell[4] == cell[2] && cell[2] > 0) return true;
      if (cell[0] == cell[4] && cell[4] == cell[8] && cell[8] > 0) return true;
    }
    
    function CompTurn() {
      for (i=0; i<9; i++) if (cell[i] == 0) PutHere = i;
      for (i=0; i<3; i++) {
      if (cell[0] == cell[1] && cell[2] == 0 && cell[0] == i) PutHere = 2;
      if (cell[0] == cell[2] && cell[1] == 0 && cell[0] == i) PutHere = 1;
      if (cell[1] == cell[2] && cell[0] == 0 && cell[2] == i) PutHere = 0;
      if (cell[3] == cell[4] && cell[5] == 0 && cell[3] == i) PutHere = 5;
      if (cell[3] == cell[5] && cell[4] == 0 && cell[3] == i) PutHere = 4;
      if (cell[4] == cell[5] && cell[3] == 0 && cell[5] == i) PutHere = 3;
      if (cell[6] == cell[7] && cell[8] == 0 && cell[6] == i) PutHere = 8;
      if (cell[6] == cell[8] && cell[7] == 0 && cell[6] == i) PutHere = 7;
      if (cell[7] == cell[8] && cell[6] == 0 && cell[8] == i) PutHere = 6;
    
      if (cell[6] == cell[3] && cell[0] == 0 && cell[6] == i) PutHere = 0;
      if (cell[6] == cell[0] && cell[3] == 0 && cell[6] == i) PutHere = 3;
      if (cell[3] == cell[0] && cell[6] == 0 && cell[3] == i) PutHere = 6;
      if (cell[7] == cell[4] && cell[1] == 0 && cell[7] == i) PutHere = 1;
      if (cell[7] == cell[1] && cell[4] == 0 && cell[7] == i) PutHere = 4;
      if (cell[4] == cell[1] && cell[7] == 0 && cell[4] == i) PutHere = 7;
      if (cell[8] == cell[5] && cell[2] == 0 && cell[8] == i) PutHere = 2;
      if (cell[8] == cell[2] && cell[5] == 0 && cell[8] == i) PutHere = 5;
      if (cell[5] == cell[2] && cell[8] == 0 && cell[5] == i) PutHere = 8;
    
      if (cell[6] == cell[4] && cell[2] == 0 && cell[6] == i) PutHere = 2;
      if (cell[6] == cell[2] && cell[4] == 0 && cell[6] == i) PutHere = 4;
      if (cell[4] == cell[2] && cell[6] == 0 && cell[4] == i) PutHere = 6;
      if (cell[0] == cell[4] && cell[8] == 0 && cell[0] == i) PutHere = 8;
      if (cell[0] == cell[8] && cell[4] == 0 && cell[0] == i) PutHere = 4;
      if (cell[4] == cell[8] && cell[0] == 0 && cell[4] == i) PutHere = 0;
      }
      Zero(PutHere);
      cell[PutHere] = 2;
      if (CheckVictory() == true) {
        alert("Выиграл JavaScript =).");
        GameOver();
      }
    }
    
    function GameOver() {
      for (i=0; i<9; i++) cell[i] = 0;
      document.pole0.src = e.src;
      document.pole1.src = e.src;
      document.pole2.src = e.src;
      document.pole3.src = e.src;
      document.pole4.src = e.src;
      document.pole5.src = e.src;
      document.pole6.src = e.src;
      document.pole7.src = e.src;
      document.pole8.src = e.src;
    }

    Найдено тут: http://top.asf.ru/Sgames/xo/. В остальном без комментариев, код говорит сам за себя.

    Запостил: guest, 30 Июня 2009

    Комментарии (5) RSS

    Добавить комментарий