편집 기록

편집 기록
  • 프로필 nowp님의 편집
    날짜2020.10.08

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


    • 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"
    
  • 프로필 알 수 없는 사용자님의 편집
    날짜2020.10.08

    파이썬 질문입니다 ㅠㅠ


    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"