Using Python to build an AI to play and win SNES StreetFighter II with machine learning
**Title: Revolutionizing Gaming: How Adam Fletcher and Jonathan Mortensen Used AI to Create an Unforgettable Street Fighter 2 Tournament**
---
**Introduction to Adam Fletcher and Jonathan Mortensen**
Adam Fletcher and Jonathan Mortensen, the dynamic duo behind Gyroscope Software, are innovators in the world of developer tools powered by artificial intelligence. Their journey began with a challenge: creating something engaging for the Samsung Developer Conference that would captivate an audience typically bored by traditional tech demos.
**The Invitation to the Samsung Developer Conference**
Gyroscope Software, known for its developer tools, received an invitation to showcase their work at the Samsung Developer Conference. The team faced a dilemma: how to make their booth stand out. Instead of offering t-shirts and looping videos, they envisioned something extraordinary—a real-time AI versus AI Street Fighter 2 tournament.
**The Decision to Create an AI-Powered Street Fighter**
Adam and Jonathan decided to leverage their expertise in AI to create an AI-powered Street Fighter 2 bot. This decision marked the beginning of a groundbreaking project that combined gaming, machine learning, and real-time strategy.
**Technologies Employed: Gym, KerasRL, BizHawk**
The duo utilized several key technologies:
- **OpenAI Gym**: Provided a framework for creating a retro gaming environment.
- **KerasRL**: Enabled reinforcement learning to train their AI agent.
- **BizHawk Emulator**: Allowed programmatic control of the Super Nintendo emulator.
These tools were crucial in setting up the game environment and training the AI.
**The Environment Setup**
Using Gym, they created an environment for Street Fighter 2 that replicated a human's view of the game. The observation space included health bars, timers, and character movements. They extracted these values directly from the game memory, ensuring an authentic experience without cheating.
**Reward Functions and Training Process**
A reward function was essential to guide the AI towards winning. Initially experimenting with various rewards like win/loss and health differences, they settled on measuring health deltas. This provided a continuous reward signal, crucial for efficient training.
**Controller Development Using Python**
The team developed a controller using Python's standard library, leveraging TCP sockets for communication between the emulator and AI. This setup allowed them to control the game and send actions efficiently.
**Results of the Tournament**
After extensive training, their AI achieved an 80% win rate against the Super Nintendo CPU on hard difficulty. The tournament at the conference featured a bracket format with characters like Ryu and Sagat, showcasing the AI's prowess.
**Audience Reaction and Booth Success**
The booth was a hit, drawing crowds eager to watch the AI in action. A highlight video demonstrated the AI dodging attacks, blocking, and executing special moves, leaving onlookers amazed.
**Backgrounds of Adam and Jonathan**
Adam, with a background in business and software reliability engineering, brought practical experience. Jonathan, a PhD holder from Stanford, contributed his expertise in machine learning. Their diverse skills were instrumental in the project's success.
**Future Implications and Potential for AI in Gaming**
Their work opened new possibilities for AI in gaming, suggesting that machines could master complex games through deep reinforcement learning. This has implications beyond gaming, impacting fields like robotics and autonomous systems.
**Q&A Session Insights**
During discussions, they highlighted challenges like hyperparameter tuning and the importance of understanding domain-specific knowledge. They also shared anecdotes about their journey, emphasizing the value of learning from failures in AI development.
**Conclusion**
Adam Fletcher and Jonathan Mortensen's project at the Samsung Developer Conference was a testament to the power of AI in gaming. Their innovative approach not only captivated the audience but also paved the way for future advancements in artificial intelligence. As they continue their work, their story inspires others to explore the potential of AI in diverse applications.