Superior AI without actually writing AI

Talk about anything not related to Transcendence.
User avatar
Atarlost
Fleet Admiral
Fleet Admiral
Posts: 2391
Joined: Tue Aug 26, 2008 12:02 am

Using angle to target rather than presence or absence of stuff in zones will prevent the AI from being able to turn damaged segments away from threats. If the AI can turn damaged segments away from threats we can probably dispense with the problematic capital ship buffs since the added armor segments will actually make them more survivable like they were originally supposed to.

Array of weapons isn't a number or boolean. I don't think anything that isn't a number or boolean can be fed into a neural net.
Literally is the new Figuratively
JohnBWatson
Fleet Officer
Fleet Officer
Posts: 1452
Joined: Tue Aug 19, 2014 10:17 pm

Atarlost wrote:Using angle to target rather than presence or absence of stuff in zones will prevent the AI from being able to turn damaged segments away from threats. If the AI can turn damaged segments away from threats we can probably dispense with the problematic capital ship buffs since the added armor segments will actually make them more survivable like they were originally supposed to.

Array of weapons isn't a number or boolean. I don't think anything that isn't a number or boolean can be fed into a neural net.
It could be taken as a set of numbers or booleans. Range, dps, and whether it is turreted is effectively what would be needed for each weapon. I suppose we could derive the max dps and range for both non - turreted and turreted weapons and use that instead.
User avatar
Atarlost
Fleet Admiral
Fleet Admiral
Posts: 2391
Joined: Tue Aug 26, 2008 12:02 am

I'm quite sure you're getting way too complicated. You can't expect to handle completely different situations like omni versus fixed axis on the same neural net. I'd expect it to be a "run over the weekend" situation for one AI, but trying to make an AI that effectively shifts its weights based on a boolean in one of its fields out of a neural net is going to take far longer if it works at all. It will take a much thicker net which will take longer to train and be more likely to evolve into a dead end.

Pretty much all a neuron can do is take a bunch of inputs, multiply them by its weights, and output that. The kind of switching that could make use of a weapon list is ridiculously hard to do in a neural net.
Literally is the new Figuratively
JohnBWatson
Fleet Officer
Fleet Officer
Posts: 1452
Joined: Tue Aug 19, 2014 10:17 pm

Atarlost wrote:I'm quite sure you're getting way too complicated. You can't expect to handle completely different situations like omni versus fixed axis on the same neural net. I'd expect it to be a "run over the weekend" situation for one AI, but trying to make an AI that effectively shifts its weights based on a boolean in one of its fields out of a neural net is going to take far longer if it works at all. It will take a much thicker net which will take longer to train and be more likely to evolve into a dead end.

Pretty much all a neuron can do is take a bunch of inputs, multiply them by its weights, and output that. The kind of switching that could make use of a weapon list is ridiculously hard to do in a neural net.
A ship really should use different tactics against an enemy that fields an omnidirectional weapon.

This could be simplified to a set of 4 variables. mainRange, mainDPS, omniRange, and omniDPS, with the latter 2 being 0 in the case of a non - omni equipped ship(causing the ship not to weight its actions toward staying in range of the enemy ship without lining up a shot), and the former 2 being 0 in the case of a ship with only omni weapons(causing a ship not to weight its actions towards lining up a shot). I can't really see what would break a neural net there.
FourFire
Militia Captain
Militia Captain
Posts: 567
Joined: Sun Aug 12, 2012 5:56 pm

Awesome ideas guys, I think getting it to use different strategies dependent on weaponlists is unnecessary, we only need an AI which is noticeably better at playing than the currently retarded AI, and we can always expand it later once we have something working.

A suggestion: releases can have a pretrained NN for the AI, and upon game completion, a savegame's stats is uploaded to multiverse...

What if the NN gets to train during each unmodded playthrough by any player, and at the end the weights on the (two, or three if desired) NN types (one for capital ships, one for gunships one for cannonfodder? or maybe stations?) are also uploaded... then, in the next release we can include the most fit of each type of NN (or maybe the ones which produce the most fun behaviours).

For fun, we could do three tests for each NN, maybe by fluke, someone's weirdass playstyle causes hornet NN to be a really good capitalship NN?

Heh, having the game's AI learn how to play from the players of the game would be a unique community element which I've only seen in one other game to date.
(func(Admin Response)= true){
if(admin func(amiable) = true)
Create func(Helpful Posts)
else func(Keep Calm and Post derisive topics)}
JohnBWatson
Fleet Officer
Fleet Officer
Posts: 1452
Joined: Tue Aug 19, 2014 10:17 pm

FourFire wrote:Awesome ideas guys, I think getting it to use different strategies dependent on weaponlists is unnecessary, we only need an AI which is noticeably better at playing than the currently retarded AI, and we can always expand it later once we have something working.
Yes, this is right. It may be good to try and get a very simple AI working, and then expand off of it. I think this is probably the best way of preventing scopecreep from killing this project too early, as well. Anyone have ideas for a bare - bones setup? Off my head, I think this could work, unless I missed something?:

Input: Direction from ship's position to enemy, relative to current ship angle; Velocity of both ships; Distance to enemy; Main weapon maximum range; Main weapon shot velocity

