Problem of mathematical logic

I am here to present to you a mathematical problem, to which my lack of knowledge in this field does not allow me to find a solution.
In most cases everything goes as I wish.

Except when:

Default: “Max N Solid = 5”
tableau.jpg
My final result (Rst NS 4) must not be > Max N Solid

Thank you in advance for your answers

Are those numbers integers or float? Which ones are inputs which results?
If all inputs and outputs are integer, and that is every state you can get, just make simple graph, that checks for NSP and NS inputs, then gives result.
For eg:
in sequence check:
if nsp=4 and ns=2 then index = 0
if nsp=3 and ns=3 then index = 1
if nsp=4 and ns=4 then index = 2

put in 3 arrays all 3 results:
Rst NS2 = 3 , 2, 1]
Rst NS3 = 2 , 3, 4]
Rst NS4 = 6 , 6, 8]

then get results array[index] for each result

but i am assuming what is input and what is output also that all are integers.

hello Nawrot,

Variables with the name “Rst” are all calculation results
The variables are of the integer type
The entries are:

N Solide = Amount of food contained by a plant.
NS Solide = Quantity worn by the character.
MAX N Solide = Maximum quantity that can be worn by the character.

I think that the problem is in my resonance, that it is the logic of calculation which is in question. If I put the results in an index the problem remains, the equation is bad.
But can you please tell me how to relate an array to check the inputs and give the result?

Something like this:

Thank you very much, this is a great example of how to read and write on a board, I really missed it. :slight_smile:

Only by doing this I eliminate the possibilities listed, but I don’t know where the error came from …

Why is the result of “NS” greater than the “MAX N. Solid” only on these three values, while it remains below or is equal on all the others?

An idea ?

Sorry i could not debug your code. So i have no idea.

Here is the link to a . zip file
tell me when you downloaded it
He is so sure!

Can you write it in an equation?

Thank you for answering my call :wink:

No I could not write it in equation, I do not have the knowledge for that.

But…

After having tried I modified the termination of my assembly and added a calculation between the «Rst NS 4» the Max n. Solid, so that if the RST NS 4 is larger than The portable maximum this one is subtracted from the Rst NS4.

](filedata/fetch?id=1811497&d=1600094119)

although I unfortunately do not understand where he came from. I will look again, to understand.

Thank you Nawrot for your help I learned a lot from your example.

Agreed here with Clockwork.

You really should have equation before you make some calculations like this. For now you probably can manage this by trial and error, but later fixing anything in this game will be nightmare.

Or maybe you could write it down as rules…

Not knowing how to make an equaton, I am afraid that the result will be slightly distorted :wink:
Cepandantke will try to put this in writing. But really I don’t see how it would be clearer than a visual graph as it is presented here … for me anyway :confused:

I did my best …

x = N solide

y = NS Porté

5 = Max N solide

Rst = Result

x – 5 = Reste NS

if : (y >= 5)

Then : (Widget STOP)

Else : x – 5 = Rst 1

if : (Rst 1 < 0)

Then : Rst 2 = (Rst1 * -1) ; Rst 3 = (5 – Rst 2) ; Rst4 = (x – Rst 3) ; Rst 5 = (Rst 3 + y)

Else : Rst 5 = y ; Rst 6 = (5 – y) ; Rst 7 = (y + Rst 6) ; y = Rst 7 ; x = (Reste NS + Rst 5)

if : (Rst 5 > 5)

Then : Rst 8 = (Rst 5 – 5) ; Rst 9 = (Rst 5 – Rst 8) ; x = (Rst 4 + Rst 8)

Else : y = Rst 5 ; x = Rst 4

Sorry buddy, this is making it worse :frowning:

What are you trying to do?

I think you have:

  1. Max amount someone can carry

  2. Amount currently carried by someone

  3. Amount a plant needs / has

But what is happening? People are getting food, carrying it and giving it to plants?

The bottom line is: who created this and more importantly … how?

I think I just answered the question

The character (an insect) comes to collect its food (N. Solide) on the plant which produces it. He has, as you understand it, a maximum amount of food that he can carry (Max N solide), it is taken into account what he already carries (NS Porté), because since the food is random we cannot find not necessarily the (Max N. Solide).

I set up a random system of the number of food available on the plant:

](filedata/fetch?id=1812402&d=1600324235)

The principle after that is that the number of food and subtracted from the pante and added to the character (NS Porté), but must not exceed the “max N solide” amount. If it is exceeded the difference is left on the plant.

I suspect that the code can be clearer and above all simpler, but I did that with my little beginner means.

If there is a possibility of simplifying, I am interested !

Maybe:

What the plant has: N_Solide
What he can carry: Max_N_Solide
What he already carries: NS_Porte

temp ← N_Solide + NS_Porte
if temp > Max_N_Solide NS_Porte ← Max_N_Solide
N_Solide ← temp - Max_N_Solide
else: NS_Porte ← temp
N_Solide ← 0

](filedata/fetch?id=1812414&d=1600328603)

Such as, it is not functional, but the basic calculation is simpler, I will try to make it operational :slight_smile:

Ok, I get it. Insects taking food from plants. How many insects? Just one, the player?

At first only the player.