Planning possible UE1 Neural Networks.

Discussions about Coding and Scripting

Planning possible UE1 Neural Networks.

Postby Gustavo6046 » Wed Jun 20, 2018 3:26 am

Before Unreal Tournament 2003...

Before dynamic arrays existed......

Hello, guys! I am back, and I want to announce I am working on a neural network library for Unreal Engine 1. Basically, a neural network is a list of nodes, where each node (A) is two lists, of weights and biases, with the same length as the number of nodes that this node A connects its output to.

So, to be able to write a neural network, I'd need dynamic arrays of floats. But, as I said, Unreal Engine 1 is before dynamic arrays existed. Sad. But true. SO, I'd need a linked list, for EACH node, and each item in the list being a float.

Hmm, that doesn't sound good.

I want your ideas. How do you think I'd code a neural network in UnrealScript without using dynamic lists? This isn't Python, after all :(
Terrain apprentice.
User avatar
Gustavo6046
Inhuman
 
Posts: 769
Joined: Mon Jun 01, 2015 7:08 pm
Personal rank: Typing ghost

Re: Planning possible UE1 Neural Networks.

Postby PrinceOfFunky » Wed Jun 20, 2018 1:38 pm

Gustavo6046 wrote:This isn't Python, after all :(

You can create a python script that writes the output to a INT file(remember to add the BOM), run it and read the output all within unrealscript.
Image
User avatar
PrinceOfFunky
Inhuman
 
Posts: 971
Joined: Mon Aug 31, 2015 10:31 pm

Re: Planning possible UE1 Neural Networks.

Postby Feralidragon » Wed Jun 20, 2018 8:44 pm

You have some options, so to name a few:

1 - Use the same principle behind hard drives:
They store the bytes in sectors, but each sector has a fixed number of bytes, so a file will just be spread across sectors and you have just a few sectors with a lot of bytes stored, with the last one just having some unused bytes, which is OK since each sector doesn't have too many of them for the waste to make a big difference, unless you have a lot of tiny files, which generally isn't the case.

UScript-wise, you can represent each "sector" as an Object, with a property as an array of floats of a specific length.
This length is left up to you to decide, as well as how you link the sectors together (linked list, tree, both, something else).


2 - Use the same principle behind Memcached:
Memcached is an open-source software highly used in the web, which only serves to store key-value pairs in memory, which can be used simply for cache (hence the name) or anything else you want to store in memory.
They manage the memory to use in a similar fashion as sectors, but they use "slabs" instead: each slab stores a set of the key-value pairs, but these pairs allocate the exact memory set by that slab, and not only the memory that they need.

Then you have different slab tiers, let's say starting with 300 bytes, then 600 bytes, then 1kB, then 1.5kB, and so on and so forth (not exactly like this, just an example to get the point across).
And when a key-value pair is stored, it is stored in the slab with the closest amount of memory needed, so if a pair was 550 bytes, it would be saved in the 600 bytes slab, meaning that there would be 50 bytes of waste.

UScript-wise, you can represent each "slab" as an Object class, each class having the same property (an array of floats) but with a different size in each class.
Then, rather than instantiating these objects and link them in a linked list (like in the "sectors"), you just use a single object to store the entire array, but you choose the class with the closest array size able to store it, and once you go over the limit, you just switch to a higher slab.


You can also use a mix of the 2, if you want to have an optimal solution, although it will be more complex to manage.
Furthermore, you could think of this as creating your own dynamic arrays, and abstract this whole thing as such to simplify its usage in your neural network or anything else you want to use this for.
User avatar
Feralidragon
Godlike
 
Posts: 5015
Joined: Wed Feb 27, 2008 6:24 pm
Location: Liandri
Personal rank: Work In Progress

Re: Planning possible UE1 Neural Networks.

Postby Gustavo6046 » Thu Jun 21, 2018 3:28 am

Ferali, you gave me an idea.

I will do first a separate library, that allows to form dynamic lists of floats, using a float[64] array per ListCluster (where ListCluster is a linked list), and a cluster management system (which I'm not sure how I'd implement). Only then I will work in the machine learning thing. (plus I don't know gradient descent, let alone SGD)
Terrain apprentice.
User avatar
Gustavo6046
Inhuman
 
Posts: 769
Joined: Mon Jun 01, 2015 7:08 pm
Personal rank: Typing ghost

Re: Planning possible UE1 Neural Networks.

Postby PrinceOfFunky » Thu Jun 21, 2018 3:41 am

Would the input data be pre-processed or it will be just images from the viewport?
EDIT: Nvm I guess they'll not be images since you're gonna use uscript only.
But then I wonder something, how will you let the bots recognize the level geometry without even using at least DLLs?
Image
User avatar
PrinceOfFunky
Inhuman
 
Posts: 971
Joined: Mon Aug 31, 2015 10:31 pm

Re: Planning possible UE1 Neural Networks.

Postby Gustavo6046 » Thu Jun 21, 2018 5:12 am

Feralidragon wrote:1 - Use the same principle behind hard drives:
They store the bytes in sectors, but each sector has a fixed number of bytes, so a file will just be spread across sectors and you have just a few sectors with a lot of bytes stored, with the last one just having some unused bytes, which is OK since each sector doesn't have too many of them for the waste to make a big difference, unless you have a lot of tiny files, which generally isn't the case.

UScript-wise, you can represent each "sector" as an Object, with a property as an array of floats of a specific length.
This length is left up to you to decide, as well as how you link the sectors together (linked list, tree, both, something else).


I have just coded a possible sector-based float linked list. I hope this works, but I'm half asleep. I'll verify it tomorrow! Check it right below:

SectorList.zip
Float sector linked list code
(2 KiB) Downloaded 27 times


PrinceOfFunky wrote:Would the input data be pre-processed or it will be just images from the viewport?
EDIT: Nvm I guess they'll not be images since you're gonna use uscript only.
But then I wonder something, how will you let the bots recognize the level geometry without even using at least DLLs?


It doesn't use level geometry. The input set is:

  • the XYZ coordinates of 10 traces (orthogonal and diagonal horizontal directions with no vertical aim, then directly up and down) (total 30 coordinates), all divided by 128 and subtracted by the bot's position (Sigmoid)
  • (the health of the bot divided by 150 + the current enemy's health (0 if no enemy), divided by 150) (Softmax)
  • the list of weapons available (Impact Hammer through Sniper Rifle, plus the Redeemer, so 11 weapons), where each input value is 1 if the bot has the weapon, or 0 if it doesn't (Linear)
  • the conveyed list of every visible Pawn (size 3) (Sigmoid)
  • the XYZ coordinates of current bot's velocity, divided by 128. (Sigmoid)

So 49 input nodes already.

And now... a few important notes:

1. A classifier is a simple neural network that will give a rating to an item in a list. It is activated once for every item in the list, and the highest rating item is selected.

The classifier's input is the criteria (small set of numbers, the same for every classification iteration, can for example be the output of another neural network when that one's output is criteria to pick ONE item in a list), and data about the item (e.g. conveyed characters for a string, or a Pawn's Input Info - see below). The classifier's output is ONE number, preferably not squashed by an activator like a sigmoid (we're not talking probabilities here, son).

2. The conveyed list of every visible Pawn is obtained like this, in UnrealScript-esque pseudocode (if we can classify this as pseudocode for using undefined local variables and shortcuts like that):

Code: Select all
res = New(class'FloatList'); // from my float sectors library
res.AddRepeated(0, 3);

foreach VisibleActors(class'Pawn', P)
{
   PI = PawnInputInfo(P); // a function that makes an input list from a pawn
   res = Conveyor.activate(class'FloatList'.static.Concatenate(res, PI));
   PI.Destroy(); // where's my garbage collector ;_;
}

return res;


3. Pawn input info is a set containing p.Health, p.bIsPlayer (1 = true, 0 = false), p.PlayerReplicationInfo.Team / 4 (or -1 if no PRI), and . The input is a concatenation of the last iteration's output (or {0, 0, 0} if there was no previous iteration) and the current iteration's pawn input info. It returns the last iteration's output. I call that dynamic list conveying, or just conveying for short.

4. The order of the weapons in the available weapon listing is:

  1. Impact Hammer || Chainsaw
  2. Enforcer
  3. Bio Rifle
  4. Shock Rifle
  5. Pulse Rifle
  6. Ripper
  7. Minigun
  8. Flak Cannon
  9. Rocket Launcher
  10. Sniper Rifle
  11. Redeemer


The output will be (n usually ranges from 0 to 1 in choice-based ("Whether") outputs):

  • Whether to target someone
  • Length-3 criteria for the target classifier
  • Whether to move forward (n > 0.5), backward (n < -0.5), or neither (0.5 >= n >= -0.5).
  • Whether to strafe right (n > 0.5), left (n < -0.5), or neither (0.5 >= n >= -0.5).
  • Whether to aim toward the target (n > 0.5), toward the navigation dest (n < -0.5), or neither (0.5 >= n >= -0.5).
  • Whether to fire (n > 0.5), to alt-fire (n < -0.5), or neither (0.5 >= n >= -0.5).
  • Whether to feign death (n > 0.5) if not already; if n <= 0.5 and it is still feigning, get up.
  • Whether to crouch (n > 0.2).
  • Whether to jump (n > 0.1).
Terrain apprentice.
User avatar
Gustavo6046
Inhuman
 
Posts: 769
Joined: Mon Jun 01, 2015 7:08 pm
Personal rank: Typing ghost

Re: Planning possible UE1 Neural Networks.

Postby Barbie » Thu Jun 21, 2018 3:46 pm

Gustavo6046 wrote:I hope this works, but I'm half asleep. I'll verify it tomorrow! Check it right below:

SectorList.zip
Does this even compile? AFAIR neither Tick() nor Destroy() exist for Objects. (See also my question Opposite of New()?)

Also I remember a problem with the name of objects that are created by New() without a given parent: the names will follow the structure of "ObjName0", "ObjName0.ObjName1", "ObjName0.ObjName1.ObjName2", ... and this will crash when the length of 1023 is exceed (see EDIT section of this posting).
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
Barbie
Godlike
 
Posts: 1578
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Planning possible UE1 Neural Networks.

Postby sektor2111 » Thu Jun 21, 2018 7:20 pm

The rest of debates is here viewtopic.php?f=12&t=12219&p=97717&hilit=neural#p97707
for the case when an admin wants to merge these scientific debates. N.A.S.A. are small kids compared with debates around UE1 posted here.

I will take a break for a while until another no-end type neural braining plants and mushrooms 3rd post will pop up from behind a random keyboard.

Edit:
Reason - Somebody has lost the class with dynamic arrays.
UE1 IS CAPABLE NATIVELY to work with dynamic arrays around STRINGS. E.G. "ServerPackages" "ServerActors" - if you have knowledge about what they are. These are used in a default server-game configuration and they are not having a fixed value, can be 10 or 20 or X until game is crashing out of memory.
In UScript you can use some dynamic arrays with XCGE, without XCGE game is crashing even if U file is compiled/created - as evidence, is that sort of RandWeapon Loader which I did months ago and I'm using it as long as in my server it works perfectly. It is loading a random weapon from a list which might have 10 weapons or 15 or 25 weapons with a condition: leaving last position empty for detecting end of array(s) else it does an error "out of bounds"; to not forget that it loads even ammo for weapon in cause giving to player an additional load. Here I do not have any plan with neural stuff, it was my curiosity about dynamic arrays. To summarize, for me was possible READING a dynamic array which I REPEAT, UE1 KNOWS these natively but some other natives were crapped up (I'm not sure if Core was screwed up here), that's why UScript is crashing if it's not helped, not because Engine doesn't recognize them.
User avatar
sektor2111
Godlike
 
Posts: 3711
Joined: Sun May 09, 2010 6:15 pm
Location: vect(1,1,1)

Re: Planning possible UE1 Neural Networks.

Postby Gustavo6046 » Thu Jun 21, 2018 11:23 pm

Thanks. I have theoretically fixed SectorLists (I will upload them here; bundled witth GusPackII, so I can pick them up in a future PC since this one's shitty screen broke). See below.
Attachments
GusPack + SectorList.zip
(4.56 MiB) Downloaded 37 times
Terrain apprentice.
User avatar
Gustavo6046
Inhuman
 
Posts: 769
Joined: Mon Jun 01, 2015 7:08 pm
Personal rank: Typing ghost

Re: Planning possible UE1 Neural Networks.

Postby papercoffee » Thu Jun 21, 2018 11:54 pm

What did you fix and why should we download it??? :noidea
User avatar
papercoffee
Site Staff
 
Posts: 8986
Joined: Wed Jul 15, 2009 11:36 am
Location: Cologne, the city with the big cathedral.
Personal rank: coffee addicted !!!

Re: Planning possible UE1 Neural Networks.

Postby Carbon » Fri Jun 22, 2018 10:17 am

papercoffee wrote:What did you fix and why should we download it??? :noidea


Not sure our downloading was the purpose.

Gustavo6046 wrote:I will upload them here so I can pick them up in a future PC since this one's crappy screen broke
User avatar
Carbon
Inhuman
 
Posts: 810
Joined: Thu Jan 17, 2013 1:52 pm
Personal rank: Hoarder.

Re: Planning possible UE1 Neural Networks.

Postby Feralidragon » Fri Jun 22, 2018 2:12 pm

Just as Barbie said.

When I suggested for you to essentially create your own dynamic arrays in different ways through Objects, the idea was to really treat them as objects like you would do in any other language, be it Python, Java, C#, PHP, whatever.
And in other languages, you do not "destroy" objects, you just dereference them and let the garbage collector handle them, and is the same thing with UScript, with just a few caveats.
You don't tick anything either, because objects like these only hold data, they don't do anything by themselves alone.

Barbie wrote:Also I remember a problem with the name of objects that are created by New() without a given parent: the names will follow the structure of "ObjName0", "ObjName0.ObjName1", "ObjName0.ObjName1.ObjName2", ... and this will crash when the length of 1023 is exceed (see EDIT section of this posting).

I actually wasn't aware of this, but I tested it yesterday, and yeah.

Although that behavior contradicts the one written here: https://wiki.beyondunreal.com/Operators#New_operator
It states that the value of outer is None by default, but that's clearly not true, at least in UT v436, and I would assume in UE1 in general.

So to instantiate an object, one needs to do it as one of the following:
Code: Select all
obj = new (none) class'MyObject';

or

obj = new (Outer) class'MyObject';

The first one places the object as part of the Transient package (this is generally the wanted behavior), while the other will place the object as part of whichever package the object it was spawned from (without all that hierarchy).
It looks ugly as hell though, but it makes a stronger case to use a factory pattern instead of instantiating the objects directly.
User avatar
Feralidragon
Godlike
 
Posts: 5015
Joined: Wed Feb 27, 2008 6:24 pm
Location: Liandri
Personal rank: Work In Progress

Re: Planning possible UE1 Neural Networks.

Postby papercoffee » Fri Jun 22, 2018 4:07 pm

Carbon wrote:
papercoffee wrote:What did you fix and why should we download it??? :noidea


Not sure our downloading was the purpose.

Gustavo6046 wrote:I will upload them here so I can pick them up in a future PC since this one's crappy screen broke

I know what he wrote ...but that's not what Forum uploads are for ...he could use a free file host to storage it online or upload the file into a PM to himself.
User avatar
papercoffee
Site Staff
 
Posts: 8986
Joined: Wed Jul 15, 2009 11:36 am
Location: Cologne, the city with the big cathedral.
Personal rank: coffee addicted !!!

Re: Planning possible UE1 Neural Networks.

Postby Gustavo6046 » Fri Jun 22, 2018 11:39 pm

Nonetheless, what I fixed was the SectorList system, theoretically now it works. I can unfortunately not test it at the current moment, but I will try with my neighbor. Morevover, sorry for bundling GusPackII - it's a necessity. It is back now on development!
Terrain apprentice.
User avatar
Gustavo6046
Inhuman
 
Posts: 769
Joined: Mon Jun 01, 2015 7:08 pm
Personal rank: Typing ghost


Return to Coding, Scripting

Who is online

Users browsing this forum: No registered users and 1 guest