How to use the pelita.layout.get_layout_by_name function in pelita

To help you get started, we’ve selected a few pelita examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ASPP / pelita / test / test_game.py View on Github external
def test_initial_positions_same_in_layout(layout_name):
    """Check initial positions are the same as what the layout says for all layouts"""
    l = layout.get_layout_by_name(layout_name=layout_name)
    parsed_l = layout.parse_layout(l)
    exp = parsed_l["bots"]
    walls = parsed_l["walls"]
    out = initial_positions(walls)
    assert out == exp
github ASPP / pelita / test / test_game.py View on Github external
def test_get_legal_positions_basic():
    """Check that the output of legal moves contains all legal moves for one example layout"""
    l = layout.get_layout_by_name(layout_name="small_100")
    parsed_l = layout.parse_layout(l)
    legal_positions = get_legal_positions(parsed_l["walls"], parsed_l["bots"][0])
    exp = [(1, 4), (1, 6), (1, 5)]
    assert legal_positions == exp
github ASPP / pelita / pelita / simplesetup.py View on Github external
def __init__(self, layout_string=None, layout_name=None, layout_file=None,
                 layout_filter = 'normal_without_dead_ends',
                 players=4, rounds=3000, host="", port=50007,
                 local=True, silent=True, dump_to_file=None):

        if (layout_string and layout_name or
                layout_string and layout_file or
                layout_name and layout_file or
                layout_string and layout_name and layout_file):
            raise  ValueError("Can only supply one of: 'layout_string'"+\
                    "'layout_name' or 'layout_file'")
        elif layout_string:
            self.layout = layout_string
        elif layout_name:
            self.layout = get_layout_by_name(layout_name)
        elif layout_file:
            with open(layout_file) as file:
                self.layout = file.read()
        else:
            self.layout = get_random_layout(filter=layout_filter)

        self.players = players
        self.rounds = rounds
        self.silent = silent

        if local:
            self.host = None
            self.port = None
            signal.signal(signal.SIGINT, keyboard_interrupt_handler)
        else:
            self.host = host