This is a homework in class where we are assigned to utilize the temperature and humidity sensor DHT11 and an LCD display. Once activated, the LCD display will show either the temperature or the humidity being detected by the sensor. A button can be pressed to switch between temperature and humidity display.
Complex functionality can be achieved by including pre-coded libraries for controlling these components using Arduino, the development board I had used.
Though being a very simple project, such components serve as the simple building block for constructing a sophisticated hardware system. Therefore, this project plays an important role in the initial stage of hardware design for me.
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.
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.
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.
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:
Nonograms (also known as Picross, Griddlers, Pic-a-Pix, and various other names) are picture logic puzzles, in which the cells in the grid must be colored or left blank according to the numbers on the side of the grid to display hidden pictures.
For a classical type of game, the numbers are a form of discrete tomography that measures how many unbroken lines of filled-in squares there are in any given row or column. For example, a clue of “1 2 3” would mean there are sets of one, two, and three filled squares, in that order, with at least one blank square between successive sets.
Solving Nonograms can be very time-consuming, and can be tremendously brain-twisting as the grid size increases, thus I created an AI program for automatically solving these puzzles.
The program utilizes the depth-first search algorithm that runs recursively from the top to bottom row. For the jth column of the ith row, the black or blank spaces must satisfy the tomographic rules formed by the numbers of the current row and column. This is a relatively simple approach for calculating the answer. However, because the algorithm does not solve the game using a more intuitive method for solving interrelated constraints, it will use a lot of time for big grids (over 40×40).
For the input format of this program, two numbers indicating the number of rows and columns are given first (n and m). Afterwards, there are n rows of data, with each row k starting with a number nk indicating how many numbers are given in that row, and followed by nk numbers representing the discrete tomography of black spaces of that very row; then there are m rows of data, and also starting with a number mk for the kth row, and followed by mk numbers representing the discrete tomography of black spaces for the kth column.
Here’s an example input for the Nonogram in Fig. 1:
A demonstration for using the AI program for solving a 39×50 Nonogram in about 22 seconds is shown below. The result displays an owl sitting on a branch (Fig. 2).
Figure 2. The complete state of a 39×50 Nonogram displaying an owl on a branch.
Othello (a variant of the traditional game Reversi) is a two-player strategy board game played on an 8×8 square field, where each player takes turns placing black or white pieces and capturing the other player’s pieces.
Figure 1. Othello board game.
The Othello AI program is the second board game AI that I have written in junior high school (the first is the Tic-Tac-Toe AI). Just like the programming strategy for the tic-tac-toe AI, I used the logic thinking experiences that I had learned while playing this game, and hard-coded some summarized strategies into this program.
Compared with the tic-tac-toe AI, which has a game-tree complexity of 9! = 362880, Othello is much more complex, yielding a stunning complexity of approximately 1058. This makes the game still mathematically unsolved up to this very day. Therefore, instead of calculating the definite winning strategy, this Othello AI rather tries to find relative advantageous points (e.g. the corners), and moves that will temporarily maximize the number of pieces which it occupies by the coded algorithm, making it a beginner ~ intermediate level AI.
Here is a demonstration of using the Othello AI program:
Sudoku is a commonly known logic puzzle game, and had been one of my favorite puzzle games.
Having the experience for creating the simple Tic-Tac-Toe AI, I started to take on this challenge for creating an AI that can solve Sudoku.
Figure 1. The initial and complete board state of an expert-level Sudoku game.
I had written this AI program when I was in junior high school using Visual Basic 6.0. Having no prior knowledge for algorithms and data structures (which I learned in senior high school), I came up with a rough version of the backtracking algorithm myself, and implemented it on the AI. Here, the backtracking algorithm is a kind of depth-first search (DFS), and is guaranteed for finding a valid solution. Constraint programming is also integrated with the backtracking algorithm, since it is a very intuitive way for solving the puzzle.
Here is a clip demonstrating the Sudoku Solver program solving a hard-level Sudoku in around 5 seconds:
Here is another one that solved an expert-level Sudoku in around 44 seconds: