Hi! I’m Daniel, a technical intern at SAS and a student at North Carolina State University. Reinforcement learning is an exciting strategy that is versatile and broadly useful in the fields of data science and machine learning. I implemented an intelligent Minesweeper-playing model using SAS reinforcement learning, and this article covers what it is, how it works, and how you could implement something similar by combining open source software with SAS Viya’s capabilities.
Reinforcement Learning
Reinforcement learning, a powerful machine learning strategy, specializes in motivating an agent to make the most beneficial decisions in its environment. Per Stanford: “Reinforcement Learning (RL) is a powerful paradigm for training systems in decision making.” This model impacts the world in many arenas, including in robot automation, natural language processing (NLP), and game AI.
What is Minesweeper?
Legendary and nostalgic, Minesweeper is simple to play yet difficult to master. The game’s objective is to avoid revealing any mines on its retro two-dimensional grid, which result in an instant loss. At the beginning of the game, the grid’s squares are unrevealed, and selecting a square reveals its value. In order to predict and avoid those sneaky bombs, all other revealed tiles display a number that represents the quantity of mines inside the square’s eight adjacent tiles. Each click is a tense gamble between survival or failure! If the player manages to reveal all non-bomb squares, they win the game.
Use Case Overview
This project applies the principles of reinforcement learning to create a model that learns to play Minesweeper using OpenAI Gym and SASrlenv. The Python environment sets up the game and sends it to SAS Viya to receive the model’s chosen action. Then, the game environment reacts to the model’s action and rewards or punishes it based on its level of success or failure. As the SAS model receives more and more feedback through training, it learns how to better play Minesweeper. This communicative back-and-forth process clearly showcases SAS software’s ability to integrate with open-source technology and results in some exciting projects.
This project has undergone several iterations, the first of which being a comprehensive Lua script that fully implements and displays the game of Minesweeper inside of Minecraft. Unfortunately, the Minecraft implementation of Lua did not have the tools to facilitate the full functionality for the project and RL model. Currently, the script has been adapted to receive information from Python using webhooks when the final demonstration is ready. As we’ve covered, Minesweeper’s mechanics and the model’s setup now take place in a Python project that communicates directly with SAS Viya. There’s a lot of moving pieces in this project! Having the ability to combine SAS Viya’s capabilities from my job with a couple of my favorite games was exciting, even if the project didn’t take the route I originally expected.
SAS Viya Reinforcement Learning Custom Environment
While many tools and libraries exist for setting up reinforcement learning, SAS’ custom reinforcement learning environment functionality interacts with OpenAI’s gym library. To get a model running, users create a specific file structure that uses gym to initialize and run the model. Once started, the local python project communicates back and forth with SAS Viya servers, who accomplish the computationally expensive task of selecting the model’s choice of action from its action set, or list of available options. The environment evaluates the action based on its degree of success or failure, and responds by rewarding or punishing the action accordingly, earning this strategy the name of Reinforcement Learning. To set up this custom environment for yourself, some tutorials are linked at the article’s conclusion. Here’s another interesting example of a custom SASrlenv environment.
Conclusion
Throughout this project, I cherished the opportunity to combine my passion about my favorite games with the software I work with daily. SAS Viya’s machine learning capabilities are powerful and versatile, and I encourage anyone with access to Viya to explore the boundaries of its interactions with the open-source software they prefer. To craft your own reinforcement learning model with SAS, check out our documentation and this comprehensive tutorial. You can try it out on your own by accessing this 14-day free trial for SAS Viya. Happy coding!
Want to learn more?
What is Reinforcement Learning? – Overview of How it Works | Synopsys
9 Real-Life Examples of Reinforcement Learning | SCU Leavey
1 Comment
Hi Daniel,
Could you help me with an idea and/or link?
I'm looking for an AI that can write a report based on numbers - the AI it should convert numbers to textual data - I do have some challenges i.e. I have "only" SAS Enterprise Guide version 8 on 9.4 platform and no testers except myself but yeah, I am willing to experiment with Natural Language, can you help me with this?
We would have four SAS EG outputs, currently feeding an Excel file - pretty large datasets, as the basis.
Like " the biggest moves are observed in dept x/y " (AI should identify which are the biggest deltas and proceed to analysing the data to know which particular Dept is underlying reason for the move)
Currently humans are doing the analysis (and the writing)
Any ideas for me?
Thanks,
B.R.,
Heleen