I’m working on a breakout-style game using a JavaScript neural network library for AI control. My setup includes a paddle that moves horizontally and a bouncing ball. I haven’t added bricks yet to keep things simple.
The neural network receives three inputs:
Ball’s X coordinate
Ball’s Y coordinate
Paddle’s X coordinate
The output determines movement:
Values above 0.5 move paddle left
Values below 0.5 move paddle right
I’m running a genetic algorithm with multiple AI agents. Each agent controls a paddle until it misses the ball. I track hits as fitness scores, then breed the best performers and add mutations to create the next generation.
Despite trying both simple perceptron and LSTM networks, the AI doesn’t seem to improve. The best result was 7 consecutive hits, but agents keep repeating the same movements. Even with LSTM architecture and 700+ agents over many generations, performance stays poor.
Your agents are probably stuck in deterministic loops - they’re seeing the same game states over and over. I’ve hit this exact issue before when the ball spawn and physics were too predictable. You need way more randomization in your starting conditions. Don’t just tweak ball position - really shake up the initial velocity angles and speeds between runs. This forces the network to actually learn instead of just memorizing bounce patterns. Here’s what worked for me: track paddle efficiency, not just hits. An agent that moves less while hitting the same amount is actually better. This stops those crazy left-right spam movements where they’re just flailing around. Your mutation rate’s probably too low too. With 700+ agents, you need higher rates to break out of local optima. Try variable mutation that ramps up when your population fitness gets stuck for multiple generations.
Your network architecture looks fine - the real issue is input representation. I hit this same problem building AI for a physics sim game.
Three inputs aren’t enough context. Your AI has no clue where the ball’s headed, so it’s playing blind. Add ball velocity X and Y inputs. Now it can predict instead of just react.
That movement logic is way too binary. Don’t use hard left/right at 0.5 - try continuous movement instead. Map network output straight to paddle velocity or position changes. Way better control.
For the genetic algorithm - your population’s probably too similar. If agents keep doing the same stuff, either your mutation rate’s too low or selection pressure’s too high. Keep more “bad” agents each generation. They sometimes carry useful genes that don’t pay off until later.
One thing that really helped me: add a time component. Track how long each agent survives, not just hits. An agent that lives longer but hits less might have better defensive positioning.
Also check your game physics. If the ball bounces the same way every time, your AI might be overfitting to specific patterns instead of learning actual paddle control.
Your network’s probably fine - the issue is your training pipeline. I’ve hit this exact problem building game AI at work.
Genetic algorithms work, but you need way better data tracking. You’re losing valuable insights because you can’t see what’s happening between generations.
Automate everything with proper logging and visualization. Set up automated data collection for agent performance, mutation tracking, and real-time fitness monitoring. Build dashboards that show exactly where agents fail and which genetic combinations actually work.
Also automate different reward experiments - distance-based rewards, velocity predictions, combination scoring. Run them in parallel and let automation find what works best.
You need a system managing hundreds of training runs while collecting detailed metrics. Manual experimentation won’t give you the data depth to solve this.
Latenode handles this complex training automation perfectly. Build workflows that manage genetic algorithms, collect performance data, and adjust parameters automatically based on results.
The primary issues here stem from your reward structure and the way inputs are represented. When I developed an AI for Pong, I encountered similar challenges. If you only reward the AI for successful hits, it receives no feedback until a correct action occurs, which can hinder learning. Consider implementing a distance-based reward system that provides feedback for staying near the ball’s potential landing area. This gives agents a clearer learning pathway.
Additionally, ensure that your input data is normalized. Using raw coordinate values can lead to instability in training. Normalize your inputs to a scale from -1 to 1, relative to the game boundaries.
Including the ball’s velocity as an input alongside its position will also help the network to anticipate movements rather than just react to them. If you’re experiencing repetitive movements, it’s likely because the network has settled into a suboptimal strategy that’s not truly learning the game’s dynamics. It’s becoming trapped in a local minimum.
your fitness function’s too basic - just counting hits won’t teach the ai much about positioning. try rewarding it based on how close the paddle gets to the intercept point when the ball comes down. even if it misses, you’re still reinforcing the right behavior.