My program isn't doing what I want it to do (x and o game / Tic Tac Toe)

I made a 3D Tic tac toe now with an AI based on your rules

I also made a random player and the AI played the random player overnight with 156000 games. It didn’t loose one game.
(now >260.000 games but I don’t think that automatically means, the AI plays perfect)