Cyber attacks against Smart Grids (SG) have harmful effects. The first function of a defensive system is to provide an intelligent system to detect intrusions. The nature of attacks against smart grids is very complex, so the intrusion detection system must be able to detect complex attacks. Lack of balancing and optimization of deep learning methods are the main challenges for many intrusion detection systems. This research presents an intelligent intrusion detection system for a smart grid based on Game Theory, Swarm Intelligence, and Deep Learning (DL). First, the proposed method balances the training samples with a conditional DL technique based on Game Theory and CGAN. Secondly, the Aquila Optimizer (AO) algorithm selects features. The third step involves mapping the selected features on the dataset and coding reduced-dimension samples into RGB color images, which are used to train the VGG19 neural network. In the fourth step, the AO algorithm optimally adjusts meta-parameters to reduce the error of the VGG19 neural network. Tests performed on the NSL-KDD dataset show that the proposed method's accuracy, sensitivity, and precision in detecting attacks are 99.82%, 99.69%, and 99.76%, respectively. The CGAN method balances the dataset and increases the accuracy, sensitivity, and precision of the proposed method compared to the GAN method in detecting attacks on the smart grid. Experiments show that the proposed method more accurately detects attacks than deep learning methods such as VGG19, CNN-GRU, CNN-GRU-FL, LSTM, and CNN.