If the moves consist of taking either $a$ or $b$ sticks, with $a\lt b$ and, as clarified in a comment, $N\lt a$ is a loss, then the first player wins iff $((N-1)\bmod(a+b))\bmod(2a)\lt a$, and a winning strategy is to take $a$ sticks if $(N-1)\bmod(a+b)\gt b$, take $b$ sticks if $(N-1)\bmod(a+b)\lt a$, and take either otherwise.
It's not a nim game, it's an Hackenbush game (Blue-Red version if $A\cap B=\emptyset$)
Replace each number by a line segment of color red for number from $A$, and blue for $B$. To each pile of number, build a pile of line segment, by decreasing order of number.
For example, if $A$ are even numbers, and $B$ are odd numbers, the pile $[3,4,7,8,10]$ will be replace by ground-red(for 10)-red(for 8)-blue(for 7)-red(4)-blue(3).
Hackenbush games are not nim games. To each finite position can be assigned a dyadic number whose sign will give the player who can win.
EDIT : strategy explained for player x :
To each number (from $A$) in each pile, $x$ will assign a value that will be :
- $1$ if this the largest number of the pile
- $1$ if the next larger number was assigned 1 and is from the same set ($A$ or $B$)
- $2^{-n}$ where $n$ is the distance to the closest number with value $1$.
Example : in pile [10,8,7,4,3,1], 10 will have value 1 (by rule 1), 8 value 1 (by rule 2), and 4 value $\frac{1}{4}$ (by rule 3).
For player y, 7 will be assigned value $\frac{1}{2}$ (rule 2 does not apply here because the next larger number 8 is not from the same set, so rule 3), 3 value $\frac{1}{8}$, and 1 value $\frac{1}{16}$.
The best strategy is to remove the number of lowest value. (This is not the quickest strategy !)
If you add all values for player x and subtract all values for player y, a positive sum means player x has a winning strategy, negative sum is for player y while a zero sum means second player.
Best Answer
It is a nim game, but the state of the game consists of not just the number of sticks remaining, but also the last move done. Each of these pairs (sticks, last move) can be given a Sprague-Grundy number just as in any other Nim-type game.
However, in this case it is easier to just build a table listing all the winning moves for each number of sticks.
$$ \begin{array}{c|l} \text{Sticks} & \text{Winning Moves} \\ \hline 0 & - \\ 1 & 1\\ 2 & 1,2\\ 3 & 3\\ 4 & 4\\ 5 & 5\\ 6 & 3\\ 7 & -\\ 8 & 1,4\\ 9 & 2,3\\ 10 & 3,5 \\ ...& ... \end{array} $$
On each new line, simply list all the moves that (if available) would lead to a position with no winning moves available. For example, for 6 sticks 3 is a winning move cause it leads to a state where the only possible winning move (3) is no longer available.
I don't see any repeating pattern yet, even when extended up to 22.