Jump to content

help with linked calculations.. recursion?


Recommended Posts

Can anybody help me with this PHP problem? I have a sort of online game where there are calculations that have circular references(?) eg:

 

A = (B*45%) + (C*45%) + (A*10%)

 

Sort of like Google's PageRank system where all the page ranks are dependant on each other and itself. And I'm thinking I might need a recursive function or something like that. Help?

 

Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/208261-help-with-linked-calculations-recursion/
Share on other sites

You have to provide a little more logic. Where does A come from? What determines when to run a recursive function? If you are going to do recursion, at what point will the recursion stop? The calculation you have provided doesn't show a need for a recursive function, and based on your description, it's hard to know what you are after.

Okay, sorry for being unclear. Here's how it has to work:

 

literacy = (morale*15%)

morale = (crime rate*10%)

crime rate = (literacy*10%)

 

To summarise: literacy is affected by morale, which is affected by crime rate, which is affected by literacy. All are percentages.

 

Or is this an impossible task? Am I missing something?

 

 

This doesn't make any sense. look

 

literacy = morale*15%  = (crime rate*10%)*15% = crime rate * 1.5%

 

but

 

crime rate = literacy*10%

 

so literacy is lower than crime rate but it's higher than crime rate. ???

 

 

crime rate = crime rate * 0.15%

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.