Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - ninekorn

Pages: [1] 2 3 ... 13
1
I am working on a version of AI learning/machine Learning for Void Expanse so that I can use that on the drones to make their movement better in game and also for their decision making. I am barely getting started in this though. I am currently working on a version of it based on the series by Sebastian Lague here : https://www.youtube.com/watch?v=bVQUSndDllU
He built his tutorial in Python, although that wasn't why I decided to learn a bit of Python a couple of days ago, it was actually for exporting TONS of objects and build XML files for Void Expanse all at the same time. I've decided to "try" and translate his Python tutorial of Episode 1 and 2 mathematical equations to c# inside of Unity and started playing with that. But I am encountering some "obstacles". For instance, when Sebastian Lague explains the mathematical equations in episode 1 and 2, there is something that I am missing. I don't know how he is using the "output" of the Neural Network. Is he "re-feeding" it into the neural network as inputs in order for the neural network to complete a certain number of iterations until it reaches the goal?

If anyone has any idea of how Machine Learning works, and has really good explanations that can be understood for a beginner, I would be really interested in asking questions. here is what I have so far.. Although the script is able to get to the goal whether it is closer to 1 or closer to 0 which is going to be perfect for me when using the Dot product for the movement in Void Expanse, I have no clue if this qualifies as a Neural Network.

Code: [Select]
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

public class SC_Neural_Network : MonoBehaviour
{
    double[] input;
    double[] weightsOne;
    double[] hiddenLayer;
    double[] lastHiddenLayer;
    double[] biasValueOne;
    double[] biasValueTwo;
    double[] output;
    double[] lastOutput;

    double[] currentOutputError = new double[2];
    double[] lastOutputError = new double[2];

    double[] currentHiddenLayerOutputError = new double[3];
    double[] lastHiddenLayerOutputError = new double[3];
    double[] lastHiddenPercentChanged = new double[3];
    double[] currentHiddenPercentChanged = new double[3];

    double[] weightsTwo;
    System.Random rand = new System.Random();

    double[] lastPercentChanged = new double[2];
    double[] currentPercentChanged = new double[2];

    public void Start()
    {
        input = new double[2];

        weightsOne = new double[6];
        hiddenLayer = new double[3];
        lastHiddenLayer = new double[3];
        biasValueOne = new double[3];
        biasValueTwo = new double[2];
        output = new double[2];
        weightsTwo = new double[6];
        lastOutput = new double[2];


        neuralNet(0.001, 100); // right now, can only use 0.001 or 0.999
    }

    double oriGoal = 0;

    int starter = 0;
    int finisher = 0;
    int someCounter = 0;

