Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. Get random x coord - row
  2. get random y coord - column
  3.  
  4. Find element within 5 nesting lists with 5 elements
  5.  
  6. OOOOO
  7. OOOOO
  8. OOOOO
  9. OOOOO
  10. OOOOO
  11.  
  12. Check [x][y] to see if a ship is already there
  13.  
  14. if not place a "2" to signify ship
  15.  
  16. x= 3
  17. y= 2
  18. board[3][2] =
  19.  
  20. OOOOO
  21. OOOOO
  22. OOO2O
  23. OOOOO
  24.  
  25. if there is a ship there, get another random row and column
  26.  
  27. Afterwards get a random location NSWE
  28.  
  29. if location is for example north check the element north of the ships first location to make sure it is free, or it does't go out of index
  30.  
  31. If the location is free go to the element north of the last noted position and mark it with a "2"
  32.  
  33. if the location is not free, or out of bounds, generate another set of random coordinates and direction until a ship is placed.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement