AI Makes Minesweeper

Every kid today is talking about the ultimate gaming experience: Minesweeper. Today, I'm going to show you how to build Minesweeper in less than 5 minutes in JavaScript using AI. We're going to open up Devra, and I've already set up some projects. I'm going to show you how to open up the Devra demos project and add a task. This task is going to describe what we want to build: create the JavaScript Minesweeper game, add all necessary files, and add modern styling. Click create and start, and let's see what happens.
It's going through the files right now to see what exists. It's come up with this proposal. I'm not going to read it, but let's just say that plan looks good. It's asking to make the index file. We'll say yes, create the file, and it'll pop up right here. There it is. It's asking me to create the style file. We'll say yes, create that file, and there it pops up. Now it's asking to make the script file. We're going to say yes, create that file, and that'll pop up. And that's all the files that we need: the basic HTML, the script, and the styling.
So let's go open this up and see what we get. Minesweeper, look at that! Okay, so it looks like it's showing where the bombs are, which isn't how the game exactly is, but let's just ask for a revision. Revise the script so that the bombs are not initially highlighted. It's asking to make this update, but I forgot another thing to add. Let's add it right now: add a way to put down flags, and also put instructions on the screen. It's asking to update the HTML, I guess for the instructions. It's asking to update the script file. Let's say update.
Now let's reload and see what we have. Left click to reveal a cell, right click to place a flag. Okay, sounds good. Hit a bomb immediately. All right, I'm going to right click, which is control click here. All right, good. Two are here. I'm going to put a flag there. There's a flag there, and then let's see if... all right, looking good. So we did it! Minesweeper. Go to Devra. The link is in the description. Get Devra to make your own games, and also there's a link to the GitHub where you can download this game that we made today. Take care!

View the video

Devra Logo

Devra: AI software and data science assistant