       states[i].agent.nextAction = Int(actions[i].scalarized())
       try states[i].simulator.step()
       let agentState = states[i].simulator.agentStates.values.first!
+      let rewardFunction = configurations[i].rewardSchedule.reward(
+        forStep: states[i].simulator.time)
       let observation = Observation(
         vision: Tensor<Float>(agentState.vision),
         scent: Tensor<Float>(agentState.scent),
-        moved: Tensor<Bool>(agentState.position != previousAgentState.position))
-      let rewardFunction = configurations[i].rewardSchedule.reward(
-        forStep: states[i].simulator.time)
+        moved: Tensor<Bool>(agentState.position != previousAgentState.position),
+        rewardFunction: rewardFunction)
       let reward = Tensor<Float>(rewardFunction(for: AgentTransition(
         previousState: previousAgentState,
         currentState: agentState)))

    public var vision: Tensor<Float>
    public var scent: Tensor<Float>
    @noDerivative public var moved: Tensor<Bool>

    @inlinable
    public init(vision: Tensor<Float>, scent: Tensor<Float>, moved: Tensor<Bool>) {
      self.vision = vision
      self.scent = scent
      self.moved = moved
    }
  }
}

        Observation(
          vision: visionDistribution.mode(),
          scent: scentDistribution.mode(),
          moved: movedDistribution.mode() .> 0,
          rewardFunction: nil)
      }

      @inlinable