    //right now only working for input of 2 and hidden layer of 3 and output of 2 and biasOne 3 and biasTwo 2 and WeightsOne 6 and WeightsTwo 6
    private void neuralNet(double goal,int counterMax)
    {
        oriGoal = goal;

        while (someCounter < counterMax && finisher == 0)
        {
            if (starter == 0)
            {
                input[0] = rand.NextDouble();
                input[1] = rand.NextDouble();
                for (int c1 = 0; c1 < weightsOne.Length; c1++)
                {
                    weightsOne[c1] = rand.NextDouble();
                    weightsTwo[c1] = rand.NextDouble();
                }
                for (int c1 = 0; c1 < biasValueOne.Length; c1++)
                {
                    biasValueOne[c1] = rand.NextDouble();
                }
                for (int c1 = 0; c1 < biasValueTwo.Length; c1++)
                {
                    biasValueTwo[c1] = rand.NextDouble();
                }
                starter = 1;
            }
            else
            {
                input[0] = output[0];
                input[1] = output[1];
            }

            for (int c = 0; c < hiddenLayer.Length; c++)
            {
                hiddenLayer[c] = ActivationFunction(input[0] * weightsOne[c * 2 + 0] + input[1] * weightsOne[c * 2 + 1] + biasValueOne[c]);
            }

            for (int c = 0; c < output.Length; c++)
            {
                output[c] = ActivationFunction(hiddenLayer[0] * weightsTwo[c * 3 + 0] + hiddenLayer[1] * weightsTwo[c * 3 + 1] + hiddenLayer[2] * weightsTwo[c * 3 + 2] + biasValueTwo[c]);
       
                if (output[c] <= goal && goal >= 0.999)
                {
                    currentOutputError[c] = 1 - output[c];
                    lastOutputError[c] = 1 - lastOutput[c];

                    var totalDiffInError = Math.Abs(currentOutputError[c] - lastOutputError[c]);
                    currentPercentChanged[c] = totalDiffInError / currentOutputError[c];
                    var diffToGoal = Math.Abs(goal - currentOutputError[c]);

                    if (currentOutputError[c] >= lastOutputError[c])
                    {
                        for (int c1 = 0; c1 < weightsOne.Length; c1++)
                        {
                            currentPercentChanged[c] *= 1.19;

                            double someTest = (currentOutputError[c] * currentPercentChanged[c]);
                            weightsOne[c1] = weightsOne[c1] - someTest;

                            someTest = (currentOutputError[c] * currentPercentChanged[c]);
                            currentPercentChanged[c] *= 1.19;
                            weightsTwo[c1] = weightsTwo[c1] - someTest;
                        }
                    }
                    else if (currentOutputError[c] < lastOutputError[c])
                    {
                        for (int c1 = 0; c1 < weightsOne.Length; c1++)
                        {
                            currentPercentChanged[c] *= 1.19;

                            double someTest = (currentOutputError[c] * currentPercentChanged[c]);
                            weightsOne[c1] = weightsOne[c1] + someTest;

                            someTest = (currentOutputError[c] * currentPercentChanged[c]);
                            currentPercentChanged[c] *= 1.19;
                            weightsTwo[c1] = weightsTwo[c1] + someTest;
                        }
                    }
                }
                else if(output[c] >= goal && goal <= 0.001)
                {
                    //Debug.Log("test00");
                    currentOutputError[c] = 1 - output[c];
                    lastOutputError[c] = 1 - lastOutput[c];

                    var totalDiffInError = Math.Abs(currentOutputError[c] - lastOutputError[c]);
                    currentPercentChanged[c] = totalDiffInError / currentOutputError[c];

                    var diffToGoal = Math.Abs(goal - currentOutputError[c]);


                    if (currentOutputError[c] >= lastOutputError[c])
                    {
                        for (int c1 = 0; c1 < weightsOne.Length; c1++)
                        {
                            currentPercentChanged[c] *= 1.33;
                            double someTest = (currentOutputError[c] * currentPercentChanged[c]);

                            weightsOne[c1] = weightsOne[c1] + someTest;

                            currentPercentChanged[c] *= 1.33;
                            someTest = (currentOutputError[c] * currentPercentChanged[c]);
                            weightsTwo[c1] = weightsTwo[c1] + someTest;
                        }
                    }
                    else if (currentOutputError[c] < lastOutputError[c])
                    {
                        for (int c1 = 0; c1 < weightsOne.Length; c1++)
                        {
                            currentPercentChanged[c] *= 1.33;
                            double someTest = (currentOutputError[c] * currentPercentChanged[c]);
                       
                            weightsOne[c1] = weightsOne[c1] - someTest;

                            currentPercentChanged[c] *= 1.33;
                            someTest = (currentOutputError[c] * currentPercentChanged[c]);
                            weightsTwo[c1] = weightsTwo[c1] - someTest;
                        }
                    }
                    /*else //not used but if the above variable 1.33 is less than 1.19, it breaks the script and i gotta implement this part
                    {

                    }*/
                }
                else if(output[c] <= goal && goal <= 0.001 || output[c] >= goal && goal >= 0.999)
                {
                    finisher = 1;
                    Debug.Log("FINISHED AND REACHED GOAL");
                }

                lastPercentChanged[c] = currentPercentChanged[c];
                lastOutput[c] = output[c];
               
                Debug.Log(output[c]);
            }
            someCounter++;
        }
    }

    double ActivationFunction(double x)
    {
        return (1 / (1 + Mathf.Exp((float)-x)));
    }
}



EDIT: this can hardly be qualified as a neural network except for the variable names in the script. I am far from the goal. Will keep learning and searching for more info on how to implement a working version in c# or javascript.





2
So, I manually set each Pivot to be exactly the same X as any other objects in the same X axis row of walls..

