Wednesday, May 6, 2015

Final Post

It has been a few weeks since I have begun this project, and it is finally come to a close. My program works pretty well, with my AI predicting it's opponents moves relatively well. It has over a 99 percent victory rate against the random move AI. When facing the all out attacker, the results dropped to about fifty percent. This was expected, as the primary AI predicts that it's opponents will switch Pokemon, therefore it will always receive attacks, but not always retaliate. When fighting the third AI, the win rate rose to about 80 percent, which is due to the correctly predicted defensive swapping.

To see my program in action, watch here:
https://www.youtube.com/watch?v=5PGQK_avuZw

Through this project, I have learned several lessons. First, if you need to restart a project, do so quickly. It is difficult trying to generate a project when you begin with the half the time you would normally begin with. I also learned that assumptions can only go so far. The problem with probabilistic reasoning is that while you can come up with a likely answer, it may not always be the outcome. Finally I learned that new languages can be frustrating to try learn, some, I have found, are pretty easy and useful while others are difficult to master or use for a particular purpose.

For future enhancement, I would like to be able to account for more variables. Within the Pokemon games, there are several attributes that this program and framework does not take into account. These include factors such as items, abilities and effort values. I would also like to be able to hook this up to either a Nintendo DS or an online simulator in order to be able to battle with opponent s online. Along with this, I would like to incorporate a machine learning portion, which would be able to recognize opponents strategies in order to counteract them.

Overall this was a fun project to work on, and I look forward to being able to upgrade it in the future.

Saturday, May 2, 2015

Almost Done

I have finished creating my fourth AI for my Pokemon simulation. After getting the logic created and spending the last couple of days coding. I still need to do quite a bit of testing with this code, as there a lot of possibilities that can alter the AI's strategy. While I believe this code will work as I believed, I was not able to fully incorporate the probabilistic reasoning based upon unknown data for the opposing moves and reserved Pokemon. However, the AI can make good assumptions about surviving for defensive switching. I will continue to work on this over the next several days, and try to improve the reasoning based upon incomplete data.

CoffeeScript has still been giving me a few problems, but I'm starting to understand it pretty well. I still find several parts of it annoying, particularly parentheses of functions, and would probably not choose to use it over other languages. It seems strange because when a function is called with no arguments, the parentheses are required, but this is not the case if you send at leas one argument. It is nice to see the minimalist style, however, and it makes me curious to see how other languages may deal with these issues. 

Tuesday, April 28, 2015

Debugging the CoffeeScript Bug

I have been working on my project and have been able to finish my third AI, which featured defensive switching, with very little difficulty. However, when I began the fourth AI, I began running into numerous issues. A majority of these issues have to do with CoffeeScript. While I do love the minimalist approach with CoffeeScript, it has a lack of commas and parentheses in many locations, it has proven frustrating at many times. This has caused me to try and call a objects instead of functions. I've also tried to call functions instead of variables. However the biggest headache, by far has been with debugging in CoffeeScript. This is mostly due to the terminal outputting line numbers where an error does not exists, whether it is outside the message, white space, or sometimes it doesn't even exist in the class!























For example, the picture above shows the error on the damageCalculator, which is called from the chooseMove function in strategy on line 118. But the choose move function ends at line 73! This has cause some frustration and slowed down my programming progress but I'm still continuing.

So far on my fourth, and final, AI I have been able to get it to attack. It's not quite predicting its opponent's moves yet, but I will continue to work on this process.

Sunday, April 19, 2015

Defensive Switching

I have begun to work on developing the AI for playing Pokemon. The first step that I have taken is to try and familiarize my self with CoffeeScipt, as that is the language with which the simulator has been developed. To do so, I decided to create a few different AI that can be used within the simulator.

http://coffeescript.org/

The first AI I created one, dubbed "Strategy: 1", uses the AI of the first several games, namely use a random attack. This strategy was easy in concept, but proved more difficult to actually code, simply due to lack of familiarity with CoffeeScript. However, after a few initial issues the changes were successfully coded, and I moved on to a more advanced AI.

The second AI, would scan all possible attacks and select the best one to use against the current opponent. This includes taking in the opponent's type, health, and speed. It also implements the user's type, primary attack attribute, condition, and the move's power, accuracy, and extra effects. This AI was a little more difficult to create, but the simulator came with some methods built in that eased the coding. The left side of this image shows the result of a battle between two of these AI.


Afterwards, I set about making an AI that would switch out a pokemon that was in danger of being defeated for a more defensive pokemon. This proved to be much more difficult to do that the previous AIs, primarily because this began to predict what action would be taken by the opponent. This AI is reliant upon the the second, or at least a semi informed AI, that will be making attacks against the current pokemon in order to be effective. This AI is most similar to the AI within current pokemon games.

Below on the left section of code is how the AI's determine which AI method to use. The right side includes a bit of the code for the third AI's switching capabilities.


By the end of this next week I hope to finish developing a fourth AI which will be predicting the opponents moves. The following week I hope to create a human controlled component, with which I can directly test the fourth AI. This will allow me to test the AI against a real opponent, and tweak it for optimization.

Wednesday, April 15, 2015

Starting Over

I have been working on my quadcopter for a while now, but I have yet to get it flying off the ground. I'm not sure what is causing my problem, but I know that I will likely not have time to finish it and develop AI software for it within the end of the semester. As such I have decided to start over with a new project. For this new project I have decided to create an AI to play one of my favorite games growing up, Pokemon.

 I initially planned to create an AI which would work with an emulator. When researching how others have developed programs which work with game boy emulators, I saw many of them used some form of reverse engineering which is beyond my current skill set. Luckily, I was able to find a simulator on git hub that was made using coffee script. This project is a simulator that runs solely off of command line, compared to a graphical interface. This should make testing the project much easier.

https://github.com/fonse/pokemon-battle

While this project does include an AI, I plan to build off this to create an AI that will using probabilistic reasoning to predict its opponents move. It will then choose a move off of this prediction, whether to attack the opponent or switch to another Pokemon for a defensive purpose. I'm hoping to create an AI that will be able to win consistently against the current AI, regardless of which Pokemon are chosen to fight. In addition I hope to include human functionality and have the AI perform relatively well against the human. I'm just beginning on this project but am excited to work on it.

Thursday, April 2, 2015

Assembling the Quadcopter

My semester project has been to create a quadcopter with the ability to perform a few basic functions autonomously. I hope through the use of an on board compass and GPS that I will be able to program the quadcopter with the ability to land and move short distances without direct control through a remote control.

I plan to use an Arduino based flight controller for the quadcopter. I have purchased one from 3D Robotics along with an external compass/GPS unit for hope to develop basic autonomy in the near future. I will start by using the ArduCopter program, which is an open source platform designed for autonomous flight, and then proceed to get insert my own Arduino code in the quadcopter to perform its functions. http://copter.ardupilot.com/wiki/introduction/

In order to begin this process of programming functions, I first need a working quadcopter. I have been assembling one but have run into numerous setbacks, usually involved with being sent or ordering the wrong part. I have finally gotten the quadcopter assembled and calibrated for flight after getting my motors running a few days ago, but I need to wait for an adapter for my battery before I can actually take it for a test flight.