예제 #1
0
    state = simulate_clicker(provided.BuildInfo(), time, strategy)
    print strategy_name, ":", state

    # Plot total cookies over time

    # Uncomment out the lines below to see a plot of total cookies vs. time
    # Be sure to allow popups, if you do want to see it

    # history = state.get_history()
    # history = [(item[0], item[3]) for item in history]
    # simpleplot.plot_lines(strategy_name, 1000, 400, 'Time', 'Total Cookies', [history], True)


def run():
    """
    Run the simulator.
    """
    run_strategy("Cursor", SIM_TIME, strategy_cursor_broken)

    # Add calls to run_strategy to run additional strategies
    run_strategy("Cheap", SIM_TIME, strategy_cheap)
    run_strategy("Expensive", SIM_TIME, strategy_expensive)
    #run_strategy("Best", SIM_TIME, strategy_best)


#run()
#print strategy_expensive(0.0, 1.0, [(0.0, None, 0.0, 0.0)], 5.0, provided.BuildInfo({'A': [5.0, 1.0], 'C': [50000.0, 3.0], 'B': [500.0, 2.0]}, 1.15))
print simulate_clicker(
    provided.BuildInfo({'Cursor': [15.0, 0.10000000000000001]}, 1.15), 15.0,
    strategy_cursor_broken)
예제 #2
0
my_test.buy_item("Test item", 100, 1)
my_suite.run_test(my_test.get_cookies(), 11)
my_suite.run_test(my_test.get_cps(), 2)
my_suite.run_test(my_test.get_history(), [(0.0, None, 0.0, 0.0),
                                          (111.0, 'Test item', 100, 111.0)])

my_test = cook.ClickerState()
res = cook.ClickerState()
res.current_cookies = 6965195661.0
res.total_cookies = 153308849166.0
res.current_time = 10000000000.0
res.current_cps = 16.1
my_suite.run_test(
    str(
        cook.simulate_clicker(provided.BuildInfo(), cook.SIM_TIME,
                              cook.strategy_cursor_broken)), str(res))

print 'LOOK HERE'
print cook.simulate_clicker(provided.BuildInfo({'Cursor': [15.0, 50.0]}, 1.15),
                            16.0, cook.strategy_cursor_broken)

my_suite.report_results()
print(str(my_test))

#[-11.1 pts]
# simulate_clicker(provided.BuildInfo({'Cursor': [15.0, 50.0]}, 1.15), 16.0, < function strategy_cursor_broken at 0xfb40a2b0 >)
# expected obj: Time: 16.0 Current Cookies: 13.9125 CPS: 151.0 Total Cookies: 66.0 History(length: 4): [(0.0, None, 0.0, 0.0), (15.0, 'Cursor', 15.0, 15.0), ..., (16.0, 'Cursor', 19.837499999999999, 66.0)]
# but received(printed using your __str__ method)
# Current time: 16.000000 Current cookies: 34.000000 Total cookies: 66.000000, , , Current CPS: 101.000000
def run_strategy(strategy_name, time, strategy):
    """
    Run a simulation for the given time with one strategy.
    """
    state = simulate_clicker(provided.BuildInfo(), time, strategy)
    print strategy_name, ":", state
예제 #4
0
def run_strategy(strategy_name, time, strategy):
    """
    Run a simulation for the given time with one strategy.
    """
    state = simulate_clicker(provided.BuildInfo(), time, strategy)
    print("Chosen Strategy: " + strategy_name.upper() + "\n" + str(state))
예제 #5
0
def run():
    """
    Run the simulator.
    """
    run_strategy("Cursor", SIM_TIME, strategy_cursor_broken)
    #run_strategy("None", SIM_TIME, strategy_none)

    # Add calls to run_strategy to run additional strategies
    # run_strategy("Cheap", SIM_TIME, strategy_cheap)
    # run_strategy("Expensive", SIM_TIME, strategy_expensive)
    # run_strategy("Best", SIM_TIME, strategy_best)


#run()

