Category Archives: My Projects

Bot Sees the Future in Ultimate Tic Tac Toe (In Progress)


Ultimate Tic Tac Toe gives a second depth to the game of Tic Tac Toe. The rules of the game make it a strategic, intellectual, and addicting game.

Rules of the game:

I am currently working on an artificial intelligence for this game that can anticipate and optimize future outcomes in order to outwit its human opponent. I have created my own Node and Node Tree data structure, which I will use to record and analyze future moves. I am doing an implementation of the minimax algorithm for this artificial intelligence. It is truly challenging to create an effective and time efficient data structure for finding the best move to make.

After I have finished this project, I hope to put it on the Android market, so stay tuned for the final result!

Bot Learns from Experience in Ultimate Tic Tac Toe

Ultimate Tic Tac Toe gives a second depth to the game of Tic Tac Toe. The rules of the game make it a strategic, intellectual, and addicting game.

Rules of the game:

I created an artificial intelligence for this game using case based reasoning, where the computer would be able to learn from its previous game experiences. You can read more about the project description under the EPGY Projects tab of the EPGY Summer AI 2013 page. Here is a short summary of what I did.

I set up a localhost MySQL server in order to record each game in a table within a single database. After I access all the data from my previous games, I sort through the moves and only analyze the winner’s moves from each game. Then, I divide each game into three equal sections and classify each move into the section of the game that it was played in. I took these three individual clusters of moves and created a probability model for each cluster. The computer player would then apply one of these models depending on the computer player’s depth into the current game. I decided to use a probability model to create a dynamic computer player because dynamic gameplay is hard to exploit since it is unpredictable. Plus, this gives the human player the feeling that it is playing against a sophisticated, human-like bot.

My initial goal was to make the java game playable on this wordpress blog. Since I can’t add jar files to posts, I installed a separate blog on my localhost Apache server with the back-end on my localhost MySQL server. Next, I changed the functions.php page to allow me to load the jar files. Then, I was going to link this blog to my blog, but that would require port forwarding, which is a security hazard. Thus, I can only show you a video of the game. Check out the Youtube link below!

Check out my git repo as well:



“In order to understand recursion, one must first understand recursion.”

Recursion is, by far, one of my most favorite concepts in computer science. It can be used to solve many hard problems and some of its implementations are beautiful. This is a visual recursion program that I did with circles. At a depth of about 20, the circles turn into triangles and one can see a Sierpinski triangle.

WordPress Queries

When I say WordPress, I mean, where you can host your own website. Using VMs, I created an Apache web server to host the wordpress site and used another VM for a MySQL server to store the back-end of the blog site. I then created a java program that could access the content in the MySQL database. I had to use a JDBC driver to connect the JAVA program to the specific database on the MySQL server. Below is the common code needed to connect to a MySQL database using JAVA.

import java.sql.*;
import java.util.*;

public class wordpressqueries {
   // JDBC driver name and database URL
   static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
   static final String DB_URL = "jdbc:mysql://###.##.##.###:3306/WordPress";
   //^format "jdbc:mysql://ipaddressofhost:port#(default is 3306)/databasename"

   //  Database credentials
   static final String USER = "user";//username
   static final String PASS = "123";//password

   public static void main(String[] args) {
       Connection conn = null;
       Statement stmt = null;
           //STEP 2: Register JDBC driver
	        System.out.println("Registered JDBC driver...");

           //STEP 3: Open a connection
           System.out.println("Connecting to database...");
           conn = DriverManager.getConnection(DB_URL,USER,PASS);
           //^acceses the database specified by the url through entering in the username and password
	        System.out.println("Creating statement...");
           stmt = conn.createStatement(); //access the database server and manipulate data in database
           //STEP 4: Execute a query
           String sql = new String("SELECT * from wp_comments");//wp_comments is a table
	       ResultSet rs = stmt.executeQuery(sql);//executeQuery method accesses the table
	       ///result sets provide access to tables of data
            //ENTER CODE HERE ********

	       //STEP 6: Clean-up environment
      }catch(SQLException se){
           //Handle errors for JDBC
      }catch(Exception e){
           //Handle errors for Class.forName
      //finally block used to close resources
           }catch(SQLException se2){
           }// nothing we can do
           }catch(SQLException se){
     }//end finally try
     }//end try
   }//end main
}//end queries

Business Development – Operations Research

As part of the DECA business club in my high school, I competed in Operations Research projects in a team, where we had to optimize/create promotional plans to increase clientele and revenue for a corporation. My first business plan in 2011 was focused on using social networking/media to increase revenue for De Anza Cupertino Aquatics (DACA), which is a nonprofit swim school and club. In 2012, my second business plan revolved around using loyalty programs to increase revenue for Verde Tea Café, which is an international Asian food restaurant. My teams for both of these plans received top awards at the California state conference, and qualified to compete in the DECA international business conference.

De Anza Cupertino Aquatics (2011) – DACA Business Plan

Verde Tea Café (2012) – Verde Business Plan


The Game of Risk

Even though this program was my biggest failure, I learned the most from this program. Being the first make-your-own-game project in my first programming class, I decided I wanted to create the game of Risk. Without consulting my teacher, I began the project, which ended up running 2,000+ lines of code. I did the entire project without object oriented programming. Without objects, programming the game became very complex, and I finished for the deadline with many glitches and some parts were not functional. My teacher then talked to me and taught me OOP, which would have made the game much easier to build. From this game, I learned that I should be more resourceful as a programmer and ask for help if I am struggling. Also, I learned that I should brainstorm and outline big projects before I just jump right into it.


I built on top of the program by leaving a trail behind the balls’ path. With all the same features as (a previous post),  I was able to create really cool designs with the trails by meticulously guiding the balls with mouse clicks. The designs use two, four, or even eight balls that will mirror each other.


It is a colorful, eye-catching ball that bounces off the walls of the applet.

[insert single ball video here]

Even though the fundamental program might be boring, it enjoyed the experience of constantly adding features and innovations to make it more complex.

By clicking my mouse on any part of the applet, the ball will change directions and travel towards the point that the mouse was clicked. Since I could only change the ball’s pixel position using whole numbers, it was difficult to change the slope of travel in such a way that it wouldn’t drastically change the speed of the ball. For example, if I click almost vertically above the ball, the slope between the ball’s pixel position and the mouse click’s pixel position will be 220/5. You wouldn’t be able to see the ball if it moved that fast. So, I used the following code to round the ball’s slope of displacement to an improper fraction that wouldn’t move the ball more than 5 pixels in the x or y direction every 20 milliseconds.

//changex is pixel distance from the ball to the mouse click (x direction)
//changey is pixel distance from the ball to the mouse click (y direction)
double maxDifference=5;
double difference=0;
int newchangex, newchangey;
for (int ting1 = 1; ting1<5; ting1++){
     for (int ting2 = 1; ting2difference){
          difference = Math.abs((Math.abs((double)(changey)/changex))-((double)(ting1)/ting2));
 	  if (maxDifference>difference){
               //this if statement will constantly replace the old newchangex &newchangey
               //values with the current one because these new values
               //create a slope that is closer to the changey/changex slope
               //than the old values.
               maxDifference = difference;
               newchangex = ting2;
               newchangey = ting1;
//newchangex and newchangey is going to represent the new slope of travel for the ball

After this, I would just change the signs of the newchangex and newchangey and it’ll work.

I also added balls that would mirror the movement of the initial ball. The ball also changed rgb values at a constant rate.

[Insert multiple ball video here]