How to use mathy - 10 common examples

To help you get started, we’ve selected a few mathy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github justindujardin / mathy / mathy / agent / training / lessons.py View on Github external
def build_lesson_plan(group_name, lessons):
    parser = ExpressionParser()
    for i, lesson in enumerate(lessons):
        if not isinstance(lesson, LessonExercise):
            raise ValueError("array should contain only LessonExercise class instances")
        for i in range(lesson.problem_count):
            try:
                problem = None
                problem, complexity = lesson.problem_fn()
                parser.parse(problem)
            except (ParserException, TypeError) as e:
                raise ValueError(
                    "The problem_fn for lesson ({} - {}) produced an invalid problem: {}".format(
                        i, group_name, problem
                    )
                )
    return LessonPlan(group_name, lessons)
github justindujardin / mathy / mathy / agent / curriculum / level1.py View on Github external
problem_count=4,
            problem_fn=lambda: combine_terms_in_place(easy=False, powers=True),
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            mcts_sims=500,
            max_turns=3,
            num_observations=256,
        ),
        LessonExercise(
            lesson_name="three_terms_with_powers",
            problem_count=1,
            problem_fn=lambda: simplify_multiple_terms(3, powers=True),
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            mcts_sims=500,
            num_observations=256,
        ),
        LessonExercise(
            lesson_name="seven_terms_with_powers",
            problem_count=1,
            problem_fn=lambda: simplify_multiple_terms(7, powers=True),
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            mcts_sims=250,
            num_observations=256,
        ),
    ],
)

