Cosmos Quest Battle Simulator and Solver
Like Nathaniel Krueper

Cosmos Quest Battle Simulator and Solver

Cosmos Quest Battle Simulator and Solver

Description:

Published: February 3, 2019 0 0 528
By: Nathaniel Krueper, Cal Poly Pomona
Category: Computer Science
Hashtags: #Algorithms #ArtificialIntelligence #emulating #Game #GUI #JAVA #Programming

I play a small flash game on Kongregate called Cosmos Quest. In this game, you collect and level up units and use them to battle other units. Some units have special abilities that make which ones you choose to use first important. You are periodically given challenges to overcome, and depending on the strength of your units, there may or may not be a solution. I found that trying different strategies manually to be time consuming, and frustrating if I kept trying and the challenge was actually impossible.


To solve this problem, I recreated the game's battle system using personal observation, information on the game's wiki, and some tips from other players. I then created an intuitive GUI to input the parameters of the challenge: the units you have and the team of units you need to defeat. Finally, I wrote code to brute-force every possible combination of units I had to see if a solution was found. I made some optimizations to the search, making sure to start with the strongest units that had the greatest chance of being in a solution before moving on to weaker units.


Because the game gets regular updates, I wanted to make sure that the project was expandable so future additions would be easy to implement. To do this, I used several techniques learned in my Object-Oriented Design class. I used the Flyweight and prototype patterns to easily obtain units, and made a class for each special ability.


Cosmos Quest also features a PvP system where players can submit a number of pre-determined units and face each other in daily tournaments. I wanted to try my hand at making a code to determine the best order to place the units so I can perform well. To do this, I randomly generated a certain number of tournament submissions, then used a steepest ascent search and a genetic algorithm to find a submission that won against the most simulated submissions. As I improved and expanded on the algorithms, I began to perform much better in the daily tournaments and am now one of the top players in the game.


I initially uploaded this feature on a public GitHub, however, one player found it and convinced me to take the tournament part of the project down, since he feared what would happen to the PvP scene if everyone had it. As a result, That part of the project is not publicly available. Using this project may seem like cheating to some, but the developers of the game have stated that they are fine with it.


Note: The images used in this project are not mine. I took them from the game's wiki.