AlexTheM8 / AiAi-AI

3 stars 0 forks source link

Parallelize End-State checks #16

Open AlexTheM8 opened 2 years ago

AlexTheM8 commented 2 years ago

Currently, the end-state check of [Goal, Time Over, Fall Out] are done sequentially in the following code block:

   if img_similarity(img, time_over, to_shape):
        g_max -= 25  # [-25, 25]
        done, info = True, 'Time Over'
    elif img_similarity(img, fall_out, fo_shape):
        g_max -= 50  # [-50, 0]
        done, info = True, 'Fall Out'
    elif img_similarity(img, goal, g_shape):
        g_max = 30 + (1.25 * (60 - (perf_counter() - st)))  # [30, 105]
        done, info = True, 'Goal'

This is an inefficient manner of resolving this issue and could be done simultaneously. Another potential boost could be packaging the Goal state check with the goal-detection (which could also be done at the same time, if not detrimental to execution time.