OneTrickPony wrote:So what we do is check every time_tick if there is something on stdin, if so we call fgets routine, if not we continue with search ?
I worry that doing it this way I will have to pollute my code with stdin checks all over the place.
In my engines I check in only one place, which is the same place as where I check the time if the engine is thinking. But of course I only have a single Search() routine, and not zillions of versions for white, black, pv-, cut-, all-nodes, QS, etc. But I guess it would be enough to only check for time or input in two of them (e.g. white and black cut nodes), as it will never take long until you get to one of those. You want to make such check only once every 1000 nodes or so anyway, as they are relatively expensive, and you won't need sub-millisecond response to input. (You won't get that anyway, even if your program would heve instant response, due to system overhead.)
That wouldn't be ideal as I would like my engine to be separate entity which can work without UCI-like interface as well (so I script for it or write an API with functionality to call search(20 seconds) for example).
I don't see why that would be a problem. If you have a call to TerminationCheck() in a few critical places, which sets an abortFlag to unwind the search depending in time, pending input and mode, you could simply define a mode that would make it return immediately in situations where you want non-abortable search.
Also I would really like to confine all Windows specific calls into one place (so it's easy to replace that one file for other OS'es) and keep rest of the code in pure C.
Well, so define subroutines ReadClock() and InputPending() in the platform-dependent sections, and call those from TerminationCheck(). You could look in the HaChu source code to see an example.