We invented a mathematical game, which i am going to explain here.
The first player choose a natural number, lets call it $n$ (if you play it for real, you must choose a sufficiently big number so the game is interested).
The second player remove a square ${k_1}^2$ from that number, so that $n-{k_1}^2>0$.
The first player remove again a square ${k_2}^2$ and so on until $$n-\sum_i {k_i}^2=1.$$
The player who gets to $1$ win.
This is the algorithm (Sagemath) we used to model when the second player is winning :
def strat(n,L=[]):
l=len(L)+1
while l<n:
suivant=True
i=1
while i^2<l and suivant:
if L[l-i^2-1]==0:
L.append(1)
l+=1
suivant=False
i+=1
if suivant:
L.append(0)
l+=1
return L
We already proved that for a given number $n$ either player 1 or player 2 wins. We also proved that winning integers for the second player will tend to $1$ when $n$ tends to infinity.
We think this proportion can be modeled by $$p(n)=1-\frac 1{\sqrt n}.$$
We would like to prove these statements without heuristics arguments.
Finally, we would love to have a close formula to determine which are the winning integers for the second player.
What progresses did we make thanks to the comments ?
It seems that this question is related to this one, with square instead of prime numbers mainly.
One can then wonder for a more general result about this kind of question. If $E$ is a subset of $\mathbb N$ such that $E$ has a density of $0$, we can play the same game with picking numbers of $E$. In our case, we took $E:=\{n^2,\ n\in \mathbb N_{\geq 1}\}$.