How to use the pelita.player.SimpleTeam 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_simplesetup.py View on Github external
for bind_address in server.bind_addresses:
            assert bind_address.startswith("tcp://")

        client1_address = server.bind_addresses[0].replace("*", "localhost")
        client2_address = server.bind_addresses[1].replace("*", "localhost")

        class FailingPlayer:
            def _set_initial(self, dummy, dummy2):
                pass
            def _set_index(self, dummy):
                pass
            def _get_move(self, universe, game_state):
                pass

        client1 = SimpleClient(SimpleTeam("team1", SteppingPlayer("^>>v<")), address=client1_address)
        client2 = SimpleClient(SimpleTeam("team2", FailingPlayer()), address=client2_address)

        client1.autoplay_process()
        client2.autoplay_process()
        server.run()
        server.shutdown()
github ASPP / pelita / pelitagame.py View on Github external
def create_builtin_team(spec):
    names = spec.split(',')
    if len(names) == 1:
        names *= 2
    elif len(names) > 2:
        raise ValueError('need two comma separated names')

    players = [import_builtin_player(name)() for name in names]
    teamname = 'The %ss' % players[0].__class__.__name__
    return pelita.player.SimpleTeam(teamname, *players)
github ASPP / pelita / doc / source / my_player / my_player.py View on Github external
def team():
    return SimpleTeam("My Team", MyPlayer(), MyPlayer())
github ASPP / pelita / demo / demo_local_actor.py View on Github external
server.notify("initialize_game", [layout, 4, 200])

# Initialise a TkViewer and register it with the ServerActor.
viewer = TkViewer()
server.notify("register_viewer", [viewer])

# Our two PlayerTeams must be defined in the same Python
# process (because this is local game).
# Create their ClientActors, register the Teams, and connect
# to the ServerActor.
clientActor = ClientActor("the good ones")
clientActor.register_team(SimpleTeam(BFSPlayer(), BFSPlayer()))
clientActor.connect_local("pelita-main")

clientActor2 = ClientActor("the bad ones")
clientActor2.register_team(SimpleTeam(RandomPlayer(), RandomPlayer()))
clientActor2.connect_local("pelita-main")

# Now follows the boilerplate which is needed to run the game.
# As this uses a TkViewer, we need to give Tk the control
# over our main thread.
# Since everything else runs in threaded actors, this is not
# much of a problem. The queue needed to exchange data between
# different threads is handled by our TkViewer.
try:
    viewer.root.mainloop()
except KeyboardInterrupt:
    print "Received CTRL+C. Exiting."
finally:
    # Finally, we need to ensure that everything closes.

    clientActor.actor_ref.stop()