Ejemplo n.º 1
0
def interactive_strategy(gamestate):
    """A strategy that starts an interactive session and lets the user make
    changes to the gamestate.

    For example, one might deploy a ThrowerAnt to the first tunnel by invoking
    gamestate.deploy_ant('tunnel_0_0', 'Thrower')
    """
    print('gamestate: ' + str(gamestate))
    msg = '<Control>-D (<Control>-Z <Enter> on Windows) completes a turn.\n'
    interact(msg)
Ejemplo n.º 2
0
def interactive_strategy(colony):
    """A strategy that starts an interactive session and lets the user make
    changes to the colony.

    For example, one might deploy a ThrowerAnt to the first tunnel by invoking:
    colony.deploy_ant('tunnel_0_0', 'Thrower')
    """
    game_print('colony: ' + str(colony))
    msg = '<Control>-D (<Control>-Z <Enter> on Windows) completes a turn.\n'
    interact(msg)
Ejemplo n.º 3
0
def run():
    interact()
Ejemplo n.º 4
0
Archivo: hog.py Proyecto: sinistrum/Hog
    winner = play(always_roll(5), always_roll(6))
    if winner == 0:
        print("Player 0, who always wants to roll 5, won.")
    else:
        print("Player 1, who always wants to roll 6, won.")

'''@main
def run(*args):
    """Read in the command-line argument and calls corresponding functions.
    
    This function uses Python syntax/techniques not yet covered in this course.
    """
    import argparse
    parser = argparse.ArgumentParser(description="Play Hog")
    parser.add_argument('--take_turn_test', '-t', action='store_true')
    parser.add_argument('--play_interactively', '-p', action='store_true')
    parser.add_argument('--play_basic', '-b', action='store_true')
    parser.add_argument('--run_experiments', '-r', action='store_true')
    parser.add_argument('--final_strategy_test', '-f', action='store_true')
    args = parser.parse_args()
    for name, execute in args.__dict__.items():
        if execute:
            globals()[name]()
'''


# Add this function to interact with the code on command line (with out adding -i)
# Must be at end of code
interact()

Ejemplo n.º 5
0
def run():
    interact()
Ejemplo n.º 6
0
def main():
    diff_msgs = test_comparator()
    interact()
Ejemplo n.º 7
0
def main():
    interact()
Ejemplo n.º 8
0
####TESTING####
import Accumulator
import ucb

test_accum = Accumulator("imap.gmail.com", "*****@*****.**", "LottaSaulsMail", 993, "INBOX") 
ids = test_accum.get_ids()
headers = test_accum.get_header_info()   
ucb.interact()
Ejemplo n.º 9
0
def prog():
    interact()
Ejemplo n.º 10
0
    commentary = True
    winner = play(always_roll(5), always_roll(6))
    if winner == 0:
        print("Player 0, who always wants to roll 5, won.")
    else:
        print("Player 1, who always wants to roll 6, won.")


'''@main
def run(*args):
    """Read in the command-line argument and calls corresponding functions.
    
    This function uses Python syntax/techniques not yet covered in this course.
    """
    import argparse
    parser = argparse.ArgumentParser(description="Play Hog")
    parser.add_argument('--take_turn_test', '-t', action='store_true')
    parser.add_argument('--play_interactively', '-p', action='store_true')
    parser.add_argument('--play_basic', '-b', action='store_true')
    parser.add_argument('--run_experiments', '-r', action='store_true')
    parser.add_argument('--final_strategy_test', '-f', action='store_true')
    args = parser.parse_args()
    for name, execute in args.__dict__.items():
        if execute:
            globals()[name]()
'''