It looks like this in blender. But when I export to .obj, i set the position of each object to x=0 and y=0. The original position of the object is kept in memory and used in the name of the XML file so that I can use that ingame to spawn turrets to the offset where they are supposed to be just like in Blender. I output the names of the XMLs by code to a notepad and just copy paste them to the library in Void Expanse for spawning them. Super fast instead of manually doing everything, and with the number of times that I gotta rebuild them in Void Expanse to test if they are aligned, it sure helps to have an automation on the workflow.






But again, it gives me this result in Void Expanse lol. They are now aligned with the axis X but not with the axis Y... haha wth am i doing wrong. Geez. Blender and the pivot is annoying me ;)






Im gonna try next the same distance between each walls.


And now with an offset of 2.25 units in the Y axis from blender for every model's pivot point gives this... Like... Huh?




OH... there is a detail you mentioned and I am not sure that i got it right. The unit conversion. I am using the exact units from blender without any changes. You can see in the void expanse screenshots that something is wrong where the wall tiles are "spawned" a little bit short in distance compared to the floor tiles which isnt supposed to happen, the floor tiles to the left extremity should be aligned with the last wall too. So definitely, it must be the unit conversion the issue. I'm gonna look for some fix on this.




Funny thing it works when i actually remove 2.25 units from the first wall at each extremity in Void Expanse Javascript when spawning the walls. Example, i take the Y position from the xml file name of the most right or most left wall, than I add or remove 2.25 units in Javascript when spawning the walls. It works like that but it means that the units that i get from Blender aren't working. Im not sure if I already asked you ai_enabled in some other post what the units of Void Expanse are compared to those in Blender. Please enlightened me when you get the chance, otherwise, this whole thing will be a pain to make offsets in code for everything to line up .Thank you
 

3
Hi ai_enabled, i'm going to try different models in Blender. I think that "maybe" the issue is related to the pivot point again... Although they are all at the perfect axis Z location, their pivot point in axis X and axis Y are different.

I had to learn to code a bit of Python in 3 days to make all of this work. The models are all exported by code, the XML files by code, the png's by code, the floor are decorations but the walls are turrets... Lol it was a lot of work but python is interesting for sure. It must've taken me 4-5 hours just to insert the XML nodes in code so that the xml files load in Void Expanse, but the nice thing is that it now works. I can use Python with models of Blender that I export from code and everything is done automatically for, in this case, over 100+ models.

I will try to align all of the pivot points so that they are aligned all with the same distance from each other if i can... Im not sure yet how to do this as manipulating pivot point from code in Python is not super user friendly, unless you know the API functions. I mean blender python code is scarce compared to unity c# and unity javascript.


4
Hi, I just wanted to know if when using the generator.AddNPCShipToSystem if the position x and y are actually rounded instead of using the exact location where i want them spawned.

Below picture shows why i am asking. I am able to create destructible parts from Blender and then from the destructible parts, i am creating "turrets" without AI to drive them, and I put their weapon invisible, which makes it so that i have static Walls in place for the station and those walls are destructible. Although I set the correct pivot location for every object in Blender and double checked they were correctly aligned, they aren't spawned where i want them to in Void Expanse. Any ideas why?




EDIT: Nevermind about my question.... I just printed to console and the correct position is supposed to be set. That is confusing me.

5
Mods / Re: DESTRUCTIBLE STATIONS - in-progress - 9sMODS DEVELOPMENT
« on: August 03, 2019, 01:11:27 pm »
Change of plans. Stations will have much more destructible parts than first intended. But its not finished and currently, for some reasons, there is an offset to the outer walls of the stations. Here it is just showing the floor of the station and the outer walls that aren't aligned. Will keep working on it.




I am posting here to get some help on the matter if anyone's curious.
http://forums.atomictorch.com/index.php?topic=1402.0

6
Mods / Re: Drone/Follower mod // in-progress - 9sMODS DEVELOPMENT
« on: July 30, 2019, 07:53:25 am »
Just wanted to report that I've been taking a couple days off to relax and enjoy playing games as it's been a while that I have profited from that (like 3 years). Btw, for anyone interested in pathfind, i have created a pathfind library in Void Expanse that uses a "Spiral" type of tile discovery and use tiles of 2*2 (that can be customized to a certain extent) which is insanely lightweight compared to traditional pathfind that uses huge area to calculate pathfind tile distances. I was trying to find my post where I am explaining how it works and couldn't find it somehow so i decided to post it back here.

