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.