Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- board[y][x]
- board = []
- #Start with a greeting, player chooses against computer or another opponent
- game = input("""Welcome to a bad game of BATTLESHIPS, a game where you must
- destroy your opponent's ships. Please choose against Computer, if you are playing
- alone (computer), or against another opponent (player).""")
- if game.lower() == 'c':
- #Set up the board automatically
- #Players place their ships (The computer will place the ships anywhere automatically)
- #Players choose co-ordinates to destroy the opponent's ships
- board[y] = input("Please enter the letter co-ordinate: ")
- board[x] = input("Please enter the number co-ordinate: ")
- if board[y][x] == "X":
- print("Hit!")
- #this part of the boat has now been sunk
- board[y][x] = "O"
- #At the end of the player's turn the computer chooses the co-ordinates randomly
- #If a player or computer destroys all the opponent's ships they win
- if game.lower() == 'p':
- #Set up the board automatically
- #Players place their ships
- #Players choose co-ordinates to destroy the opponent's ships in order to win
- board[y] = input("Please enter the letter co-ordinate: ")
- board[x] = input("Please enter the number co-ordinate: ")
- if board[y][x] == "X":
- print("Hit!")
- #this part of the boat has now been sunk
- board[y][x] = "O"
- #Every turn the module will space out so they cannot see the opponent's ships
- for n in range(50):
- print("")
- #If a player destroys all the opponent's ships they win
Add Comment
Please, Sign In to add comment