#simulate_clicker(provided.BuildInfo({'Cursor': [15.0, 0.10000000000000001]}, 1.15), \
#                 5000.0, strategy_none)
"""
build_info = provided.BuildInfo({'Cursor': [15.0, 0.10000000000000001]}, 1.15)
print build_info.build_items()
print build_info.get_cost("Cursor")
print build_info.get_cps("Cursor")
print build_info._info["Cursor"]
print build_info.get_cost("Cursor")*build_info._build_growth
build_info.update_item("Cursor")
"""

simulate_clicker(provided.BuildInfo({'Cursor': [15.0, 0.10000000000000001]}, 1.15), \
                 500.0, strategy_cursor_broken)
예제 #6
0

def run():
    """
    Run the simulator.
    """
    #run_strategy("Cursor", SIM_TIME, strategy_cursor_broken)

    # Add calls to run_strategy to run additional strategies
    #run_strategy("Cheap", SIM_TIME, strategy_cheap)
    #run_strategy("Expensive", SIM_TIME, strategy_expensive)
    run_strategy("Best", SIM_TIME, strategy_best)
    #run_strategy("Best - 2", SIM_TIME, strategy_best_2)


BUILD_ORIGINAL = provided.BuildInfo()
BUY_LIST_BEST = gen_buy_list(BUILD_ORIGINAL, 90)
BUY_LIST_ORIGINAL = gen_buy_list(BUILD_ORIGINAL, 1)

#run()

#test = ClickerState()
#print test
#print math.ceil((6.0 - 1.0) / 2.0)

# test time_until()
#state = ClickerState()
#build = provided.BuildInfo()
#print build.get_cost("Cursor")
#time_needed = state.time_until(build.get_cost("Cursor") - state.get_cookies())
#print time_needed
예제 #7
0
    return(clicker_state)


def strategy_cursor_broken(cookies, cps, history, time_left, build_info):
    """
    Always pick Cursor!

    Note that this simplistic (and broken) strategy does not properly
    check whether it can actually buy a Cursor in the time left.  Your
    simulate_clicker function must be able to deal with such broken
    strategies.  Further, your strategy functions must correctly check
    if you can buy the item in the time left and return None if you
    can't.
    """
    return "Cursor"
print simulate_clicker(provided.BuildInfo({'Cursor': [15.0, 0.1]}, 1.15), 500.0, strategy_cursor_broken)
def strategy_none(cookies, cps, history, time_left, build_info):
    """
    Always return None

    This is a pointless strategy that will never buy anything, but
    that you can use to help debug your simulate_clicker function.
    """
    return None
# print simulate_clicker(provided.BuildInfo({'Cursor': [15.0, 0.1]}, 1.15), 15.0, strategy_none) 
def strategy_cheap(cookies, cps, history, time_left, build_info):
    """
    Always buy the cheapest item you can afford in the time left.
    """
    cookies += time_left * cps
    items =  build_info.build_items()
예제 #8
0
import poc_simpletest
import poc_clicker_provided as provided

TESTSUITE = poc_simpletest.TestSuite()
BuildInfo = provided.BuildInfo()
SIM_TIME = 10000000000.0


def phase_one_tests(ClickerState):
    test = ClickerState()

    # Initialization
    TESTSUITE.run_test(
        str(test.get_cookies()), "0.0",
        "Test 1: Initial amount of cookies should be equal 0.0")
    TESTSUITE.run_test(str(test.get_time()), "0.0",
                       "Test 2: Initial time should be equal 0.0")
    TESTSUITE.run_test(str(test.get_cps()), "1.0",
                       "Test 3: Initial CPS should be equal 1.0")
    TESTSUITE.run_test(
        str(test.get_history()), "[(0.0, None, 0.0, 0.0)]",
        "Test 4: Initial history should be [(0.0, None, 0.0, 0.0)]")
    TESTSUITE.run_test(
        str(test.time_until(5.1)), "6.0",
        "Test 5: time_until should return float without fractional part")
    TESTSUITE.run_test(
        str(test.time_until(0.0)), "0.0",
        "Test 6: time_until should return 0.0 if given amount of cookies <= current cookies"
    )

    test.wait(5)