def markov_predict_test(simulator, state, solution):
    markov_agent = MarkovAgent(GameStateHandler(state).get_valid_positions())
    score = simulator.simulate_probability_agent(markov_agent,
                                                 markov_agent.predict)
    if type(solution) == int:
        return score >= solution
    return markov_agent.thoughts() == convert_solution(solution)
def markov_listen_test(simulator, state, solution):
    markov_agent = MarkovAgent(GameStateHandler(state).get_valid_positions())
    score = simulator.simulate_probability_agent(markov_agent,
                                                 markov_agent.listen)
    if type(solution) == int:
        return score >= solution
    return roundThoughts(markov_agent.thoughts()) == roundThoughts(
        convert_solution(solution))
def particle_listen_test(simulator, state, solution):
    particle_agent = ParticleAgent(
        GameStateHandler(state).get_valid_positions())
    score = simulator.simulate_probability_agent(particle_agent,
                                                 particle_agent.listen)
    if type(solution) == int:
        return score >= solution
    return particle_agent.thoughts() == convert_solution(solution)
def particle_reweight_test(simulator, state, solution):
    # Don't actually need simulator for this test
    # To make our lives simple we will match the maps open tiles (for divisibility purposes) when giving a particle count

    valid_positions = GameStateHandler(state).get_valid_positions()
    grid = ParticleGrid(valid_positions, len(valid_positions) * SCALE_FACTOR)

    # Generate a random distribution
    dist = {key: random.random() for key in grid.get_particle_distribution()}

    # Reweight the particles
    grid.reweight_particles(dist)
    return roundThoughts(grid.get_particle_distribution()) == roundThoughts(
        convert_solution(solution))
def particle_reset_test(simulator, state, solution):
    # Don't actually need simulator for this test
    # To make our lives simple we will match the maps open tiles (for divisibility purposes) when giving a particle count

    valid_positions = GameStateHandler(state).get_valid_positions()
    grid = ParticleGrid(valid_positions, len(valid_positions) * SCALE_FACTOR)

    particle_dist = grid.get_particle_distribution()

    # Mess up the distribution
    for key in particle_dist:
        particle_dist[key] = random.random()

    # Reset the distribution
    grid.reset()

    return grid.get_particle_distribution() == convert_solution(solution)