4 ms·
What the heck is the trivial one liner to check who will win a chess game given both players play perfect?
by skizm 8y ago
What the heck is the trivial one liner to check who will win a chess game given both players play perfect?
- d4rti 8y agoI can only come up with a recursive algorithm which depends on a PerfectPlay(state, player) like so: WinnerWithPerfectPlay(state,currentPlayer): if Winner(state) return Winner(state) else nextPlayer <- "white" if currentPlayer = "black" else "black" return WinnerWithPerfectPlay(PerfectPlay(state, player), nextPlayer) Which doesn't allow for stalemate moves.
- kirkules 8y agoI suppose the claim of the existence of this one liner might be the same as the claim that one of the players can always force a win, in which the line is something like "return 'white'" or "return 'draw'"
- plin25 8y agoI believe this is a trick question. The "standard" chess board is 8x8, with a 32 possible pieces. This gives you a constant (albeit absurdly large) number of configurations, which means that the one-line solution "Brute Force" is an O(1) algorithm.