import boards

def main():
    playerDead = False
    enemyDead = False
    
    enemyBoard = boards.makeEnemyBoard()
    enemyLocations = boards.setupEnemyBoard()
    playerBoard = boards.makePlayerBoard()
    
    print("----BATTLESHIP----")
    boards.printBoards(enemyBoard, playerBoard)
    
    while not playerDead and not enemyDead:
        row = int(input("Guess row: "))
        col = int(input("Guess coloumn: "))
        
        #Make true for testing purposes
        enemyDead = True
    
    if enemyDead:
        print("You win!")
    else:
        print("You lose!")

main()
import boards

def main():
    MAX_HITS = 17
    enemyDead = False
    playerDead = False
    hitsOnEnemy = 0
    hitsOnPlayer = 0
    turn = 1
    
    enemyBoard = boards.makeEnemyBoard()
    enemyLocations = boards.setupEnemyBoard()
    playerBoard = boards.makePlayerBoard()
    
    print("----BATTLESHIP----")
        
    while not playerDead and not enemyDead:
        boards.printBoards(enemyBoard, playerBoard)
        print("Turn " + str(turn))
        row = int(input("Guess row: ")) - 1
        col = int(input("Guess coloumn: ")) - 1
        
        #Player choice evaluated
        if enemyLocations[row][col] == "o":
            #It's a hit!
            enemyBoard[row][col] = "*"
            hitsOnEnemy += 1
            
        else:
            if(row < 0 or row > boards.BOARD_SIZE - 1) or (col < 0 or col > boards.BOARD_SIZE - 1):
                print("Oops, that's not even in the ocean.")
            elif(enemyBoard[row][col] == "X" or enemyBoard[row][col] == "*"):
                print("You guessed that one already.")
            else:
                #It's a miss
                enemyBoard[row][col] = "X"        
        
        #Check if either player is dead
        if hitsOnEnemy == MAX_HITS:
            enemyDead = True
        elif hitsOnPlayer == MAX_HITS:
            playerDead = True
        
        turn += 1
        
        #Make true for testing purposes
        enemyDead = True
    
    if enemyDead:
        print("YOU WIN!")
    else:
        print("YOU LOSE!")

main()
Add player input evaluation, determines hit/miss
Add player input evaluation, determines hit/miss

  import boards
  
  def main():
+     MAX_HITS = 17
+     enemyDead = False
      playerDead = False
-     enemyDead = False
+     hitsOnEnemy = 0
+     hitsOnPlayer = 0
+     turn = 1
      
      enemyBoard = boards.makeEnemyBoard()
      enemyLocations = boards.setupEnemyBoard()
      playerBoard = boards.makePlayerBoard()
      
      print("----BATTLESHIP----")
+         
-     boards.printBoards(enemyBoard, playerBoard)
-     
      while not playerDead and not enemyDead:
+         boards.printBoards(enemyBoard, playerBoard)
+         print("Turn " + str(turn))
-         row = int(input("Guess row: "))
+         row = int(input("Guess row: ")) - 1
-         col = int(input("Guess coloumn: "))
+         col = int(input("Guess coloumn: ")) - 1
+         
+         #Player choice evaluated
+         if enemyLocations[row][col] == "o":
+             #It's a hit!
+             enemyBoard[row][col] = "*"
+             hitsOnEnemy += 1
+             
+         else:
+             if(row < 0 or row > boards.BOARD_SIZE - 1) or (col < 0 or col > boards.BOARD_SIZE - 1):
+                 print("Oops, that's not even in the ocean.")
+             elif(enemyBoard[row][col] == "X" or enemyBoard[row][col] == "*"):
+                 print("You guessed that one already.")
+             else:
+                 #It's a miss
+                 enemyBoard[row][col] = "X"        
+         
+         #Check if either player is dead
+         if hitsOnEnemy == MAX_HITS:
+             enemyDead = True
+         elif hitsOnPlayer == MAX_HITS:
+             playerDead = True
+         
+         turn += 1
          
          #Make true for testing purposes
          enemyDead = True
      
      if enemyDead:
-         print("You win!")
+         print("YOU WIN!")
      else:
-         print("You lose!")
+         print("YOU LOSE!")
  
  main()
Add player input evaluation, determines hit/miss
## Code Before:
import boards

def main():
    playerDead = False
    enemyDead = False
    
    enemyBoard = boards.makeEnemyBoard()
    enemyLocations = boards.setupEnemyBoard()
    playerBoard = boards.makePlayerBoard()
    
    print("----BATTLESHIP----")
    boards.printBoards(enemyBoard, playerBoard)
    
    while not playerDead and not enemyDead:
        row = int(input("Guess row: "))
        col = int(input("Guess coloumn: "))
        
        #Make true for testing purposes
        enemyDead = True
    
    if enemyDead:
        print("You win!")
    else:
        print("You lose!")

main()
## Instruction:
Add player input evaluation, determines hit/miss
## Code After:
import boards

def main():
    MAX_HITS = 17
    enemyDead = False
    playerDead = False
    hitsOnEnemy = 0
    hitsOnPlayer = 0
    turn = 1
    
    enemyBoard = boards.makeEnemyBoard()
    enemyLocations = boards.setupEnemyBoard()
    playerBoard = boards.makePlayerBoard()
    
    print("----BATTLESHIP----")
        
    while not playerDead and not enemyDead:
        boards.printBoards(enemyBoard, playerBoard)
        print("Turn " + str(turn))
        row = int(input("Guess row: ")) - 1
        col = int(input("Guess coloumn: ")) - 1
        
        #Player choice evaluated
        if enemyLocations[row][col] == "o":
            #It's a hit!
            enemyBoard[row][col] = "*"
            hitsOnEnemy += 1
            
        else:
            if(row < 0 or row > boards.BOARD_SIZE - 1) or (col < 0 or col > boards.BOARD_SIZE - 1):
                print("Oops, that's not even in the ocean.")
            elif(enemyBoard[row][col] == "X" or enemyBoard[row][col] == "*"):
                print("You guessed that one already.")
            else:
                #It's a miss
                enemyBoard[row][col] = "X"        
        
        #Check if either player is dead
        if hitsOnEnemy == MAX_HITS:
            enemyDead = True
        elif hitsOnPlayer == MAX_HITS:
            playerDead = True
        
        turn += 1
        
        #Make true for testing purposes
        enemyDead = True
    
    if enemyDead:
        print("YOU WIN!")
    else:
        print("YOU LOSE!")

main()