modularized some math functions. Server now assigns player color