gravity algorithm

first fail to get the algorithm working