TheEvilMonkeyMan Posted July 20, 2010 Share Posted July 20, 2010 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 More sharing options...
sKunKbad Posted July 20, 2010 Share Posted July 20, 2010 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. Link to comment https://forums.phpfreaks.com/topic/208261-help-with-linked-calculations-recursion/#findComment-1088457 Share on other sites More sharing options...
Mchl Posted July 20, 2010 Share Posted July 20, 2010 Just using simple math on what you've written brings: A = ((B*45%) + (C*45%))/90% Something is missing in your explanation Link to comment https://forums.phpfreaks.com/topic/208261-help-with-linked-calculations-recursion/#findComment-1088468 Share on other sites More sharing options...
TheEvilMonkeyMan Posted July 20, 2010 Author Share Posted July 20, 2010 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? Link to comment https://forums.phpfreaks.com/topic/208261-help-with-linked-calculations-recursion/#findComment-1088503 Share on other sites More sharing options...
Mchl Posted July 20, 2010 Share Posted July 20, 2010 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% Link to comment https://forums.phpfreaks.com/topic/208261-help-with-linked-calculations-recursion/#findComment-1088575 Share on other sites More sharing options...
TheEvilMonkeyMan Posted July 22, 2010 Author Share Posted July 22, 2010 Thanks for your replies. I obviously haven't thought this through enough and will take another look at what I'm trying to achieve. Link to comment https://forums.phpfreaks.com/topic/208261-help-with-linked-calculations-recursion/#findComment-1089379 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.