Output: Turn left; Turn right; accelerate; fire main weapon

This allows for a ship with one main weapon to chase after and effectively lead a given target.
A suggestion: releases can have a pretrained NN for the AI, and upon game completion, a savegame's stats is uploaded to multiverse...

What if the NN gets to train during each unmodded playthrough by any player, and at the end the weights on the (two, or three if desired) NN types (one for capital ships, one for gunships one for cannonfodder? or maybe stations?) are also uploaded... then, in the next release we can include the most fit of each type of NN (or maybe the ones which produce the most fun behaviours).

For fun, we could do three tests for each NN, maybe by fluke, someone's weirdass playstyle causes hornet NN to be a really good capitalship NN?

Heh, having the game's AI learn how to play from the players of the game would be a unique community element which I've only seen in one other game to date.
George was looking into something similar with station inventories, so it's definitely something we could do(or at least attempt) down the road.
User avatar
sun1404
Militia Captain
Militia Captain
Posts: 527
Joined: Thu Nov 03, 2011 10:32 am
Location: Heretic. (Finally!)

Perhaps it will help in finding a suitable set of inputs for a neural net by thinking about what -you- take into account in your decisions in combat. I think most people don't think too much when in a game combat, so the formula should turns out to be simple. Below is what I think is my criteria:

1)Where the enemy is (could be expressed in many ways, such as angle and distance.)
2)What is your weapon shot's speed.
These allows basic aiming and firing.

3)How long would it take to destroy the enemy (Basically an estimate from your weapon damage, hit chance, and enemy HP and resistance)
** The AI can maybe get this input from the first few shots, using the code that shows damage as percentage, information becomes simply
1.Percent damage for each shot.
2.Weapon firing speed)
4)How easily can your enemy destroy you (The enemy's weapon damage versus your HP+resistance)
These let you decide whether to be aggressive or evasive.

5)Your speed and turning speed
6)Enemy speed and turning speed
If enemy (turning) speed is higher to a certain degree, it is impossible to be evasive, nor to flee.

7)Your remaining HP
If too low, flee for safety, at least until shield recover.


As another idea, the neural net might not need to handle every small decisions, but simply choose between a few preset fighting styles (dogfight, bombarding, evasive, flee, kite, etc.). Only your ship's stats versus the enemy's would be needed. The chosen style can be reevaluated every 10 seconds or so, or when important event (ie. shield collapse) happens.
Yes, look at my avatar, I have a wyvera type ship.
User avatar
Atarlost
Fleet Admiral
Fleet Admiral
Posts: 2391
Joined: Tue Aug 26, 2008 12:02 am

sun1404 wrote:As another idea, the neural net might not need to handle every small decisions, but simply choose between a few preset fighting styles (dogfight, bombarding, evasive, flee, kite, etc.). Only your ship's stats versus the enemy's would be needed. The chosen style can be reevaluated every 10 seconds or so, or when important event (ie. shield collapse) happens.
The small decisions are precisely what the original link shows a neural net can do that the condition tree AI is hideously bad at.
Literally is the new Figuratively
JohnBWatson
Fleet Officer
Fleet Officer
Posts: 1452
Joined: Tue Aug 19, 2014 10:17 pm

Atarlost wrote:
sun1404 wrote:As another idea, the neural net might not need to handle every small decisions, but simply choose between a few preset fighting styles (dogfight, bombarding, evasive, flee, kite, etc.). Only your ship's stats versus the enemy's would be needed. The chosen style can be reevaluated every 10 seconds or so, or when important event (ie. shield collapse) happens.
The small decisions are precisely what the original link shows a neural net can do that the condition tree AI is hideously bad at.
Precisely.

Any comments on my attempt at a simplified set of inputs and outputs? If it's usable as a starting point(to see how the whole idea of a neural net would work, and identify any unexpected problems), we could try and move on to setting up some solid code for this.
FourFire
Militia Captain
Militia Captain
Posts: 567
Joined: Sun Aug 12, 2012 5:56 pm

I vote for solid code now.
We can always make several variants of inputs/outputs and see which ones learn more quickly.
(func(Admin Response)= true){
if(admin func(amiable) = true)
Create func(Helpful Posts)
else func(Keep Calm and Post derisive topics)}
User avatar
Atarlost
Fleet Admiral
Fleet Admiral
Posts: 2391
Joined: Tue Aug 26, 2008 12:02 am

JohnBWatson wrote:Any comments on my attempt at a simplified set of inputs and outputs? If it's usable as a starting point(to see how the whole idea of a neural net would work, and identify any unexpected problems), we could try and move on to setting up some solid code for this.
I still think my sector and zone input arrangement would better be able to take advantage of multiple armor segments, but the demonstration uses something much like yours. At least in that it uses only four inputs and five outputs. Unfortunately it's in French and I don't read French. If anyone who does can translate that might help, but it appears to be just an abstract anyways.
Literally is the new Figuratively
JohnBWatson
Fleet Officer
Fleet Officer
Posts: 1452
Joined: Tue Aug 19, 2014 10:17 pm

