Ejemplo n.º 1
0
def string_to_interactions(string):
    """
    Converts a compact string representation of an interaction to an
    interaction:

    'CDCDDD' -> [(C, D), (C, D), (D, D)]
    """
    interactions = []
    interactions_list = list(string)
    while interactions_list:
        p1action = Action.from_char(interactions_list.pop(0))
        p2action = Action.from_char(interactions_list.pop(0))
        interactions.append((p1action, p2action))
    return interactions
Ejemplo n.º 2
0
    def _get_human_input(self) -> Action:  # pragma: no cover
        """
        A method to prompt the user for input, validate it and display
        the bottom toolbar.

        Returns
        -------
        string
            Uppercase C or D indicating the action to play
        """
        action = prompt(
            'Turn {} action [C or D] for {}: '.format(
                len(self.history) + 1, self.human_name),
            validator=ActionValidator(),
            get_bottom_toolbar_tokens=self.status_messages['toolbar'],
            style=toolbar_style)

        return Action.from_char(action.upper())
Ejemplo n.º 3
0
    def _get_human_input(self) -> Action:  # pragma: no cover
        """
        A method to prompt the user for input, validate it and display
        the bottom toolbar.

        Returns
        -------
        string
            Uppercase C or D indicating the action to play
        """
        action = prompt(
            "Turn {} action [C or D] for {}: ".format(
                len(self.history) + 1, self.human_name
            ),
            validator=ActionValidator(),
            style=toolbar_style,
            **{bottom_toolbar_name: self.status_messages["toolbar"]},
        )

        return Action.from_char(action.upper())