Code
Code
Set secretRow = random number between 1 and ElseIf direction = "left" AND playerCol > 1
5 playerCol = playerCol - 1
Set secretCol = random number between 1 and 5 ElseIf direction = "right" AND playerCol < 5
EndWhile playerCol = playerCol + 1
Set playerRow = 1 // Player starts at top-left Else
corner (1, 1)
Print "Invalid move! Try again."
Set playerCol = 1
EndIf
Set moves = 0 // Initialize move counter
moves = moves + 1 // Increment move counter
Print "Welcome to the game! You have 10 moves to
EndFunction
find the secret cell marked with 'X'."
While moves < 10
// Function to check if the player found the 'X' Print "You are currently at (", playerRow, ", ",
playerCol, ")."
Function CheckWin()
Print "Enter move direction (up, down, left, right):"
If playerRow = secretRow AND playerCol =
secretCol Input direction
Print "You Win! You found the secret cell in", MovePlayer(direction) // Move the player based on
moves, "moves." input
EndIf
If moves = 10 AND playerRow != secretRow AND
Return False playerCol != secretCol
EndIf
// Main game loop