interactive python implementation of the rules