Minesweeper AI

I got addicted to Minesweeper the first few days when I started playing this awesome puzzle game. Solving the game faster every few times gives me great satisfaction of self-fulfillment. However, for the “expert” board setting, where 99 mines are hidden within a 16×30 square grid, I had never obtained a score lower than 100 seconds. Curious of what the fastest solving rate is the one can achieve, I designed a Minesweeper AI program that can automatically play the Windows Minesweeper game.

C language is used for programming, and the algorithm flowchart is displayed in Fig. 1.

Figure 1. Algorithm flowchart of the Minesweeper AI program.

Here breadth-first-search (BFS) is used to search for uncovered squares on the grid, and a queue is used for saving uncovered squares to be analyzed. A game-playing optimized algorithm is written inside the program, and OpenCV is used to take a snapshot of the Minesweeper window region and process the image for subsequent calculations. Mouse movement and click actions are realized by including the windows.h header.

The usage of the program is relatively simple. The user should only execute the Minesweeper game program, and modify the game setting beforehand. After opening the AI .exe file, the program will automatically locate the Minesweeper game, calculate the dimensions, then start playing. If a mine is accidentally clicked, the program will continue to play the next game until a fully uncovered board is achieved.

Here is a clip demonstrating the Minesweeper AI playing an expert level game and winning in 7 seconds. It failed on the first try almost at the end, but succeeded on the second try.

[Download program for the Minesweeper AI (Can only run on a windows 64-bit OS)]

Miniaturized ELISA Platform

Studying in a cross-disciplinary department meant having the freedom to choose what to explore. I entered the intelligence bio-sensing lab (previously named bio-molecular device lab) hosted by professor Lin-Chi Chen when I was a junior. There I was trained how to put into practice the engineering skills that I have learned during college, and implementing them on biosensing. I became interested in manufacturing devices that can realize automation, assist research, or help reduce the cost for lab experiments (e.g. Real-time Impedance Detection Systems, Surface Plasmon Resonance Platform, Automated Microfluidic Controlling Platform). This miniaturized ELISA platform serves as the first one among those devices and systems I had created.

The enzyme-linked immunosorbent assay (ELISA) is a commonly used analytical biochemical assay that uses antibodies against the protein to be tested to detect the presence of ligands (usually proteins) in the liquid sample. However, the traditional method for performing this assay is costly and time-consuming. Therefore, I decided to construct a miniaturized ELISA platform that can help reduce sample usage, and thus make it cheaper.

Small circular holes are cut on a thin acrylic board are by laser cut, a holder for assisting supporting the microwell is fabricated using 3D printing, and PVDF films are used as the base material for protein immobilization (Fig. 1).

Figure 1. Materials used for the miniaturized ELISA platform

The acrylic board with holes and another board with no holes are used to clip the PVDF film tight, wrapped with tape, making microwells with a volume capacity of ~10μL (Fig. 2 left). The microwell is put on the 3D-printed holder, and the right picture of Fig. 2 shows the microwell platform with each well containing 10μL deionized water.

Figure 2. PVDF clipped with an acrylic board with holes and another board without holes (left), and the microwell platform with every well containing 10μL deionized water.

Streptavidin-HRP is diluted using PBS buffer, and 5μL of the solution is added in each of the microwell. Then 5μL TMB is added for validation of the colorimetric detection method. Fig. 3 shows the experiment result using the platform for qualitative analyzing different concentrations of streptavidin-HRP. It can be seen that different concentrations yield different intensities of absorbed light signals (λ = 450nm), thus this platform can be further improved for real experimental use.

Figure 3. Different concentrations of streptavidin-HRP with TMB for colorimetric detection using the miniaturized ELISA platform.

This project is the first one for me to implement simple skills that I have learned during the first three years in university on real bio-detection research issues, which motivated me to start thinking of practical methods to use engineering techniques for solving problems in an interdisciplinary way.

Robot Arm Control

It’s easy for us to point at a certain coordinate in space. That’s mainly because we simply locate the point with our eyes, and continuously check if our finger is pointing at that very spot. It surely will be more difficult without using eyes, and this is the case for robot arm control with no image feedback.

