Exemplo n.º 1
0
import sys
import Participant
import socket
import pickle
import threading
import re
import time

# Define a dictionary of available bots:
available_bots = {
    'alice': Participant.Alice(),
    'bob': Participant.Bob(),
    'batman': Participant.Batman(),
    'james': Participant.James(),
    'yoda': Participant.Yoda()
}

# Force user to specify ip and port
try:
    ip = sys.argv[1]
    if ip == '--help' or ip == '-h':
        print(
            "To start a client that should connect to specified ip and port:\n"
            "$python3 client.py <u>ip</u> <u>port</u> [ <u>bot_name</u> ]\n\n"
            "> -b <u>bot_name</u>: specify the bot you want this client to be from the list of available bots\n"
            ">> Current available bots: Alice, Bob, Eve\n\n"
            "> Example usage (connecting as a person to localhost:2410):\n"
            ">> $python3 client.py localhost 2410\n\n"
            "> Example usage (connecting as a bot (Alice) to localhost:2410):\n"
            ">> $python3 client.py localhost 2410 alice")
        sys.exit()