How it works is that the first set of tiles that are discovered are stated below from lower number to highest in a spiral shape type of array:

456
307
218

The first tile to be discovered is the tile #0. Then whatever other tile that the pathfind discovers increases the array to 9 length (for the first squared perimeter) but ONLY the chunk that is discovered is calculated and the others remain empty/null which makes it so that the pathfind is only discovering tiny chunks of 2*2 and leaves the rest null but how the pathfind works is that it keeps in memory the already discovered chunks of 2*2 (only the tiles that are pertinent to the path to target) so that when the pathfind finds the target, it's able to retrace the path. And the pathfind is unlimited in distance meaning that everytime the pathfind discovers a new chunk of 2*2 that is NOT inside the first perimeter of the array length, it will increase the size of the array to contain the new perimeter of the spiral which is insanely cool. For example, the first size is 9, the second perimeter increases the size of the array to 24 total chunks with mostly null data since only the chunks where the pathfind is heading are calculated, the next perimeter increases the spiral and square to make it so that the array contains 48 chunks, etc... The reason why I went with a spiral array instead of a traditional let's say 10*10 array of chunks or 5*5 array of chunks is that it was way too heavy in Void Expanse for every NPCs that were activating their pathfind.

If anyone knows where else I have posted this, please tell me as I don't remember, it might actually be in one of my videos. I'm thinking of creating a blog about this type of pathfind, although it uses Sebastian Lague's Youtube tutorial on pathfinding, i'm not sure if he uses the same "spiral" form of pathfind in his tutorial. I'd have to ask him if it's even possible to contact him.

As for the MODs, I have worked a tiny bit on "recycling" my station interior models and modified them for Modular Destructible stations. Here it is in the works with the modular parts highlighted in orange/yellow:

Outpost01 interior consists of building 13 parts (probably less after revising it)


I am just hoping that building separate parts for the station interior recycled Models from the 9Mods part 1.0 will make it so that it's friendlier with the Farseer Physics Engine in Void Expanse as I was encountering physics crash/server hangs in 9Mods part 1.0 where i had to temporarily "discontinue" the station interior mod. I still don't even know where the crashes were happening but I suspect that jumpgates or turrets colliders were spawning right in the station colliders which was crashing the server. I didn't continue testing to make that irrefutable conclusion, instead I moved on to other things.

So my goal is to bring the station interior Mod with destructible Modular parts and each part will have it's own physics for collision and it will be possible to build them separately and destroy them anywhere in the galaxy where you are permitted to build stations.

7
Mods / Re: 9sMODs - Part 2.3 of 9.0 - RELEASED - Range Combat drones
« on: July 18, 2019, 10:06:20 am »
9sMODs - Part 2.3 of 9.0 - RELEASED

Range Combat (RC) Drones Update.

You now have access to spawning Range Combat Drones. Right now, they use the exact same combat technique and are NOT shooting further away than the close combat (cc) drones. But they have different damage types like Particle Discharge and Guided/Unguided Missiles and Gauss Canon.

Please give feedback if you played the MOD whether you liked it or not. This is not the final version, as you probably noticed, that the drones all cost the same amount of Ingame currency. Also, currently, all drones are not "smart" enough to notice if other friendly drones are in their sight when they shoot. Also, i will soon finalize the pathfinding for the mining drones as right now, a path is discovered for them but the path doesnt exclude unwalkable tiles. Those will be changed in future patches.   ;)

Drone Combat With 2 repair Drones, 1 Combat Energy machine Gun drone, 1 laser combat Laser Drone, 1 Particle discharge combat Drone In combat against enemy


3 mining drones mining some asteroids + 1 repair drone + 1 laser combat drone getting attacked
part 1 of 6

part 2 of 6

part 3 of 6

part 4 of 6

part 5 of 6

part 6 of 6





Drone Combat With 2 repair Drones, 1 Combat Ballistic machine Gun drone , 1 combat Laser Drone, 1 Guided Missile combat drone
part 1 of 3 - Guided missile on top of planet - drone missed his shot

part 2 of 3 - missile hitting enemy

part 3 of 3 - peaceful mining