lesson_quick = build_lesson_plan(
    "combine_like_terms_1",
    [
        LessonExercise(
            lesson_name="two_terms",
            problem_count=1,
github justindujardin / mathy / mathy / agent / curriculum / level1 / yellow_belt.py View on Github external
lesson_name="move_then_simplify_1",
            problem_fn=lambda: combine_terms_after_commuting(),
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            mcts_sims=500,
            max_turns=4,
            num_observations=observations,
        ),
        LessonExercise(
            lesson_name="commute_blockers_2_3",
            problem_fn=lambda: move_around_blockers_two(3),
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            problem_count=4,
            mcts_sims=500,
            num_observations=observations,
        ),
        LessonExercise(
            lesson_name="combine_in_place_1",
            problem_fn=lambda: combine_terms_in_place(),
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            max_turns=3,
            mcts_sims=500,
            num_observations=32,
        ),
        LessonExercise(
            lesson_name="six_terms",
            problem_count=1,
            problem_fn=lambda: simplify_multiple_terms(6, powers_proability=0.85),
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            mcts_sims=500,
            num_observations=observations,
        ),
github justindujardin / mathy / mathy / agent / curriculum / level1.py View on Github external
[
        # LessonExercise(
        #     lesson_name="two_terms",
        #     problem_fn=lambda: simplify_multiple_terms(2),
        #     problem_type=MODE_SIMPLIFY_POLYNOMIAL,
        #     mcts_sims=100,
        #     num_observations=32,
        # ),
        # LessonExercise(
        #     lesson_name="three_terms",
        #     problem_fn=lambda: simplify_multiple_terms(3),
        #     problem_type=MODE_SIMPLIFY_POLYNOMIAL,
        #     mcts_sims=100,
        #     num_observations=32,
        # ),
        LessonExercise(
            lesson_name="four_terms",
            problem_fn=lambda: simplify_multiple_terms(4),
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            mcts_sims=200,
            num_observations=64,
        ),
        LessonExercise(
            lesson_name="move_then_simplify",
            problem_fn=lambda: combine_terms_after_commuting(12, 16),
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            max_turns=4,
            mcts_sims=500,
            num_observations=64,
        ),
        LessonExercise(
            lesson_name="simplify_in_place",
github justindujardin / mathy / mathy / agent / curriculum / level1 / yellow_belt.py View on Github external
num_observations=observations,
        ),
    ],
)
yellow_belt_practice = build_lesson_plan(
    "yellow_belt_practice",
    [
        LessonExercise(
            lesson_name="commute_blockers_1_3",
            problem_fn=lambda: move_around_blockers_one(3),
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            problem_count=4,
            mcts_sims=500,
            num_observations=observations,
        ),
        LessonExercise(
            lesson_name="five_terms",
            problem_count=4,
            problem_fn=lambda: simplify_multiple_terms(5, powers_proability=0.85),
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            mcts_sims=500,
            num_observations=observations,
        ),
        LessonExercise(
            lesson_name="move_then_simplify_1",
            problem_fn=lambda: combine_terms_after_commuting(),
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            mcts_sims=500,
            max_turns=4,
            num_observations=observations,
        ),
        LessonExercise(
github justindujardin / mathy / mathy / agent / curriculum / combine_like_terms_2.py View on Github external
#     num_exploration_moves=3,
        #     problem_fn=two_variable_terms,
        #     problem_type=MODE_SIMPLIFY_POLYNOMIAL,
        #     max_turns=10,
        #     mcts_sims=250,
        # ),
        LessonExercise(
            lesson_name="Three variable terms",
            problem_count=20,
            num_exploration_moves=5,
            problem_fn=three_variable_terms,
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            max_turns=15,
            mcts_sims=250,
        ),
        LessonExercise(
            lesson_name="Four variable terms",
            problem_count=10,
            problem_fn=four_variable_terms,
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            max_turns=25,
            num_exploration_moves=10,
            mcts_sims=750,
        ),
        LessonExercise(
            lesson_name="Five variable terms",
            problem_count=5,
            problem_fn=six_variable_terms,
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            num_exploration_moves=15,
            max_turns=30,
            mcts_sims=1000,
github justindujardin / mathy / mathy / agent / curriculum / level1.py View on Github external
LessonExercise(
            lesson_name="commute_grouping_3",
            problem_fn=lambda: combine_terms_after_commuting(8, 15, 3),
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            problem_count=4,
            mcts_sims=250,
            num_observations=32,
            max_turns=6,
        ),
    ],
)

white_belt_practice = build_lesson_plan(
    "white_belt_practice",
    [
        LessonExercise(
            lesson_name="commute_grouping_1",
            problem_fn=lambda: combine_terms_after_commuting(),
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            problem_count=4,
            max_turns=4,
            mcts_sims=500,
            num_observations=128,
        ),
        LessonExercise(
            lesson_name="five_terms_with_exponents",
            problem_count=4,
            problem_fn=lambda: simplify_multiple_terms(5),
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            mcts_sims=200,
            num_observations=128,
        ),
github justindujardin / mathy / mathy / agent / curriculum / level1 / green_belt.py View on Github external
maybe_int,
    maybe_power,
    rand_bool,
    rand_var,
    simplify_multiple_terms,
    combine_terms_after_commuting,
    combine_terms_in_place,
    move_around_blockers_one,
    move_around_blockers_two,
)

observations = 128
green_belt = build_lesson_plan(
    "green_belt",
    [
        LessonExercise(
            lesson_name="eight_terms",
            problem_count=1,
            problem_fn=lambda: simplify_multiple_terms(8, powers_proability=0.85),
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            mcts_sims=200,
            num_observations=observations,
        ),
        LessonExercise(
            lesson_name="simplify_in_place_8_9",
            problem_fn=lambda: combine_terms_in_place(8, 9),
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            max_turns=5,
            mcts_sims=200,
            num_observations=observations,
        ),
        LessonExercise(
github justindujardin / mathy / mathy / agent / curriculum / level1.py View on Github external
lesson_name="six_terms_with_exponents",
            problem_count=4,
            problem_fn=lambda: simplify_multiple_terms(6, powers=True),
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            mcts_sims=50,
            num_observations=32,
        ),
        LessonExercise(
            lesson_name="eight_terms_with_exponents",
            problem_count=4,
            problem_fn=lambda: simplify_multiple_terms(8, powers=True),
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            mcts_sims=50,
            num_observations=32,
        ),
        LessonExercise(
            lesson_name="commute_blockers_1_7",
            problem_fn=lambda: move_around_blockers_one(7),
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            problem_count=4,
            mcts_sims=50,
            num_observations=32,
        ),
        LessonExercise(
            lesson_name="ten_terms_with_exponents",
            problem_fn=lambda: simplify_multiple_terms(10, powers=True),
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            problem_count=4,
            mcts_sims=50,
            num_observations=32,
        ),
        LessonExercise(
github justindujardin / mathy / mathy / agent / curriculum / level1 / green_belt.py View on Github external
lesson_name="simplify_in_place_8_9",
            problem_fn=lambda: combine_terms_in_place(8, 9),
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            max_turns=5,
            mcts_sims=200,
            num_observations=observations,
        ),
        LessonExercise(
            lesson_name="move_then_simplify_8_9",
            problem_fn=lambda: combine_terms_after_commuting(8, 9),
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            max_turns=5,
            mcts_sims=200,
            num_observations=observations,
        ),
        LessonExercise(
            lesson_name="nine_terms",
            problem_count=1,
            problem_fn=lambda: simplify_multiple_terms(9, powers_proability=0.85),
            problem_type=MODE_SIMPLIFY_POLYNOMIAL,
            mcts_sims=200,
            num_observations=observations,
        ),
    ],
)

green_belt_practice = build_lesson_plan(
    "green_belt_practice",
    [
        LessonExercise(
            lesson_name="eight_terms",
            problem_count=1,