/**
 * This function checks if the player has collided with any enemy in the game.
 * The player position is a Pair (x, y) representing the current position of the player.
 * The enemy positions is a list of Pairs [(x1, y1), (x2, y2), ...] representing the positions of all enemies.
 * The game area is a 2-dimensional list where each element represents a space in the game area.
 * A collision occurs if the player position is the same as any enemy position and there is no obstacle in that space.
 *
 * @param playerPosition The current position of the player.
 * @param enemyPositions The positions of all enemies.
 * @param gameArea The 2-dimensional list representing the game area.
 * @return True if a collision occurs, otherwise False.
 */
fun checkCollision(playerPosition: Pair<Int, Int>, enemyPositions: List<Pair<Int, Int>>, gameArea: List<List<Char>>): Boolean {

    for (enemyPosition in enemyPositions) {
        val (x, y) = enemyPosition
        if (playerPosition.first == x && playerPosition.second == y) {
            if (gameArea[y][x] != '#') {
                return true
            }
        }
    }
    return false
}

// Example usage:
val area = listOf(
    listOf('#', '#', '#', '#', '#', '#', '#', '#', '#', '#'),
    listOf('#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#'),
    // Add more rows as needed
)
/**
 * This function checks if the player has collided with any enemy in the game.
 * The player position is a Pair (x, y) representing the current position of the player.
 * The enemy positions is a list of Pairs [(x1, y1), (x2, y2), ...] representing the positions of all enemies.
 * The game area is a 2-dimensional list where each element represents a space in the game area.
 * A collision occurs if the player position is the same as any enemy position and there is no obstacle in that space.
 *
 * @param playerPosition The current position of the player.
 * @param enemyPositions The positions of all enemies.
 * @param gameArea The 2-dimensional list representing the game area.
 * @return True if a collision occurs, otherwise False.
 */
fun checkCollision(playerPosition: Pair<Int, Int>, enemyPositions: List<Pair<Int, Int>>, gameArea: List<List<Char>>): Boolean {
/**
 * This function checks if the player has collided with any enemy in the game.
 * The player position is a Pair (x, y) representing the current position of the player.
 * The enemy positions is a list of Pairs [(x1, y1), (x2, y2), ...] representing the positions of all enemies.
 * The game area is a 2-dimensional list where each element represents a space in the game area.
 * A collision occurs if the player position is the same as any enemy position and there is no obstacle in that space.
 *
 * @param playerPosition The current position of the player.
 * @param enemyPositions The positions of all enemies.
 * @param gameArea The 2-dimensional list representing the game area.
 * @return True if a collision occurs, otherwise False.
 */
fun checkCollision(playerPosition: Pair<Int, Int>, enemyPositions: List<Pair<Int, Int>>, gameArea: List<List<Char>>): Boolean {

    for (enemyPosition in enemyPositions) {
        val (x, y) = enemyPosition
        if (playerPosition.first == x && playerPosition.second == y) {
            if (gameArea[y][x] != '#') {
                return true
            }
        }
    }
    return false
}

// Example usage:
val area = listOf(
    listOf('#', '#', '#', '#', '#', '#', '#', '#', '#', '#'),
    listOf('#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '#'),
    // Add more rows as needed
)