Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Get random x coord - row
- get random y coord - column
- Find element within 5 nesting lists with 5 elements
- OOOOO
- OOOOO
- OOOOO
- OOOOO
- OOOOO
- Check [x][y] to see if a ship is already there
- if not place a "2" to signify ship
- x= 3
- y= 2
- board[3][2] =
- OOOOO
- OOOOO
- OOO2O
- OOOOO
- if there is a ship there, get another random row and column
- Afterwards get a random location NSWE
- 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
- If the location is free go to the element north of the last noted position and mark it with a "2"
- 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