Sunday, February 15, 2015

Week 5 Fun with Nukes

This week I have had fun trying to figure out what we want to happen with nukes for the AI player. For now the main target is the command center and this week has a first pass on a new way to create nukes. Alex created a new method to create nukes paths overall to help with the transfer from mouse click to touch. The old method tended to work one way or the other and had problems switching back and forth. So I took this and developed a method on top. Initially missiles automatically shoot out a distance directly from the center of the planet. This way unless you try hard you can't nuke your planet accidentally on the first turn. You can turn it back, but that is a problem for another date. So, my method uses just a little bit of trig. Missiles have a launch distance that they go for each rotation and each rotation the planet moves one away. So when you check if a missile could hit you check with the adjacent 5 spots to the direction its rotating. So if its the left planet you search its left location 5 times.You check how many turns it would take going directly from the first place out to each location. You add one for the original launch which happens automatically by creating a nuke. if this number is within -1 to 1. Say it takes 3 turns and either and the location is either 2, 3, or 4 it will blow up. So if its 3 its 100% chance. 2 or 4 its put at 60% chance. You don't add perfect straight to location, that would be too predictable as well as easily countered. When it confirms which of those spots its going to nuke it figures out at each point the angle from the center of the spot to the last nuke location. It has a hypotenuse which is the full vector length, as well as an x so you can use cos^-1 to get the angle in radians, which our system uses. Than you have to add an offset so its not likely to fly straight at it, and add zig zag similar to a real player. This can cause it to miss, as well causing the enemy to have a hard time hitting one of their nukes into the computer players. This path on the first go is working well. As expected hits target about 60-70 percent of the time which is decent and not to high. However about 10% of the time it does seem to shoot of the screen for an unknown reason. We will be looking in this week to figure out if its a math or logic error. Or a weird new pathbuilder error. As well, we are looking to do a similar goal orientation for the enemy nuke selection as its building. This way it all works goal orientated which is how the game has been developed to be seen. The command center being the biggest object, both to explode and secure. We will than work our way down based on some small changes. This being how the AI wants to win. Starve the opponents resources, go for shield generators, kill all nuke paths etc. Each will have a multiplier to help decide and create AI that have a variety of goals in different games. This way they aren't too easily predicted game after game. These numbers can and will change in the midst of games if that Player changes his gameplay as well, but that is to be added in the much later stages. We are currently quite happy with the initial AI both for its nuking and its building and survivability. The last piece to be added is the boost resources which the intro AI won't do a hundred percent of the time. In the later and more difficult will use all resources to its advantage every turn.

No comments:

Post a Comment