Example #1
0
def play(method):
    score = throw.START_SCORE
    turns = 0

    if method == "mdp":
        target = mdp.start_game(GAMMA)
    else:
        target = modelfree.start_game()

    targets = []
    results = []
    while (True):
        turns = turns + 1
        result = throw.throw(target)
        targets.append(target)
        results.append(result)
        raw_score = throw.location_to_score(result)
        if raw_score <= score:
            score = int(score - raw_score)
        else:
            cc = 1
        if score == 0:
            break

        if method == "mdp":
            target = mdp.get_target(score)
        else:
            target = modelfree.get_target(score)

# print "WOOHOO!  It only took", turns, " turns"
#end_game(turns)
    return turns
Example #2
0
def play(method):
    score = throw.START_SCORE
    turns = 0
    
    if method == "mdp":
        target = mdp.start_game(GAMMA)
    else:
        target = modelfree.start_game()
        
    targets = []
    results = []
    while(True):
        turns = turns + 1
        result = throw.throw(target)
        targets.append(target)
        results.append(result)
        raw_score = throw.location_to_score(result)
        if raw_score <= score:
            score = int(score - raw_score)
        else:
            cc=1
        if score == 0:
            break

        if method == "mdp":
            target = mdp.get_target(score)
        else:
            target = modelfree.get_target(score)
            
   # print "WOOHOO!  It only took", turns, " turns"
    #end_game(turns)
    return turns
Example #3
0
def play(method):
    global actions
    actions = get_actions()

    score = throw.START_SCORE
    turns = 0
    
    if method == "mdp":
        target = mdp.start_game(GAMMA)
    else:
        target = modelfree.start_game()
        
    targets = []
    results = []
    while(True):
        turns = turns + 1
        result = throw.throw(target)
        targets.append(target)
        results.append(result)
        raw_score = throw.location_to_score(result)
        print "Target: wedge", target.wedge,", ring", target.ring
        print "Result: wedge", result.wedge,", ring", result.ring
        print "Raw Score:", raw_score
        print "Score:", score
        prior = score
        if raw_score <= score:
            score = int(score - raw_score)
        else:
            print
            print "TOO HIGH!"
        modelfree.q_learning(prior, score, get_index(actions, target))                        
        if score == 0:
            break

        if method == "mdp":
            target = mdp.get_target(score)
        else:
            target = modelfree.get_target(score)
            
    print "WOOHOO!  It only took", turns, " turns"
    #end_game(turns)
    return turns
Example #4
0
def play(method, d=None):
    score = throw.START_SCORE
    turns = 0

    if method == "mdp":
        target = mdp.start_game(GAMMA)
    else:
        target = modelfree.start_game()

    targets = []
    results = []
    while True:
        turns = turns + 1
        result = throw.throw(target)
        targets.append(target)
        results.append(result)
        raw_score = throw.location_to_score(result)
        if d:
            if d[score] == None:
                d[score] = throw.location_to_score(target)
            else:
                assert d[score] == throw.location_to_score(target)
        # print "Target: wedge", target.wedge,", ring", target.ring
        # print "Result: wedge", result.wedge,", ring", result.ring
        # print "Raw Score:", raw_score
        # print "Score:", score
        if raw_score <= score:
            score = int(score - raw_score)
        # else:
        #     print
        #     print "TOO HIGH!"
        if score == 0:
            break

        if method == "mdp":
            target = mdp.get_target(score)
        else:
            target = modelfree.get_target(score)
    # print "WOOHOO!  It only took", turns, " turns"
    # end_game(turns)
    return turns
Example #5
0
def play(method):
    score = throw.START_SCORE
    turns = 0
    
    if method == "mdp":
        target = mdp.start_game(GAMMA)
    else:
        target = modelfree.start_game()
        
    targets = []
    results = []
    while(True):
        turns = turns + 1
        result = throw.throw(target)
        targets.append(target)
        results.append(result)
        raw_score = throw.location_to_score(result)
        #if raw_score > score:
            # update Q[s][a]
        #else:
            #modelfree.Q_learning(score,target,raw_score)
        print "Target: wedge", target.wedge,", ring", target.ring
        print "Result: wedge", result.wedge,", ring", result.ring
        print "Raw Score:", raw_score
        print "Score:", score
        if raw_score <= score:
            score = int(score - raw_score)
        else:
            print
            print "TOO HIGH!"
        if score == 0:
            break

        if method == "mdp":
            target = mdp.get_target(score)
        else:
            target = modelfree.get_target(score)
            
    print "WOOHOO!  It only took", turns, " turns"
    #end_game(turns)
    return turns
Example #6
0
def play(method):
    score = throw.START_SCORE
    turns = 0

    if method == "mdp":
        target = mdp.start_game(GAMMA)
    else:
        target = modelfree.start_game()

    targets = []
    results = []
    while (True):
        turns = turns + 1
        result = throw.throw(target)
        targets.append(target)
        results.append(result)
        raw_score = throw.location_to_score(result)
        print "Target: wedge", target.wedge, ", ring", target.ring
        print "Result: wedge", result.wedge, ", ring", result.ring
        print "Raw Score:", raw_score
        print "Score:", score
        if raw_score <= score:
            score = int(score - raw_score)
        else:
            print
            print "TOO HIGH!"
        if score == 0:
            break

        if method == "mdp":
            target = mdp.get_target(score)
        else:
            target = modelfree.get_target(score)

    print "WOOHOO!  It only took", turns, " turns"
    #end_game(turns)
    return turns