color game algorithm bdg