예제 #1
0
def debug(message):
    if DEBUG:
        tron.warn(message)
예제 #2
0
 Jim M | cs.marlboro.edu | Feb 2014 

"""
import random, tron, time

DEBUG = False

if DEBUG:
    #      On csmarlboro.org, change 'everyone' to your username.
    #      Keep the rest of the path - that folder is world writable.
    #      This opens that file for appending, and writes one line
    #      to it with the date and time.
    logfile = '/var/www/csmarlboro/tron/logs/everyone.txt'
    tron.init_error_log(logfile)
    tron.warn("Starting logbot")   # Change this to whatever you like.

def debug(message):
    if DEBUG:
        tron.warn(message)

def which_move(board):
    """ Return the direction to move (1,2,3,4) given a Board object. """
    choices = board.moves()
    debug('')
    debug(' legal moves are' + str(choices))
    move = random.choice(choices)
    debug(' chosen move is ' + str(move))

    ## test: take longer than the 1 sec allowd.
    # time.sleep(2)