LLMs can build an internal world model and use it at inference time in order to understand spatial problems and rulesets. It's part of the often overlooked "How does it do that though?" counterpart to the often repeated "It's just predicting the next most likely token." Here's the write-up I've found that's the most clear, there are several other papers and ongoing research finding this though: https://thegradient.pub/othello/