Monday, April 23, 2012

A* Search Algorithm: Snowman Pathfinding

As a follow-up to my minesweeper game, I wanted to develop a pathfinding algorithm on a similar platform.  At the same time, I had modeled a snowman, so I decided to use it to collaborate my modeling skills with my programming skills.

This project uses the A* (A-star) Search Algorithm to generate a path from one point to another on a grid system, finding the shortest way to the destination grid without running through walls.  The grid settings are fully customizable in that you can get the maximum row and column as well as the number of walls present in the grid system.

I have to say that this project is very relevant to my field of study because pathfinding algorithms such as this relate to my interests in game development and artificial intelligence.

So how does it work?  When the user clicks on a point on the grid, the program will convert the clicked position to the corresponding grid object.  This grid object is then set as the destination.  The grid object that the snowman is currently on will be set as the start position.  Then, in an iterative loop, the program will find the grid objects adjacent to the current grid (which will be the starting grid object to begin with).  We will calculate the F cost of each grid object.  The F cost is the sum of the G cost and H cost.  G cost, as represented by my program, is the distance from the current grid object to the adjacent grid object.  H cost is the distance from this adjacent grid object to the destination grid object.  The adjacent grid object that has the lowest F cost will then be new current grid.  This process will repeat until either the destination grid object becomes the current grid or the entire grid system has been essentially exhausted in search.

Here are some screenshots of the program at work:












We click on the point opposite of the snowman in relation to the two walls.











The snowman calculates the shortest path to the destination and begins moving.













Seen in a different angle, we see that the snowman has made it to the destination.


That's it for now.  Thanks for reading!

Sunday, April 15, 2012

SCJAS Research Award - First Place in Oral Presentation

This past Saturday, I went to University of South Carolina Aiken to present my research at the statewide annual South Carolina Junior Academy of Sciences.  There were over 300 other student presenters.  The event took the whole day.  I attended many of the presentations and many of them were excellent.

The awards ceremony took place late in the afternoon, and to my pleasant surprise, my research presentation took first place in the Math / Computer Science Mentored Research branch.  I was honored to receive the award.  It was something I couldn't have done without the help of my research advisor, Mrs. Bunn, who has listened and advised me during hours of my practice presentations.  So, thank you!

Monday, March 26, 2012

3D Minesweeper Game

As an interesting amalgamation of game design and algorithm development, I worked on a 3D minesweeper game in the past week.  It turned out pretty well, I think.  It has awesome explosions (when you click on a mine) and cute little red and white cubes with numbers on them.  You can also move the camera by using the W, A, S, and D keys as well as rotate and zoom in and out by using Q, E, Z, and X keys. 

The code design is facilitated by the use of recursive methods, which help reduce processing time tremendously.  Mines are generated randomly in a two-dimensional array that represents the grid.  Because the cubes are represented in a three-dimensional way, handling the user clicks was interesting.  When the user clicks on any point in the world, we perform what is called a raycast.  Raycast creates a ray of predefined length from the user's point of view in the direction of the position of the mouse click.  If the ray hits any cube, then we consider that cube to have been clicked.

I've tested this program up to 60 by 60 grid and it has worked beautifully with little lag.  Enjoy the screenshots!

I'll gladly provide with the download if you ask.







Saturday, March 24, 2012

M16 Model

Hello, everyone!  It's been a while again, but since the last post, I have some stuff to show you.

Recently, I finished a 3D model of an M16 Rifle.  I have quite an interest in guns, so modeling this one was quite a fun.

It's a rough sketch of the gun.  It's unskinned and lacks fine details that the gun has.  Since I'm just learning how to model, I'll save those for later.

Anyhow, please enjoy the renders!




Thursday, March 1, 2012

Work!

Hello, everyone!  I've not been able to post anything for a few months now.  I just wanted to let all know what's been going on in my life.

For the past few months, I had the privilege of having the opportunity to work with the mayor of Hartsville and create an iOS app that has the possibility to be sold to huge industries around the world.  Now, I can't really tell you what it's all about for the sake of business, so let's not get into that.

Basically, since 2012 started, I was busy scuba diving, doing tons of Govie schoolwork, meeting with the mayor, and programming for my app.  You know what's really cool about this app?  It's all a result of my own work.  I really didn't think I could do so much by myself, but I did, and I am rightfully proud of it.

I'll post screenshots of it at work once, hopefully, sales begin.  But until then, it's going under the radar.

So, that's the gist of how my life's been and probably will be for a little more until I finish revising the designs.  It was nice to write again!