Gate game in Python