Atarlost wrote:
I still think my sector and zone input arrangement would better be able to take advantage of multiple armor segments, but the demonstration uses something much like yours. At least in that it uses only four inputs and five outputs. Unfortunately it's in French and I don't read French. If anyone who does can translate that might help, but it appears to be just an abstract anyways.
Text on page, translated with google and edited for more readable English grammar:

Code: Select all

This example sets up creatures who learn by themselves using a genetic algorithm applied to a neural network.

Objective of the experiment:
The goal is to kill the enemy, which has 3 lives. We expect that at the end the creatures will be able to target (and therefore set its field of view accordingly), shoot, and dodge.

Implementation :
The ranking system used for calculating the weights of the outputs is a tournament system (everyone confronts all others), where everyone gets 3 points for a match won, 1 for a tie, and 0 if they lose.

The selection algorithm used is a "roulette wheel".

Every creature is provided with a neural network which follows the following scheme:

4 inputs:
-presence of enemy in his field of vision 
-presence of a bullet in his field of vision
-if the creature has already fired a missile or not 
-width (in radians) of its field of vision

2 layers of neurons:
All the neurons of the first layer SOBT connect to all neurons of the second layer, a semi-firmant complete graph.

4 outputs:
-Move forward
-Turn left
-Turn right
-Shoot
-Change The field of vision
A retro control exists for the field of view (see diagram).

The following diagram illustrates the neural network structure implemented:
Diagram:

Left side:

4 inputs

Sensor of water

Sensor of fire

Sensor of diamonds

Central sensor.

[Is there some sort of meaning behind this, or is it translated incorrectly? I can't make heads or tails of it.]

Center:

First layer of neurons

Second layer of neurons

Right side:

4 outputs

Advance

Turn right

Turn left

fire weapon

alter the field of vision

It appears to lead the target using the field of vision adjustment, rather than the distance between itself and the target and the projectile's speed. It's definitely an interesting system, though I'm not sure it would work as well for our purposes. Worth a shot, though.
User avatar
Atarlost
Fleet Admiral
Fleet Admiral
Posts: 2391
Joined: Tue Aug 26, 2008 12:02 am

Ah, so they are using boolean presence or absence.

Since we don't have FoV I'd suggest for prototyping a forward segment defined by the weapon's spread and the ship's accuracy adjustment (min 1 facing's width) with the remaining space divided into a starboard segment and a port segment, each divided into "in range" and "out of range". We can worry about getting capships to hide damaged segments and use non-forward weapons and get gunships to exhibit flocking behavior properly later.

Assuming anyone here can actually code this. I suppose step one might be to get the screensaver working as a standalone again?
Literally is the new Figuratively
JohnBWatson
Fleet Officer
Fleet Officer
Posts: 1452
Joined: Tue Aug 19, 2014 10:17 pm

Atarlost wrote:Ah, so they are using boolean presence or absence.

Since we don't have FoV I'd suggest for prototyping a forward segment defined by the weapon's spread and the ship's accuracy adjustment (min 1 facing's width) with the remaining space divided into a starboard segment and a port segment, each divided into "in range" and "out of range". We can worry about getting capships to hide damaged segments and use non-forward weapons and get gunships to exhibit flocking behavior properly later.

Assuming anyone here can actually code this. I suppose step one might be to get the screensaver working as a standalone again?
More than one way to skin a cat - it's probably possible to get a unit to aim using the target's current speed and the unit's projectile velocity, which would likely work better anyways due to the increased importance of target leading.

For getting the code started, a system that allows for both watchable fights(with all extra visual effects dummied out) and fights that run as fast as possible with no rendering used would probably be the optimal starting point. It'd let us see how our algorithm is working and also optimize it through many generations without wasting resources or time.
User avatar
Atarlost
Fleet Admiral
Fleet Admiral
Posts: 2391
Joined: Tue Aug 26, 2008 12:02 am

JohnBWatson wrote:
Atarlost wrote:Ah, so they are using boolean presence or absence.

Since we don't have FoV I'd suggest for prototyping a forward segment defined by the weapon's spread and the ship's accuracy adjustment (min 1 facing's width) with the remaining space divided into a starboard segment and a port segment, each divided into "in range" and "out of range". We can worry about getting capships to hide damaged segments and use non-forward weapons and get gunships to exhibit flocking behavior properly later.

Assuming anyone here can actually code this. I suppose step one might be to get the screensaver working as a standalone again?
More than one way to skin a cat - it's probably possible to get a unit to aim using the target's current speed and the unit's projectile velocity, which would likely work better anyways due to the increased importance of target leading.

For getting the code started, a system that allows for both watchable fights(with all extra visual effects dummied out) and fights that run as fast as possible with no rendering used would probably be the optimal starting point. It'd let us see how our algorithm is working and also optimize it through many generations without wasting resources or time.
We know the way the French did it works.

I'm pretty sure the easiest way to run the simulation is to take the intro screen code and dummy out the ship randomization, change the AI, and put in disk IO commands to store stuff. And figure out a fitness function that will make progress even when the ships are failing to kill each other. That way the simulation is already written and acts like the game.
Literally is the new Figuratively
Post Reply