I'm writing a text-based game, in C. I want the game to handle NPCs movement and actions in the background, while the user is making his moves. I'd also use time-based events to tell the user when midnight is (in game-time), or to activate certain things at certain times.
I know that Dwarf Fortress is all single thread stuff, but I can't understand how that's done. I don't know how he handles events. Surely he's not polling.
I've never done any thread programming, or anything with sockets. I've been programming for a while, but I know nothing about those things.
I googled options, but there seems to be a lot of stuff that comes under the heading of event-handling. I have no idea where to start. The first idea that comes to mind, is have two separate programs communicating through a text file, but that seems like a very ugly solution.
What's the simplest solution to handle events such as I described?
I'm currently working in Windows but I would switch over to linux if it's easier. I just happened to be using a Windows machine when I started, so it doesn't matter which.