Guessing the cards: some answers
First of all, obviously, if you keep betting on red you will always guess exactly N/2 cards. But there are better strategies.
You can keep saying “red” and count cards. Once you know that reds are out, keep saying “black”. This strategy allows to guess about 26.9 cards out of 52 on average. (I calculated this analytically).
Or you can count cards and say “red” if there are more reds left and say “black” otherwise. With this strategy you will guess about 30 cards out of 52 on average. (I calculated this on a simulation).
Keep in mind, if you want to simulate card games, use a reliable shuffling algorithm.