Skip to content
DeepForgeby svx
All problems

Episodic Memory Bonus

Problem

Compute a novelty bonus from the distance to the nearest state in episodic memory.

Return 1 / (1 + d_min) where d_min is the smallest Euclidean distance from state to any memory entry. An empty memory returns 0.0.

Hint

Revisiting a state within the same episode gives no novelty reward.

Test cases

case 1
in: [[0,0],[[0,0],[1,1]]]
expected: 1
case 2
in: [[3,4],[[0,0]]]
expected: 0.16666666666666666
case 3
in: [[1],[]]
expected: 0
Starter codePython
import math
def episodic_memory_bonus(state, memory):
    # Your code here
    pass

3 test cases · run your code against them in the editor