Think of a two arm robot (Fig. 1). We usually want to reach a certain point on the x-y plane. The problem is only the angle of the joints can be controlled. How can we correlate the joint angles of a robot with its tip coordinate? Things get harder when it comes to 3D space, and even harder considering its rotation.

In this project, I created a program that can calculate the every joint angle of the 6-arm robot IRB140 for positioning it at a given (x, y, z) coordinate and rotation.

Figure 1. Dimensions of the IRB140 robot (unit: mm) [1].

The problem for reversing an operation from the specified coordinate and rotation to every rotation angle of an arm joint lies in the field of inverse manipulator kinematics. There may be multiple solutions that lead to the same result. Thus, I implemented the Pieper’s solution [2] for solving the joint angles for the IRB140 robot.

Here’s a video demonstration for precision control of the IRB140 by only giving the joint angles as the input. The robot follows a trail surrounding a paper box with the tip of the last arm always pointing at the center of the box.

[Source code for robot arm control program]

1. ABB, IRB140 product specification, 2019, https://library.e.abb.com/public/2893a5756d204e19aba0d37c2a2cadc6/3HAC041346%20PS%20IRB%20140-en.pdf
2. Craig, J.J., Introduction to Robotics: Mechanics & Control. 1986: Addison-Wesley Publishing Company.

Bladeless Fan

The Dyson cooling fan is an eye-catching product. At first sight, some people may wonder how the seemingly bladeless fan really works because it simply looks like a structure with no air outlet. The fact is it can does have a small outlet at the inner part of its “ring”, and has the ability to take fluid dynamics into practice and enhance the air flow, making it also an air multiplier.

Figure 1. Dyson bladeless fan and simulated air flow.

In fluid dynamics class, I and a classmate of mine decided to construct a bladeless fan by our own and study the air multiplying phenomenon. We used 3D printing to fabricate the “ring” part of the fan, and a small centrifugal fan for connecting with the inlet of the ring part and inject a strong current inside.

Figure 2. Illustration and photograph of the bladeless fan.

Now we wanted to simply test whether this structure really leads to an air multiplying effect. We divided the outlet are into 9 sections, which can be represented using a 3×3 rectangular grid, and calculated the wind speed of every section at different input voltages for the centrifugal fan.

Fig. 3 shows the air velocity profile of the output wind, and Fig. 4 shows the magnification of air flow.

Figure 3. Air velocity (t_m [=] m/s) of 3×3 section grid at different input voltages.

Figure 4. Magnification of air flow at different input voltages of the centrifugal fan.

During this project, I learned more about the fundamentals of fluid mechanics, and memorized the relevant rules more deeply, which made me have a better understanding of this subject.

Guess the Number (iOS)

This is the first iOS game I had made using Xamarin, and is the second project of the guess the number series (after Guess the Number (Windows) and prior to Guess the Number AI). (The two-player game is also named Bulls and Cows.)

At the start of the game, a random 4-digit code is generated by the app and the player starts to guess that code. The player can restart the game anytime by pressing RESET, and a history of guesses and results are shown in a list at the bottom.

Here’s a demonstration of the app:

Considerations for app development are quite different from computer programs, such as the different screen sizes for different mobile platforms, and most of the time only a touch screen can be used. After finishing this project, I acquired some important fundamental concepts and know-hows for app design.

Guess the Number AI

After completing the first two projects of the Guess the Number series (Guess the Number (Windows) and Guess the Number (iOS)), I made an AI that can play this game at a high-human level.

It has been proven that at most 7 turns are needed to guess the answer, with a best average game length of 5.21 turns. For this game, all the possible combinations (e.g. “0123”, “7381” …) can be saved into a 1D array. After each guess, the possible combinations for the answer will be reduced. Therefore, the algorithm of the program is written for finding a number that will minimize the maximum possible combinations left. The time complexity for each turn is O(n3), and an average of 5 turns of guessing if needed for an arbitrarily chosen number.

For using the program, the user must first choose a 4-digit answer (e.g. “0123”), and input the two numbers [A] and [B] according to the game rules and the numbers guessed by the program. For instance, if the answer is “1357”, and the AI guesses “3127”, the user must input 1 2 ([A] = 1, [B] = 2).

Here’s a demonstration of the AI program guessing the answer “8192” in 5 guesses:

[Download Guess the Number AI program]

[Source code for the Guess the Number AI program]