A very simple sixty-line python snippet that uses the OpenAI API to play against itself in a two player turn based game. I've experimented with a few different games, requiring only that GPT understands a way of notating turns, detecting invalid moves, and identifying a winner.
For most of these experiments (chess, checkers, etc.) it appears that older OpenAI engines struggle to comply with the prompts, while newer engines are fully compliant and show increasing amounts of sophistication in move selection. For all of the engines that I tested, the model will occasionally attempt to perform an invalid move, which the same engine can readily detect and correct when instructed. By allowing GPT multiple attempts to provide a valid move, the games are able to progress to an eventual winner, but it can take a long time (particularly if there are no repetition rules).
See the codelab below, but be warned that games can take a large number of API calls and GCP cycles to complete. This is a quick snippet with very little attention paid to formatting, safety, or robustness.