Advertisement
g0ku

Untitled

Feb 15th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.99 KB | None | 0 0
  1. function TForm1.desno(x,y,tip:integer):integer;
  2. var br:integer;
  3. begin
  4. br:=0;
  5. if tip=1 then
  6. begin
  7. if x+1<=9 then
  8. begin
  9. if pShots[x,y]=1 then
  10. br:=1+desno(x+1,y,1)
  11. else br:=0;
  12. end
  13. else br:=0;
  14. end;
  15.  
  16. if tip=2 then
  17. begin
  18. if x+1<=9 then
  19. begin
  20. if cShots[x,y]=1 then
  21. br:=1+desno(x+1,y,2)
  22. else br:=0;
  23. end
  24. else br:=0;
  25. end;
  26. desno:=br-1;
  27. end;
  28. function TForm1.levo(x,y,tip:integer):integer;
  29. var br:integer;
  30. begin
  31. br:=0;
  32. if tip=1 then
  33. begin
  34. if x-1>=0 then
  35. begin
  36. if pShots[x,y]=1 then
  37. br:=1+levo(x-1,y,1)
  38. else br:=0;
  39. end
  40. else br:=0;
  41. end;
  42.  
  43. if tip=2 then
  44. begin
  45. if x-1>=0 then
  46. begin
  47. if cShots[x,y]=1 then
  48. br:=1+levo(x-1,y,2)
  49. else br:=0;
  50. end
  51. else br:=0;
  52. end;
  53. levo:=br-1;
  54. end;
  55. function TForm1.gore(x,y,tip:integer):integer;
  56. var br:integer;
  57. begin
  58. br:=0;
  59. if tip=1 then
  60. begin
  61. if y-1>=0 then
  62. begin
  63. if pShots[x,y]=1 then
  64. br:=1+gore(x,y-1,1)
  65. else br:=0;
  66. end
  67. else br:=0;
  68. end;
  69.  
  70. if tip=2 then
  71. begin
  72. if y-1>=0 then
  73. begin
  74. if cShots[x,y]=1 then
  75. br:=1+gore(x,y-1,2)
  76. else br:=0;
  77. end
  78. else br:=0;
  79. end;
  80. gore:=br-1;
  81. end;
  82. function TForm1.dole(x,y,tip:integer):integer;
  83. var br:integer;
  84. begin
  85. br:=0;
  86. if tip=1 then
  87. begin
  88. if y+1<=9 then
  89. begin
  90. if pShots[x,y]=1 then
  91. br:=1+dole(x,y+1,1)
  92. else br:=0;
  93. end
  94. else br:=0;
  95. end;
  96.  
  97. if tip=2 then
  98. begin
  99. if y+1<=9 then
  100. begin
  101. if cShots[x,y]=1 then
  102. br:=1+dole(x,y+1,2)
  103. else br:=0;
  104. end
  105. else br:=0;
  106. end;
  107. dole:=br-1;
  108. end;
  109. function TForm1.isPotopljen(x,y,tip:integer):boolean;
  110. begin
  111. if tip=1 then
  112. begin
  113. if (gore(x,y,1)+dole(x,y,1)+1=cBoard[x,y])or(levo(x,y,1)+desno(x,y,1)+1=cBoard[x,y])then
  114. isPotopljen:=true
  115. else isPotopljen:=false;
  116. end;
  117.  
  118. if tip=2 then
  119. begin
  120. if (1+gore(x,y,2)+dole(x,y,2)=pBoard[x,y])or(1+levo(x,y,2)+desno(x,y,2)=pBoard[x,y])then
  121. isPotopljen:=true
  122. else isPotopljen:=false;
  123. end;
  124.  
  125. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement