CPU project. Making computer inside the collective mind

User avatar
DjSapsan
Script
Script
Posts: 48

CPU project. Making computer inside the collective mind

Post#1 » 31 Jul 2018, 12:54

DISCLAIMERs:
0) Im from Ukraine and very bad know English language.
1) I have not so much time, this topic will evolve slowly.


Dont look at disclaimer please :D

Task: create real CPU (Turing complete machine) inside the artificial intelligence of bots using general nodes (tags, conditions, actions).

PROGRAM FOR CONVERTING TAGS TO BINARY
Im talked a bit in discord about computing and decided to start this project. I have experience with creating and programming CPU. With help of community we can create real CPU and programm it. For example, programs can be: dividing, counting, fibonacci numbers,array sorting, dances, smart behavior, graphical output (with 10+ bots), an so on.
My first thoughts about logic: any object can have tags (personal and team tags). Using tags in different combinations we can addressing different parts of program. Different objects can represent registers (and registers can represent output). Tags on object represent certain values. For input we can use only memory (or behavior of opponent bots, its memory too). For operations we can use complicated logic with "if-else". With only adding (using binary system) possible to make subtracting, multiplying, dividing and so on.
I have not so many time now, and i waiting for requests, asks and suggestions.
EDIT 1: BINARY SYSTEM AND ADRESSING ( V )
EDIT 2: ADDING TWO NUMBERS ( V )
Last edited by DjSapsan on 06 Aug 2018, 19:34, edited 1 time in total.

User avatar
DjSapsan
Script
Script
Posts: 48

Re: CPU project. Making computer inside the collective mind

Post#2 » 31 Jul 2018, 23:14

First we need system of addressing. Address is a number that refers to certain object in the array. We can have many objects such a memory cells, or registers, or something else. To define needed object in array programmers usually uses countable system. In real world its a binary system. In game we have tags. How much objects can we address?
Calculations (here only point of view from single bot):
First we will count only myself. Some math. "Myself" can have tag X and can have NO tag X. Number of different tags is 5. Its mean, range of values for "Myself" is (- - - - -) to (5 4 3 2 1) = 2^5 = 32 combinations.
12345.jpg.jpg
12345.jpg.jpg (41.08 KiB) Viewed 1370 times


With "Myself" only we can address only 32 different things. Lets tag other objects.
Math for 4 bots (remember PoV):
"Myself" can tag "Myself" and "Ally" - total 4 bots. Adding 2 bits (2^2=4). And define every Ally with team tag.
4 bots allow us to address 128 different things.
124234.jpg
124234.jpg (125.85 KiB) Viewed 1370 times

Maximal number of allies that we can define with teamtag is 32 plus "Myself" = 33 bots.
Math for ally team: 32*33 = 1056. Its enough to write simple programs!

Remember, we can use enemies + bases + resources. Its quite enough for us!
EkT1pJSLyYc.jpg
EkT1pJSLyYc.jpg (85.52 KiB) Viewed 1370 times

sollniss
Automaton
Automaton
Posts: 178

Re: CPU project. Making computer inside the collective mind

Post#3 » 01 Aug 2018, 00:32

And then what?

Show me how to add.

MGBlitz81
Automaton
Automaton
Posts: 135

Re: CPU project. Making computer inside the collective mind

Post#4 » 01 Aug 2018, 15:09

Sorry this isn't the game for that...

If you want to make a computer, try searching the Google play store for survivalcraft 2. The logic in that game is more thorough and has many uses. Besides, the output is bots? What are they going to do when trying to figure out 2+2? Start dancing?

pier4r
Skynet
Skynet
Posts: 3390

Re: CPU project. Making computer inside the collective mind

Post#5 » 01 Aug 2018, 15:40

While I see the effort, as sandbox challenge, possibly challenging, for me it is already enough to have the multiplayer challenge. Because simulating a CPU doesn't really help in battle.

Besides, if an AI really become fat and uses too much computational time, then I would also start to lean to a sort of indicator. Not a penalty, rather some sort of execution time or node evaluated.

So one can say "ok this AI has a score of X but its last execution cost in a battle was: X nodes"
http://www.reddit.com/r/Gladiabots/wiki/players/pier4r_nvidia_shield_k1 -> Gladiabots CHAT, stats, insights and more ;

ElvenMonk
Neural Network
Neural Network
Posts: 238

Re: CPU project. Making computer inside the collective mind

Post#6 » 02 Aug 2018, 11:23

@sollniss: "if onject1 is tagged 00000 00010 (EDCBA 54321) and object 2 is tagged 00000 00010 set tags on object3 to 00000 00100" etc. Having unlimited AI size with limited memory there is no problem in implementing all ariphmetic operations in a bruteforce manner.

