Block Driven Ship/Turret AI

    Edymnion

    Carebear Extraordinaire!
    Joined
    Mar 18, 2015
    Messages
    2,709
    Reaction score
    1,512
    • Purchased!
    • Thinking Positive Gold
    • Legacy Citizen 5
    Can you make block analog of my current code for bomber?
    Bobby
    Target:Ship - Shield - Activator Off
    ....................- Mass - Activator On
    ....................- System HP - Activator On, Activator Off
    Target:Ship - Shield - Activator Off
    ....................- Mass - Activator On
    Target:Ship - Mass - Activator On
    ....................- Distance - Activator On, Activator Off
    Target:Ship - Mass - Activator On

    22 extra blocks.

    Target priority with shields down, biggest mass, lowest system hp first.
    Target shields down, largest mass second.
    Target shields up, largest mass, within the closest 50% of targets
    Target shields up, largest mass.

    So target things about to die first, finish them off. Target the biggest and closest if nothing is damaged. If nothing is close, go after whatever you can see in range, biggest target first.

    Fairly large, but nowhere near 500 blocks, and you could simplify it even more with only minimal losses in accuracy. Like simply make it:

    Target:Ship - Shields - Activator Off
    Target:Ship - System HP - Activator On, Activator Off
    Target:Ship - Mass - Activator On

    It would now target anything with no shields as a priority, then anything that is damaged but has shields up, and finally would default to attacking the largest ship it can see. Thats at only 10 blocks, and would do 90% of what you just said.
    Ähhh... Sorry Guys but combat isnt that static that this AI controll system is. We need fast and comfortable ways to reajust AI even in combat.
    You could do that with my system, on the fly.

    You simply put the activators on everything you want to make decisions on, then use an inner-ship/wireless remote to change the activator settings. Have a button for Fighters that sets the activators for mass to the lower range and distance to the lower range. Have a button for cruisers or bombers by increasing the mass and distance thresholds.
     
    Last edited:
    • Like
    Reactions: Nickizzy
    Joined
    Dec 3, 2016
    Messages
    93
    Reaction score
    7
    I can also make code for block controlled AI suggestion. But again I am not a developer of Starmade and don't have it's code to be able to add something. If you know any ways, please tell me.

    I think you will like to see both realized suggestions.

    But if you want it, I need more information about your suggestion.
    [doublepost=1482166357,1482165991][/doublepost]
    31 extra blocks.

    Target priority with shields down, biggest mass, lowest system hp first.
    Target shields down, largest mass second.
    Target shields up, largest mass, within the closest 50% of targets
    Target shields up, largest mass.
    1) You're missing armor here.
    2) It's not an equivalent of mine code.
    3) My code is alpha and short now.
     

    Edymnion

    Carebear Extraordinaire!
    Joined
    Mar 18, 2015
    Messages
    2,709
    Reaction score
    1,512
    • Purchased!
    • Thinking Positive Gold
    • Legacy Citizen 5
    2) It's not an equivalent of mine code.
    It is functionally equivalent.
    As in, when both sets get through and pick a target, they are most likely to pick the same target.

    You don't have to replicate 100% detail as long as the output is roughly the same.

    If you're as good a coder as you say you are, you should understand the concept of elegant code. You don't do in 500 lines what you can do in 5 lines.

    You should also be able to appreciate the fact that straight up compares are a lot easier to make than stopping to calculate ratios on the fly like you're doing. That AI code is going to have to access a lot of information and recalculate a lot of data on the fly, which will make it slower.
     
    Joined
    Dec 3, 2016
    Messages
    93
    Reaction score
    7
    It is functionally equivalent.
    Of course it is similar to act, but code works in another way. I don't know any block combination to make an equivalent of my code.

    Ship may not have armor and hull, but have 100% shields and your drone will prefer the same ship but with 0% shields, but 100% armor and hp.
    [doublepost=1482166831,1482166677][/doublepost]
    It is functionally equivalent.
    1) You're missing armor here.
    2) It's not an equivalent of mine code.
    3) My code is alpha and short now.
     

    Edymnion

    Carebear Extraordinaire!
    Joined
    Mar 18, 2015
    Messages
    2,709
    Reaction score
    1,512
    • Purchased!
    • Thinking Positive Gold
    • Legacy Citizen 5
    Ship may not have armor and hull, but have 100% shields and your drone will prefer the same ship but with 0% shields, but 100% armor and hp.
    It will shoot at anything with shields down first, as it should.
    It will give priority to anything with less than 50% of it's system HP. If it has lost system HP, it almost assuredly has lost armor as well. Throw in one or two more activators to knock it up to anything under 75% of it's structural HP, same basic thing. Shoot the most damaged, most vulnerable ship.

    You are adding more checks than are required to get the job done, which frankly is sloppy coding. Beyond that, you want to be able to do things like that through a dropdown menu?

    Because they're not going to let you code the AI yourself directly, not in-game. When things get straightened out and the API comes out, sure, you can make an AI mod to default the behavior however you want, but most players aren't programmers and can't do that level of complexity.

    Its a balancing act, give enough flexibility to get great stuff done, but keep it simple enough that people can learn and use it without a computer sciences degree.
     
    Joined
    Dec 3, 2016
    Messages
    93
    Reaction score
    7
    I can also make code for block controlled AI suggestion. But again I am not a developer of Starmade and don't have it's code to be able to add something. If you know any ways, please tell me.

    I think you will like to see both realized suggestions.

    But if you want it, I need more information about your suggestion.
    Common guys! Best way to get it is to make it! Suggest any ways to add both suggestions to test it
    [doublepost=1482169355,1482166956][/doublepost]
    You are adding more checks than are required to get the job done, which frankly is sloppy coding.
    I made as much checks as I think that I should. And I am planning to add some code to bomber's example.

    This code have difference between it's logic and your mind about it. Drone will not choose biggest or most damaged entity. It will choose entity with most value calculated by code.

    Dropdown menu is enought only for code templates.

    My suggestion requires ability to make code and change it ingame.

    Would be great to be able to change AI configuration remotely.

    Its a balancing act, give enough flexibility to get great stuff done, but keep it simple enough that people can learn and use it without a computer sciences degree.
    I can suggest different ideas to make it balanced.

    People can use templates. And download them. It's not hard to choose between "fighter", "bomber", "support" and etc...
    It is functionally equivalent.
    As in, when both sets get through and pick a target, they are most likely to pick the same target.

    You don't have to replicate 100% detail as long as the output is roughly the same.
    Equivalent means equivalent. For example: 100 equals 100, but 100 is not equals 101.

    I understand that your logics is similar to my code, but it's not the same.

    Also, I can make a code equivalent of your logics. It means I can make the same (absolutely) logics using my suggestion. But I don't know any way to make block equivalent of my code.
     

    Edymnion

    Carebear Extraordinaire!
    Joined
    Mar 18, 2015
    Messages
    2,709
    Reaction score
    1,512
    • Purchased!
    • Thinking Positive Gold
    • Legacy Citizen 5
    People can use templates. And download them. It's not hard to choose between "fighter", "bomber", "support" and etc...
    So basically you're saying "I acknowledge this is too complicated for the average person to use, but thats okay because they can download pre-made templates"?

    So... what you're saying is for the vast majority of players there is no ability to customize your option, and they can only choose between premade settings.

    Yeah... about that...
    Equivalent means equivalent. For example: 100 equals 100, but 100 is not equals 101.

    I understand that your logics is similar to my code, but it's not the same.
    If I carry a thousand pebbles up a hill in a bucket, or have 1,000 people each carry one pebble at a time up that hill, the effect is equivalent. I got a bucket of pebbles up a hill.

    One is a whole lot more complicated and harder to do than the other. Just because one plan doesn't involve everything necessary to hire a thousand people and decide which pebble each one gets doesn't mean the end results are different.
     
    Joined
    Dec 3, 2016
    Messages
    93
    Reaction score
    7
    Please do within the context
    Code is a big updated, but still is not finished.
    int getPriority(Entity entity)
    {
    if(!isEnemy) return 0;
    int priority = 0;//Used to calculate

    priority = (10000/ (range + 3000)) * entityMass * (1.25 - entityShieldLevel) * (1.25 - entityArmorLevel) * (1.25 - entityHullLevel) *(0.5 + getPowerIncome()/1000000) * (0.25 + getAmountOfAttackedShips()/getAmountOfFleetShips());//Will want to attack closest biggest and most damaged entity. Also will calculate it's power income and amount of ships which are attacking it now

    if(isAlreadyAttacking())
    {
    priority *= 2;
    if(10000 < getAttackingTimeMS()) priority *= 10;
    }//If drone is already attacking this entity, it will want to continue

    if(isChoosedByFleetCommander) priority *= 10;//This line will tell drone that you choosed it. But it doesn't means that drone will attack commander's target. This line is not necessarily, but can be placed

    return priority;
    }

    Meanings of

    Equivalent means equivalent. For example: 100 equals 100, but 100 is not equals 101.
    and

    If I carry a thousand pebbles up a hill in a bucket, or have 1,000 people each carry one pebble at a time up that hill, the effect is equivalent. I got a bucket of pebbles up a hill.

    One is a whole lot more complicated and harder to do than the other. Just because one plan doesn't involve everything necessary to hire a thousand people and decide which pebble each one gets doesn't mean the end results are different.
    are similar, but diffirent.
    [doublepost=1482171255,1482170873][/doublepost]
    So basically you're saying "I acknowledge this is too complicated for the average person to use, but thats okay because they can download pre-made templates"?

    So... what you're saying is for the vast majority of players there is no ability to customize your option, and they can only choose between premade settings.

    Yeah... about that...
    Nope. Anybody is able to make basic code without much knowleges. AI can be configured without code editing just using external constants which can be changed by player. For example, it will allow players to change values of shield or range for AI: "... valueOfShield * (1 - getShieldLevelCurrent()/getShieldLevelCap()) + valueOfRange * (1000 / getRange())..."
     

    Edymnion

    Carebear Extraordinaire!
    Joined
    Mar 18, 2015
    Messages
    2,709
    Reaction score
    1,512
    • Purchased!
    • Thinking Positive Gold
    • Legacy Citizen 5
    Anybody is able to make basic code without much knowleges.
    No, no they cannot.

    I've been a programmer for 10 years now, I know for a fact most people look at this stuff and see hieroglyphics.
     
    Joined
    Dec 3, 2016
    Messages
    93
    Reaction score
    7
    No, no they cannot.

    I've been a programmer for 10 years now, I know for a fact most people look at this stuff and see hieroglyphics.
    "...a = 1/range;..."
    to attack closest
    or

    "...a = 1/range + 1/(speed + 1);...";
    to attack closest and slowest
    or

    "
    ...if(isMissile()) if(canBeAimed())
    a = 1/range;...
    "
    to attack closest missile.

    Is it hard? Yes they (most of them) see hieroglyphics, but they will be able to use external variables or make code above.
     
    Joined
    Nov 30, 2015
    Messages
    855
    Reaction score
    75
    Code is a big updated, but still is not finished.
    int getPriority(Entity entity)
    {
    if(!isEnemy) return 0;
    int priority = 0;//Used to calculate

    priority = (10000/ (range + 3000)) * entityMass * (1.25 - entityShieldLevel) * (1.25 - entityArmorLevel) * (1.25 - entityHullLevel) *(0.5 + getPowerIncome()/1000000) * (0.25 + getAmountOfAttackedShips()/getAmountOfFleetShips());//Will want to attack closest biggest and most damaged entity. Also will calculate it's power income and amount of ships which are attacking it now

    if(isAlreadyAttacking())
    {
    priority *= 2;
    if(10000 < getAttackingTimeMS()) priority *= 10;
    }//If drone is already attacking this entity, it will want to continue

    if(isChoosedByFleetCommander) priority *= 10;//This line will tell drone that you choosed it. But it doesn't means that drone will attack commander's target. This line is not necessarily, but can be placed

    return priority;
    }
    [doublepost=1482171255,1482170873][/doublepost]

    Nope. Anybody is able to make basic code without much knowleges. AI can be configured without code editing just using external constants which can be changed by player. For example, it will allow players to change values of shield or range for AI: "... valueOfShield * (1 - getShieldLevelCurrent()/getShieldLevelCap()) + valueOfRange * (1000 / getRange())..."
    I can tell you that right now, after the basic Kahn course on Java, A good amount of scratch, and Arduino experience(I made a 4 digit 7 segment display once with it too), right now that looks really jargony.

    I'm sure if I looked really close at it and someone told me all the values and weird () and * things then I could get it, but I'm a lot more into code than most people. Unless everything is blocky and there's a bunch of functions for everything, I'm not sure how I would put up with learning a bunch of stuff like that.

    I like it as blocks because it's easier to control and visualize. The thing that would take up the most space would be activators, because if you wanted fine percentages more than 50 or 25, or if you ever needed numbers(stay within 250 meters of the target) it would be great to have a penta-activator that would only work for things like rail speed and rotator and AI blocks and could work as 5 activators in one.
     
    Joined
    Nov 30, 2015
    Messages
    855
    Reaction score
    75
    Can we also add number variables for things like distance and such? So you can say "stay 400 meters away from target" and such for much more potential. Say 100 meters per activator?

    Ima make a program for fun!

    "Strafe" program

    The ship has a high cap, lower regen standpoint on both shields and power, and uses lots of overdrive on it's main Cannon/Cannon weapon. High thrust to weight ratio, ion effect on self and on weapon.

    AI Main
    If shields below 25%(5 blocks)>Nearest enemy(2 blocks)>Stay min 3500 meters away(1+35 distance blocks)
    //if it's really low on shields flee. Keep in mind that once it's shields are above 25% it will simply drift until the power-disengage kicks in or it reaches 80% power.
    If power below 25%(5 blocks)> Nearest enemy(2 blocks)> stay min 2000 meters away.(1+20 distance blocks)
    //If it's low on power retreat to a safer position
    If power below 75%(5 blocks)> Nearest enemy(2 blocks)> stay min 2000 meters away(1+20 distance blocks)
    //It still will not engage until it's power regenerates enough.
    If shields above 80%(6 blocks)> Target(1 block)> Nearest enemy with min 25% shields(6 blocks)
    //once it's shields regen it will re-engage, keep in mind that the power-disengage line is above this so it will obey that first.
    If shields below 75%(5 blocks)> nearest enemy(2 blocks)> stay min 2000 meters away(1+20 distance blocks)
    //This is a safety code so that the ship will stay away from enemies while it's shields regen, as I explained in the first line. This is the last command, so it only functions if power is above 25% and shields are between 26% and 79%.

    This would create a design that would attack an enemy with strong burst damage until it's power ran out or it lost to much shields. Then it would run away quickly with high TTM ratio and wait until it regenerated it's power and shielding to acceptable levels, and attack again. This would be never achievable with current AI.

    It would be a medium large ship in order for it to have significant power pools, and it would cost 114 blocks, which is only about a 10 by 10 flat, and if they look cool you can line your interiors with them anyway.

    95 of the blocks are used in distance increases, with pentavators (5activators in one, see above post by me)you could reduce the total number to just 38. With Decavators(10activators) you could reduce it to 29. That's barely a 5 by 5 flat, easily fitted into interiors.



    Someone's gonna steal this and reck me with it someday, I know it.
     

    Edymnion

    Carebear Extraordinaire!
    Joined
    Mar 18, 2015
    Messages
    2,709
    Reaction score
    1,512
    • Purchased!
    • Thinking Positive Gold
    • Legacy Citizen 5
    Oh yeah, and if you add in a few more blocks, you could do things like "Power Less Than 50%" "Use Cannons" by linking the cannon computer into the AI, and then under that have an "Attack:Ship" with "Missiles" so that a ship that isn't 100% power stable can be told to only try to use it's big guns when it has plenty of energy, otherwise use secondary weapons instead of just sitting there constantly trying to depower itself.
     
    Joined
    Dec 3, 2016
    Messages
    93
    Reaction score
    7
    I can tell you that right now, after the basic Kahn course on Java, A good amount of scratch, and Arduino experience(I made a 4 digit 7 segment display once with it too), right now that looks really jargony.

    I'm sure if I looked really close at it and someone told me all the values and weird () and * things then I could get it, but I'm a lot more into code than most people. Unless everything is blocky and there's a bunch of functions for everything, I'm not sure how I would put up with learning a bunch of stuff like that.
    Relax. You don't have to see code to edit it. Here will be edited constants like "range value", "mass value", "shield value" and etc. ;)

    The thing that would take up the most space would be activators, because if you wanted fine percentages more than 50 or 25, or if you ever needed numbers(stay within 250 meters of the target) it would be great to have a penta-activator that would only work for things like rail speed and rotator and AI blocks and could work as 5 activators in one.
    95 of the blocks are used in distance increases, with pentavators (5activators in one, see above post by me)you could reduce the total number to just 38. With Decavators(10activators) you could reduce it to 29. That's barely a 5 by 5 flat, easily fitted into interiors.
    Good idea. This activator makes block suggestion a bit better. (y)

    But it doesn't change much.

    Oh yeah, and if you add in a few more blocks, you could do things like "Power Less Than 50%" "Use Cannons" by linking the cannon computer into the AI, and then under that have an "Attack:Ship" with "Missiles" so that a ship that isn't 100% power stable can be told to only try to use it's big guns when it has plenty of energy, otherwise use secondary weapons instead of just sitting there constantly trying to depower itself.
    You can do it using code too. Cause with code you're not limited. You can do what you want.

    For example (for fun), drone's behavior may to depend on: amount of ships in battle, width of a target ship, distance to the sun, cargo capacity, hp of commander, level of jump drive, angle (facing) to the target ship and etc... You can make drones to dance sinchronously. :ROFLMAO:
     

    Edymnion

    Carebear Extraordinaire!
    Joined
    Mar 18, 2015
    Messages
    2,709
    Reaction score
    1,512
    • Purchased!
    • Thinking Positive Gold
    • Legacy Citizen 5
    You can do it using code too. Cause with code you're not limited. You can do what you want.
    What I don't understand is why you insist on constantly trying to derail this topic when you have your own.

    We get it, you like to code. Me too, I do it for a living. In fact, its probably some of my code that generated your last paycheck.

    But that just isn't going to fly (no pun intended) in this GAME. They are NOT going to put a coding interface into the game. I can go on about how its way over most people's heads, but lets be honest. If you gave the end user an interface where they could input code that the game engine would then blindly execute, all you've done is create a GAPING security hole in the product where anyone with half a brain can start using it to hack everyone on the server.

    Its not going to happen.


    Or at least take it to your own thread.
     
    Joined
    Nov 30, 2015
    Messages
    855
    Reaction score
    75
    Relax. You don't have to see code to edit it. Here will be edited constants like "range value", "mass value", "shield value" and etc. ;)
    I still have to figure out what "if(isMissile);((action)target);missile means, that or it just becomes static.
    You can do it using code too. Cause with code you're not limited. You can do what you want.

    For example (for fun), drone's behavior may to depend on: amount of ships in battle, width of a target ship, distance to the sun, cargo capacity, hp of commander, level of jump drive, angle (facing) to the target ship and etc... You can make drones to dance sinchronously. :ROFLMAO:
    First of all, of course you are. You can't take an Arduino, plug a light sensor into it, and tell it to find moisture levels. It would only recognize variables and inputs it could understand, which is why you need to say exactly measureLight_1. And if we do blocks we can select things like distance from object or health of object.
     
    Joined
    Dec 3, 2016
    Messages
    93
    Reaction score
    7
    What I don't understand is why you insist on constantly trying to derail this topic when you have your own.
    Or at least take it to your own thread.
    We are talking about AI. Anyone is free to prove, disprove and suggest about AI here. In addition, my own thread is not finished. Ofc I can, but I prefer not to discuss about 1 theme in different threads. For example, we are talking about different suggestions in this armor thread. If you want, you can make new thread like this to discuss about all suggestions about AI (with poll) and update it.

    Your suggestion is not bad. Penta-activator makes it a bit better. I don't say "nononono I don't want it don't do it". I just telling you +/- of different suggestions.

    I will repeat that we can make and test both suggestions. Best way to choose is to test.

    If you gave the end user an interface where they could input code that the game engine would then blindly execute, all you've done is create a GAPING security hole in the product where anyone with half a brain can start using it to hack everyone on the server.
    Relax. Noone will hack server. Because we can make isolated script which can use only specifical methods. So nobody will be able to hack using this feature.
    First of all, of course you are. You can't take an Arduino, plug a light sensor into it, and tell it to find moisture levels. It would only recognize variables and inputs it could understand, which is why you need to say exactly measureLight_1. And if we do blocks we can select things like distance from object or health of object.
    Yes we can. Of cource. But I didn't get you. Cause we can do it using both: blocks and code.

    I have an idea: what if I will add to my suggestion sensor blocks which will allow to use some code stuff? For example range sensor will allow AI to get information about range, speed sensor - speed, mass sensor - mass and etc... And we can make it for all ships and player controllable too. So without range sensor you can't know enemy's range. It's idea for block AI suggestion too. I am not sure about this suggestion, what do you think?

    I still have to figure out what "if(isMissile);((action)target);missile means, that or it just becomes static.
    I can give you basic coding knowleges using only 5-10 minutes of your time or about. You will be able to understand and write code.
     
    Joined
    Jun 13, 2013
    Messages
    16
    Reaction score
    5
    • Legacy Citizen 6
    • Legacy Citizen 5
    • Legacy Citizen 4
    The code doesn't need to be super hard or super complex for in-game AI scripting. Heck, just use LUA if you have to (it's one of the easier to learn languages out there)

    If we just give players a simple understanding of things like variables, functions, loops and how to write them in the in-game language, they're basically good to go. Have a page documenting all the basic things like getting the AI to shoot or jump out that they can look at and use. If someone really wanted to make a complex AI they should also be able to do that, but it wouldn't be necessary.

    :/ basically what I'm saying is that if people can research weapon slaves, logic blocks, rails, power and thrust formulas, other weird game mechanics and exploits to try get the best ship possible, they can learn a relatively simple scripting language.
     
    Joined
    Dec 3, 2016
    Messages
    93
    Reaction score
    7
    The code doesn't need to be super hard or super complex for in-game AI scripting. Heck, just use LUA if you have to (it's one of the easier to learn languages out there)

    If we just give players a simple understanding of things like variables, functions, loops and how to write them in the in-game language, they're basically good to go. Have a page documenting all the basic things like getting the AI to shoot or jump out that they can look at and use. If someone really wanted to make a complex AI they should also be able to do that, but it wouldn't be necessary.

    :/ basically what I'm saying is that if people can research weapon slaves, logic blocks, rails, power and thrust formulas, other weird game mechanics and exploits to try get the best ship possible, they can learn a relatively simple scripting language.
    Agree. But Java is not hard too.
     

    alterintel

    moderator
    Joined
    May 24, 2015
    Messages
    869
    Reaction score
    596
    • Likeable
    • Community Content - Bronze 2
    • Legacy Citizen 3
    How did I miss this thread.
    Great idea.

    Don't worry about the naysayers... there's always going to be guys that prefer scripting over blocks and will argue it to their last breath.