파이썬 질문 : 게임의 다음 플레이어 선택하기

조회수 428회
  • Human_Human
  • Human
  • Human_computer

3가지 모드가 있는데

  • 그중 선택된게 Human_Human 이거나 Human_Computer라면,
    • 그전판에 점수를 1점이라도 얻었다면 다시 그 사람 차례인데,
    • 틀리면 다음 사람 차례로 넘어가는걸

만들어야되는거거든요.

공부하고 있는데 잘안되네요 모가 문제일까요?

def next_player(current_player: str, latest_occurance: int, gametype: str) -> str:

    """Return the same current_player if and only if the current player's last 
    occurance of the guessed letter is 0. Return the other player otherwise for 
    the gametype HUMAN_HUMAN or HUMAN_COMPUER. If the gametype is HUMAN always 
    return current_player.

    >>> next_player('PLAYER_ONE', 1, HUMAN_HUMAN)
    'PLAYER_ONE'
    >>> next_player('PLAYER_TWO', 0, HUMAN_COMPUTER)
    'PLAYER_TWO'
    >>> next_player('PLAYER_ONE', 0, HUMAN)
    'PLAYER_ONE'
    """

    if gametype == HUMAN_HUMAN:
        if latest_occurance >= 1:
            return current_player
        else:
            if current_player == PLAYER_ONE:
                return "PLAYER_TWO"
            elif current_player == PLAYER_TWO:
                return "PLAYER_ONE"

    elif gametype ==  HUMAN_COMPUTER:
        if latest_occurance >= 1:
            return current_player
        else:
            if current_player == PLAYER_ONE:
                return "PLAYER_TWO"
            elif current_player == PLAYER_TWO:
                return "PLAYER_ONE"        

    else:
        return "PLAYER_ONE"

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)