Turing machine though doesn't have notion of addresses or registers. And if I was to choose what to implement in Gladiabots among Turing Maching, ALU or genetic algorithm, I'd rather implement latter.

User avatar
DjSapsan
Script
Script
Posts: 48

Re: CPU project. Making computer inside the collective mind

Post#7 » 06 Aug 2018, 19:19

Adding is most important operation in the computing. Using addition we can implement any operation. We have two ways to do this:
1) Check every single condition
2) Implement binary adder with logic gates.
3) Secret


How its work?

1) Every single condition looks like follow:
if 'A' == 1 and 'B' == 1 then set 'C' to 2
...
if 'A' == 10 and 'B' == 20 then set 'C' to 30
Simplest and hardest way for adding numbers. Dont need to think but a lot of work. If A and B has 5 bits values then we need 1024 cases (and x3 more nodes).

2) Second way can be smaller but complicated.
Regular adders in the CPUs works with following logic. Let's look at single bit adding. Rules same as we learned in school. But only two symbols - 0 and 1 instead of ten. Simplest 1-bit adder with 2 inputs and 2 outputs has 4 cases:

Code: Select all

0 + 0 = 0 (0 carry out)
0 + 1 = 1 (0 carry out)
1 + 0 = 1 (0 carry out)
1 + 1 = 0 (1 carry out)

Maybe you know, this table looks like XOR-gate. Yea, adder working with XOR gates! In case 1+1 we have carry out (overflowing), for this we need AND gate. Pretty simple. For full-working adder we need move overflowed bit to the next part. So we need add this bit to sum of the next part of adder. For this we put one more XOR gate. And dont need another AND gate here because impossible to have such case.
Wikipedia

BUT WE HAVE A LIMITATION!
We can't make gates with two inputs in game. So we should implement adder in another way. How?
Lets go.
In first evolve, opponent bots will be as input.First bot is number A, second bot is B and third is C. C=A+B. Our main bot will calculate sum of A and B and set answer with tags to third bot C.
You can noticed that we have certain condition for carrying bits. In case A.bit = 1 and B.bit = 1 carrying occured. And ripple moving to the next bits until next bit is = 0. More clearly on picture:
addadadadad.png
addadadadad.png (5.98 KiB) Viewed 1265 times


So for each bit we put conditions from current bit to the most significant bit. F.e. if adding number 1 to the least significant bit then we have following cases: no carry, carry to second bit, carry to third bit, ... carry to last bit. Nodes with conditions for least significant bit:
comditios.jpg
comditios.jpg (22.32 KiB) Viewed 1265 times

Full view:
bitttt.jpg
bitttt.jpg (196.15 KiB) Viewed 1265 times


Next we make similar logic to every bit. And this logic will work in order from least to most significant bit. For correct order we should use temporary tag (on resource). Temp tag disabling next branches if certain branch was picked.
In final i created block of nodes for watching results and editing inputs. Two rows for number A and number B. Connected node mean 1, disconnected node mean 0:
Image
Well, we have working adder in gladiabots!

Lets look pictures. Bot-tagger:
tagger.jpg
tagger.jpg (76.88 KiB) Viewed 1264 times


Bot-calculator:
adder.jpg
adder.jpg (173.46 KiB) Viewed 1265 times


Final test:
You can convert tags to numbers here
A = 2,3 (12 in decimal)
B = 3,4 (6 in decimal)
C = 1,4 (18 in decimal)

Image
Image


Another example:
A = 2,3,4,5 (15 in decimal)
B = 4 (2 in decimal)
C = 1,5 (17 in decimal)

Image

pier4r
Skynet
Skynet
Posts: 3390

Re: CPU project. Making computer inside the collective mind

Post#8 » 06 Aug 2018, 20:15

nice exploration.
http://www.reddit.com/r/Gladiabots/wiki/players/pier4r_nvidia_shield_k1 -> Gladiabots CHAT, stats, insights and more ;

ElvenMonk
Neural Network
Neural Network
Posts: 238

Re: CPU project. Making computer inside the collective mind

Post#9 » 06 Aug 2018, 20:52

When sharing AI will be released, we will be able to use your patented sub-AIs to do math operations and other fancy stuff, without revealing implementation details.

User avatar
DjSapsan
Script
Script
Posts: 48

Re: CPU project. Making computer inside the collective mind

Post#10 » 07 Aug 2018, 10:25

ElvenMonk wrote:When sharing AI will be released, we will be able to use your patented sub-AIs to do math operations and other fancy stuff, without revealing implementation details.

Ill be happy with sharing AI for free.
But ur suggestion is amazing, this will be cool to share subtrees without revealing implementation. Something like .dll or .cpp

Return to “General Discussions”

Who is online

Users browsing this forum: No registered users and 1 guest