Here are some of my AI and games projects in Python, C, C++, and Java.
AI:
Games:
How does Google Alpha-Go learn to play Go in an hour and beat the best human Go players? I know it is based on discovering hidden patterns, yet its details are beyond my current ability to grasp.
Can I use AI to do something interesting and within my capabilities?
In one of my presentations to our AI Club, I proposed a grading challenge problem, where a teacher would give a pass/fail grade based on a student's class participation, quiz, and final exam grades. Depending on his mode, he may choose to use a simple average, weighted average, or an arbitrary secret formula.
I showed the club that, once given enough data, a machine learning tool can uncover the hidden patterns indiscernible to a simple formula. Using the latest machine learning tool TensorFlow 2, I built a neural network like below.
I used Python Pandas and Numpy tools to generate simulated student grades. I then split the data into two parts: one for training my AI model, the other for checking model correctness. I trained the neural network by feeding it with the training data. After five passes, the model achieved an accuracy of 94.1%. Then I tested it on test data; astoundingly, the accuracy was 97.7%. Below is a sample test run. The source code can be downloaded here.
$python grade_pass.py Please choose grading method (type 1, 2, or 3): 3 Epoch 1/5 2813/2813 [==============================] - 16s 5ms/step - loss: 0.4431 - accuracy: 0.7865 Epoch 2/5 2813/2813 [==============================] - 14s 5ms/step - loss: 0.2762 - accuracy: 0.8810 Epoch 3/5 2813/2813 [==============================] - 14s 5ms/step - loss: 0.1780 - accuracy: 0.9304 Epoch 4/5 2813/2813 [==============================] - 14s 5ms/step - loss: 0.1395 - accuracy: 0.9375 Epoch 5/5 2813/2813 [==============================] - 14s 5ms/step - loss: 0.1234 - accuracy: 0.9405 313/313 [==============================] - 2s 4ms/step - loss: 0.0732 - accuracy: 0.9770 === Out of sample test accuracy: 0.9769999980926514 === === Test: Failed Predictions 230, or 2.3% *** *** samples of failed predictions*** class quiz final grade1 grade2 grade3 grade pass pass_predict_odds pass_predict 98794 0.46 0.93 0.41 0.600000 0.576 0.585996 0.585996 0 0.810490 1 98819 0.47 0.89 0.44 0.600000 0.581 0.594624 0.594624 0 0.783957 1 98847 0.42 0.97 0.41 0.600000 0.580 0.588508 0.588508 0 0.892313 1 98878 0.47 0.92 0.42 0.603333 0.580 0.591289 0.591289 0 0.839082 1 98917 0.46 0.40 0.95 0.603333 0.687 0.585153 0.585153 0 0.862356 1 98925 0.65 0.44 0.77 0.620000 0.647 0.595652 0.595652 0 0.623241 1 98926 0.44 0.90 0.42 0.586667 0.568 0.579854 0.579854 0 0.582080 1 98969 1.00 0.61 0.40 0.670000 0.583 0.595171 0.595171 0 0.537886 1 98976 0.67 0.80 0.42 0.630000 0.584 0.597724 0.597724 0 0.777348 1 98981 0.42 0.95 0.40 0.590000 0.569 0.577153 0.577153 0 0.735859 1 99028 0.76 0.51 0.62 0.630000 0.615 0.601853 0.601853 1 0.442510 0 99064 0.60 0.82 0.41 0.610000 0.571 0.583862 0.583862 0 0.556755 1 99067 0.52 0.58 0.68 0.593333 0.618 0.606410 0.606410 1 0.436331 0 99082 0.47 0.40 0.91 0.593333 0.669 0.576659 0.576659 0 0.640742 1 99093 0.50 0.63 0.64 0.590000 0.609 0.607984 0.607984 1 0.428010 0 99125 0.65 0.78 0.43 0.620000 0.579 0.593310 0.593310 0 0.620491 1 99135 0.59 0.80 0.43 0.606667 0.573 0.587212 0.587212 0 0.507702 1
We should also note that even the failures are close misses of passing grade criteria of 0.60.
If AI can uncover arbitrary rules in simulated data or man-made games, it should discover physical rules hidden in actual data. Our science and engineering may have reached a phase complicated enough that future discoveries or achievements may depend on AI.
This is the traditional Battleship game we played as children. The difference is that I am the designer this time, not merely a player.
Using OOP, this game can be designed using 2D arrays to manipulate player states, allowing players to play against the computer. As my great C++ teacher Mr. Forhan often encourages us to go beyond, I studied the powerful and generic C++ Standard Template Library from this great college C++ textbook: Accelerated C++: Practical Programming by Example 1st Edition by Mike Hendrickson (Author), Andrew Koenig
I was amazed by the professional way of solving complex problems using standard generic algorithms.
For the final project of Mr. Forhan's C++ course, I developed a Mini-Jeopardy game, mimicking the popular TV game show Jeopardy. A player would answer questions posted by the host in four areas: Math, US State Capitals, US Presidents, and Antonyms.
The game worked well. I realized its methodology could be applied for students to perfect their scores in a chosen field, as long as we provide the questions and answers in a suitable library.
However, it has one weakness: as I emailed Mr. Forhan in discussion, the C++ program's console display is less ideal for the eyes. I hope to adapt it to web format.
In the last summer, as I developed this website, I tried the conversion. The text to HTML conversion is straight-forward, but I soon encountered two big technical obstacles:
Is there a way for the server to "push" updates to the players? After considerable research, I found that the solution is to use the latest websocket bi-direction communication methods.
The gist of websocket methodologies is depicted by the figure below:
Since multi-player gaming using websocket is among the most advanced and tricky web technologies, it took me considerable trials to make it work.
The end result is my multiplayer web Mini-Jeopardy Game. You can click to play.