8
Meh... For 2 weeks I have been having sleep issues. Couldn't even work on this and make the engines look better. it's as if I had lost all interest. I missed two days of work last week and went to have blood samples taken for tests for doctors to find whatever is wrong with me. It feels as if i've reached a point of no return, like, i cannot get back to a good 8 hours of rejuvenating sleep. Anyway, they will find whatever is wrong if there is anything wrong.

Except for those news, I've decided to push back a little bit further away the items Generator MOD because I am still undecided as to using the original images for the store sprites or not... I don't really my coded drawings, they need to be improved... Instead, to find new inspiration, I will start working on Machine Learning to see if there is a way that I can implement that into Void Expanse. I just wanna share that the drones formation that you see in game is the "easy" version that I was working on and not the "other" version where drones are mimicking the player's movement to stay in formation. I want fancy stuff for Void Expanse. So i'm gonna start getting knowledge on Machine Learning tonight. I will keep you guys updated as soon as I have a breakthrough.

9
Mods / Re: Upcoming unlimited weapons mod and also a Galaxy Market.
« on: July 08, 2019, 12:38:19 am »
Here is the new design... Still missing a lot of props. And no fire in the thruster area. But the edges are made with code. Will soon make them procedural



10
Mods / Re: Upcoming unlimited weapons mod and also a Galaxy Market.
« on: July 05, 2019, 10:09:25 am »
Almost done with the Engine Item Generator. But here's what I've got so far for sprites. I'm not totally sure that it's gonna work with the current design. I'm not satisfied with looks of them, its as if they were drawn by hand by someone who fails at drawing. The first version was a 2d look and it was ugly as hell but this one is the "simili 3d look" and I still find them ugly. They are procedurally generated. I would be able to generate thousands of those that are different from one another and I can change many things on the design. I am barely starting in 2d drawing.

You will see engines with yellow for energy, purple for fuel and turquoise for shield. All engines that are equiped with a tank AND generator will be able to produce a small amount of regen for the player's ship. The engines that are equipped with the generators have the tiny pipe/wire running from above the truster to the container tank of the rocket engine.

The engines also will affect a tiny bit the structural integrity of ships. The white one is the basic metal model of structural hull and the darker one is the carbon fiber.



It feels as if it's not gonna cut it for nice visuals in Void Expanse. I'm gonna try to find tutorial on how to draw 3d to 2d.  Do they even look like engines? I mean they look like a vase that has fallen down that spits fire lol. Please give me your opinion anyone.

This is the original:


11
Help section / Re: How to use ship.SetEquipmentCacheValue?
« on: July 05, 2019, 10:07:47 am »
Ok thank you ai_enabled!

12
Help section / Re: How to use ship.SetEquipmentCacheValue?
« on: July 02, 2019, 10:30:55 pm »
ai_enabled, when you have the chance, can you also confirm that the node <durability> is also useless for the moment?

13
Help section / Re: How to use ship.SetEquipmentCacheValue?
« on: July 02, 2019, 02:42:30 pm »
Yeah ai_enabled. Im halfway through building the "infinite" with procedural "icon" generator starting with the Engines items. So players will visually see different icons for each engine parts that they wish to get in the shop. Also, the icon visually will display the color of the engine "trail" so that players dont need to necessarily read what color the trail is, instead they will see it.

The thing is I stumbled upon the upgrades node and wanted to know if it was something i could incorporate in the item generator.

I will find another way with Global Variables. Anyways, upgrades are so much so the same thing as "passive skills". Im gonna think of something.



14
Help section / Re: How to use ship.SetEquipmentCacheValue?
« on: July 02, 2019, 12:42:22 am »
ai_enabled? Do you have an explanation for the nodes:

<upgrades_max>10</upgrades_max>
<upgrades>
</upgrades>

If I do this below, it doesn't crash the game as if maybe it was made for that? But how to activate or upgrade the item ingame?:
      
<upgrades_max>10</upgrades_max>
<upgrades>
     <effects>
      <effect>
         <effect_type>speed_max_value</effect_type>
         <effect_base>400</effect_base>
      </effect>
     </effects>
</upgrades>


I tried those functions here without luck:

