Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. {
  2. public GameObject[] allSlotsGO = new GameObject[8]; //all slots on game board
  3. public bool[] isSlotsUnused = new bool[8]; //which slots on the game board have not been placed on
  4. int turnCounter = 1;
  5.  
  6. void start()
  7. {
  8. Setup();
  9. }
  10.  
  11. void Setup()
  12. {
  13. for(int i = 0; i < isSlotsUnused.length; i++)
  14. {
  15. isSlotsUnused[i] = true;
  16. }
  17. }
  18.  
  19. void AIMove()
  20. {
  21. //find out what turn its on, assume it always starts on turn 1, because it does..
  22. Switch(turnCounter)
  23. {
  24. case 1:
  25. MoveOne();
  26. break;
  27. case 2:
  28. MoveTwo();
  29. break;
  30. case 3:
  31. MoveThree();
  32. break;
  33. case 4:
  34. MoveFour();
  35. break;
  36. case 5:
  37. MoveFive();
  38. break;
  39. }
  40. //increment counter
  41. turnCounter += 1;
  42. }
  43.  
  44. void MoveOne()
  45. {
  46. bool hasPlayed = false;
  47. int playAttempt;
  48.  
  49. while(hasPlayed == false)
  50. {
  51. playAttempt = Random.Range(0,8); //randomly move 0-8
  52. if(isSlotsUnused[playAttempt] == true)
  53. hasPlayed == true
  54. }
  55.  
  56. //place on allSlotsGO[playAttempt] //lets say that move was pos1
  57. //change isSlotsUnused[playAttempt] to false //place 1
  58. }
  59.  
  60. void MoveTwo()
  61. {
  62. bool hasPlayed = false;
  63. int playAttempt;
  64.  
  65. while(hasPlayed == false)
  66. {
  67. playAttempt = Random.Range(0,8); //randomly place 0-6, lets say player moves on pos2
  68. if(isSlotsUnused[playAttempt] == true)
  69. hasPlayed == true
  70. }
  71.  
  72. //place on allSlotsGO[playAttempt] //lets say that move was pos3
  73. //change isSlotsUnused[playAttempt] to false //[place 3]
  74.  
  75. }
  76.  
  77. void MoveThree()
  78. {
  79. bool hasPlayed = false;
  80. int playAttempt;
  81.  
  82. while(hasPlayed == false)
  83. {
  84. playAttempt = Random.Range(0,8); //randomly place 0-6, lets say player moves on pos4
  85. if(isSlotsUnused[playAttempt] == true)
  86. hasPlayed == true
  87. }
  88.  
  89. //place on allSlotsGO[playAttempt] //lets say that move was pos5
  90. //change isSlotsUnused[playAttempt] to false //[place 5]
  91.  
  92. }
  93.  
  94. void MoveFour()
  95. {
  96. bool hasPlayed = false;
  97. int playAttempt;
  98.  
  99. while(hasPlayed == false)
  100. {
  101. playAttempt = Random.Range(0,8); //randomly place 0-6, lets say player moves on pos6
  102. if(isSlotsUnused[playAttempt] == true)
  103. hasPlayed == true
  104. }
  105.  
  106. //place on allSlotsGO[playAttempt] //lets say that move was pos7
  107. //change isSlotsUnused[playAttempt] to false //[place 7]
  108.  
  109. }
  110.  
  111. void MoveFive()
  112. {
  113. bool hasPlayed = false;
  114. int playAttempt;
  115.  
  116. while(hasPlayed == false)
  117. {
  118. playAttempt = Random.Range(0,8); //randomly place 0-6, lets say player moves on pos8
  119. if(isSlotsUnused[playAttempt] == true)
  120. hasPlayed == true
  121. }
  122.  
  123. //place on allSlotsGO[playAttempt] //lets say that move was pos9
  124. //change isSlotsUnused[playAttempt] to false //[place 9]
  125.  
  126. }
  127.  
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement