How to program and avoid collisions

Hello Folks ,

I am trying to develop a simulation where I am moving random boxes using keyframe animations . As of now I have not declared them as rigid objects and they pass through each other upon collision. I wanted to know about how I can go for collision programming and avoid it dynamically if arises in keyframe animation.

I am programing in python where I initially decide the insertion of keyframe and move the boxes. I am looking for dynamic logic to decide they don’t collide each other in middle of animation.