//var upgrades0 = game.GetItemUpgrade(shipItems);
//var upgrades1 = game.GetItemUpgrades(shipItems);
//var upgrades2 = game.GetItemLevel(shipItems);
//var upgrades3 = game.GetItemLevels(shipItems);
//var test0=  items.GetItemUpgrade(items);
//var test1 = items.GetItemUpgrades(items);
//var test2 = items.GetItemLevel(items);
//var test3 = items.GetItemLevels(items);
//var test0=  items.GetItemsUpgrade(items);
//var test1 = items.GetItemsUpgrades(items);
//var test2 = items.GetItemsLevel(items);
//var test3 = items.GetItemsLevels(items);
//var test0=  game.GetItemsUpgrade(items);
//var test1 = game.GetItemsUpgrades(items);
//var test2 = game.GetItemsLevel(items);
//var test3 = game.GetItemsLevels(items);

//var test3 = items.GetItemData(items);
//var test3 = items.GetItemsData(items);



EDIT: I can put pretty much any type of string inside the node <upgrades> and the game won't crash. It's as if whatever data that the node contains, it's nullified or discarded in the core engine. maybe it is, maybe it's not.

15
The drone MOD is not at it's last version .I will create other drones very soon as now it's just a matter of creating assets which very easy to do. But before I do that, I want to create the infinite Item Generator that I've been talking about for a while on the forum. For such a long time, I was working and trying to make a better version of the drone AI and finally I've reached the part where I was ready to release it. It's still "not totally polished", but I can really easily add different "combat techniques". You can see in the "SC_AI_Drone_Combat_cc_Rout_Co m_Att_Tec2_1.js" scripts from 1 to 5 and "SC_AI_Drone_Combat_cc_Rout_Co m_Att_Tec3_1" from 1 to 5 that those scripts are for the "combat techniques". The combat techniques can be chosen randomly or not with the script "SC_AI_Drone_Combat_cc_Rout_Co m_Att_1.js". The reason that there is so many libraries now, was that It was the only way that I have found to make this work without "a huge hit" on the performance. If ALL of those scripts were combined into 1, all drones would be accessing a script that would be 3000-4000 lines long. It wouldve been lagging much more when creating drones for the first time when you are spawned in the server, so much so that there would have been a "thread lag error" in the console. Also, by making it so that the drones at Formation 1 are using the series of script ending with 1, makes it so that the scripts are holding ONLY the data of drones that are in Formation 1 and so on for Formation 2 to 5. In order to make this happen for Multiplayer, I had to create an array of Global Index that is seen in the script "SC_AI_Drone_Manager_Utilities .js" and in the "drone_manager" for "Combat/Mining/Repair".

This method works but it can be improved. I will work later on improving the scripts and adding much more content of drones as it is now easy since we now have the basics of Releasing/Retrieving drones that works for all players in multiplayer.

N.B If you like this MOD, please comment on it on the steam workshop webpage for that MOD or in this thread. It can only make me understand your needs and improve this MOD so that it becomes way better in the future. I do have other ideas for drones like "ramming drones/Tank Drones for taking lots of damage/shield regen drones/etc". Tell me if you like the current MOD!

172 scripts so far to make the whole thing work, but the Void Expanse Engine can handle it. Much more are coming anyway. 60 more Library scripts will be required in order for the RC drones to be implemented. It can take me about 1-2 hours to do it so If any of you want me to rush it, please ask here. Otherwise, I really want to start working on the Items Generator. But the RC drones contain the "Particle Ray weapon" that is in the original game and also the "Gauss Cannon" that both do more damage than the other conventional Drone Weapons. A fix is coming soon also for the huge damage output that the  "Ballistic Burst Cannon" is doing... I forgot to fix the damage of one of the bullets that does 200 damage instead of 4 damage.

PLEASE NOTE THAT CURRENTLY, THE DRONES ONLY GAIN LEVELS WHEN THEY ARE BEEING RETRIEVED AND THEN RELEASED. OTHERWISE, THEY WILL STAY AT THE LEVEL THAT THEY FIRST SPAWNED AT. I AM NOT EVEN SURE THAT I CAN INCREASE THE LEVEL OF NPCS WITHOUT RETRIEVING THEM FIRST (REMOVE) FROM THE GAME. I WILL HAVE TO STUDY THE ORIGINAL SCRIPTS A BIT MORE FOR THAT.

Pages: [1] 2 3 ... 13