# Add this function to interact with the code on command line (with out adding -i)
# Must be at end of code
interact()
Ejemplo n.º 11
0
def main():
    """Main function.  Prompts user for input.  Outputs the Message-ID
       of each message in both the source and destination.  Outputs the 
       number of messages which are different between source and destination.
       Sends a formatted table with the header content of the missing messages
       to OUTPUT_FILE."""
    
    ####GET ALL MESSAGES FROM GMAIL###
   # gmail_usr_name = raw_input("Enter the gmail user name: \n")
   # gmail_passwrd = getpass.getpass("Enter the Gmail password: \n")
    print("Please wait while message IDs for Gmail are populated...")
    gmail_accumulator = Accumulator.Accumulator(GMAIL_PATH, "usr_name", "passwrd",
                                                IMAP_PORT, GMAIL_FOLDER)
    gmail_msg_ids = gmail_accumulator.get_ids()
    pprint.pprint(gmail_msg_ids)
    
    ####GET ALL MESSAGES FROM IMAP###
    #IMAP2_usr_name = raw_input("Enter the IMAP2 user name: \n")
    #IMAP2_passwrd = getpass.getpass("Enter the IMAP2 password: \n")
    print("Please wait while message IDs for IMAP are populated")
    
    IMAP2_accumulator = Accumulator.Accumulator("imap2.lbl.gov", "usr_name", "passwrd",
                                                IMAP_PORT, IMAP2_FOLDER)
    IMAP2_msg_ids = IMAP2_accumulator.get_ids()
    pprint.pprint(IMAP2_msg_ids)
    
    gmail_unique_ids = gmail_accumulator.get_unique_ids()
    ###FIND THE DIFFERENCES BETWEEN IMAP AND GMAIL.####
    compare_ids = Comparator.Comparator(IMAP2_msg_ids, gmail_unique_ids)
    diff_ids = compare_ids.compare()
    
    ###FIND THE DUPLICATE IDs FROM IMAP2.###
    
    dups = IMAP2_accumulator.get_duplicate_ids()
    dup_headers = header_info(dups, IMAP2_accumulator)
    print("{num_msgs} messages in IMAP2/{fldr}\n".format(num_msgs = IMAP2_accumulator.count_ids(), fldr = IMAP2_accumulator.folder))
    print("{num_msgs} messages in GMAIL/{fldr}\n".format(num_msgs = gmail_accumulator.count_ids(), fldr = gmail_accumulator.folder))
    
    print("-------------------------------------------------------------------------------------")
    print("There are {num} messages in IMAP2/{fldr1} which are not in Gmail/{fldr2}\n".format(num = len(diff_ids),
                                                                                            fldr1 = IMAP2_accumulator.folder,
                                                                                            fldr2 = gmail_accumulator.folder))
    print("--------------------------------------------------------------------------------------")
    pprint.pprint(diff_ids)

    print("Here is a list of the headers of each message ID which is not in Gmail:\n")
    headers = header_info(diff_ids, IMAP2_accumulator)

    ###print a table of the info of the missing messages.###
    table = prettytable.PrettyTable(["TO", "FROM", "SUBJECT"])
    table.align["TO"] = "l"
    table.padding_width = 1
    for hdr in headers:
        table.add_row(hdr)
    print(table)


    ###write the output to OUTPUT_FILE.###

    output_file = open(OUTPUT_FILE, 'w')
    output_file.write("\n")
    output_file.write("{num_msgs} messages in IMAP2/{fldr}\n".format(num_msgs = IMAP2_accumulator.count_ids(), fldr = IMAP2_accumulator.folder))
    output_file.write("{num_msgs} messages in GMAIL/{fldr}\n".format(num_msgs = gmail_accumulator.count_ids(), fldr = gmail_accumulator.folder))
    output_file.write("There are {num} messages in IMAP2/{fldr1} which are not in Gmail/{fldr2} \n".format(num = len(diff_ids),
                                                                                            fldr1 = IMAP2_accumulator.folder,
                                                                                           fldr2 = gmail_accumulator.folder))
    output_file.write("Here is a list of the headers of each message ID which is not in Gmail:\n")
    for ids in diff_ids:
        output_file.write(str(ids))
        output_file.write("\n")
    output_file.write("\n")

    ###OUUTPUT THE TABLE###

    output_file.write(str(table)) 
    output_file.write(LINE_SEPARATOR)

    output_file.close()

    ucb.interact()
Ejemplo n.º 12
0
def interactive_strategy(colony):
    print('colony: ' + str(colony))
    msg = '<Control>-D (<Control>-Z <Enter> on Windows) completes a turn.\n'
    interact(msg)
Ejemplo n.º 13
0
def main():
    interact()