kakoeimon / GodotMation

An implementation of machinations framework in Godot Engine
MIT License
2 stars 2 forks source link

Gates are not completly implemented. #1

Open kakoeimon opened 6 years ago

kakoeimon commented 6 years ago

Gates are not completly implemented. For example in the texts (see links in readme) is stated that the resource value of a connection is like a probability. This means that if we have a gate with two output resource connections one with label 1 and another with label 2. The one with label one will have achance of 1/3 to be triggered and the other with 2 a chance of 2/3. This is the label of the resource connection divided by the sum of the labels of all output resource connections. In Machinations found in the site of Joris Dormans (see readme) a similar gate will redistribute the input resources to the output resource connections. This means that if a gate similar with the one discribed above, have an input of 3, will redistribute 1 resource for the first output resource connection and 2 for the other. In other words it is going to redistribute input resources along the output resource connections until will have no more resources. This is the way the gate is implemented in GodotMation see inside the trigger function of the gate.gd : https://github.com/kakoeimon/GodotMation/blob/master/addons/kakoeimon.godotmation/nodes/gate.gd the lines : while output_resources[output_i].trigger(): output_resources[output_i].update_flow() output_resources[output_i].used = false output_i += 1 if output_i > output_resources.size()-1: output_i = 0 I found this kind of redistribution of the resource that pass through a gate more valuable from the one discribed in the texts and I dicided to implement it this way.

The reason is that we can have probability by using percentages. This means that if the output resource connections have a label of 10% and 70% this means that the probaiblity to redistribute the resources to the one with 10% is 10% and etc plus we have a chance to loose resources if the output from the random in gate will point higher from the sum of the probabilities. For example 82%.

Those are the only implementetions of the gate right now. But in the texts, you can have a condition label in the output resource connection. For example >1 or ==2 and even a else, but in the Machination software the probability just cicles the output resource connections like the label was 1 for all the output resource connections. For this reason and because the text never realy made it clear what we have to check for the coditions I haven't implemented it. One way to implement it is to check how much input resources are comming inside the gate and then check the coditions to dicide which output resource connection to use. This is what I am planning to add but if anybody have a different idea please post here.

The other which I haven't implemented is the random gate. I haven't implemented this cause I wanted first to implement the so called deterministic gate ( the one I was talking above).

Please enter the discusion, let's solve this problem to complete the project.