torus and mass shifter model

Hi guys,
I am developing a model in blender 3D using python script in which a torus is made to move around in a fixed path. At the center of the torus there exists a block of cube which moves side to side in order to keep the torus moving forward without falling even after if it is hit by an external object. Can anyone help me how to develop the model?

You should probably try to outline what you want to do in greater detail and post any .blends if you have made something.

Otherwise we’ll be like:

Somehow I can’t really imagine something that makes sense. Can you provide a sketch?

What let the torus move?
When does the torus move?
What path (staight, curve, circle)?

One Cube? Multiple cubes?
What makes the cubes move and where?
When does a cube move?
What is the relation between cubes and torus?