Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Tue Jul 14, 2009 8:25 am   

1384.61535644531 < 1384 according to %int() ??
 
So, been working on a script that would determine in what order it was best to buy things in order to maximize income and minimize waste of money
With the help of MattLofton, Charneus and Taz I pretty much have gotten the code working how I want it.

I wound up needing to do it in Excel to be able to even confirm that it was working correctly.

One thing is that there are the rare occasions where it will say that a higher # is lower.
For example

Code:
Excel                  zMud   
Estate      1366.15   Estate      1,366.15
Estate      1370.77   Estate      1,370.77
NightClub   1375.00   NightClub   1,375.00 <--- Low
Estate      1375.38   Estate      1,375.38 <--- High
Estate      1380.00   Estate      1,380.00
Casino      1384.00   Estate      1,384.62 <--- High
Estate      1384.62   Casino      1,384.00 <--- Low
Estate      1389.23   Estate      1,389.23


Here's the code that i put together. It's not pretty but it works (with the exception of the high/low hiccup)
There's no pattern to it with it being every X amount of hits before it happens. But it DOES happen as far as I can tell just with the Estate. Like no NightClub/Casino or any other combo. It always is the Estate/something
But even then there's no real pattern because as I also showed above, there's a nightclub/estate that worked fine and if it had the error all the time it should have been reversed.
I'm not sure if it's something in the code that i mixed up, or just one of those hiccups that zmud rarely has.
Wouldn't be shocked if it's related to the #if's after the #ECHO @SRPurchase - @SRLowestTemp
I've never been very good at getting #if's to nest correctly. Always seem to screw them up.

Code:
#ALIAS SRReSet {
 #VARIABLE SRMansionCost {11795}
 #VARIABLE SRCasinoCost {20760}
 #VARIABLE SRIslandCost {2925}
 #VARIABLE SREstateCost {87000}
 #VARIABLE SRNightCCost {2750}
 #MATH SRNightCTemp @SRNightCCost/@SRNightCGain
 #MATH SRMansionTemp @SRMansionCost/@SRMansionGain
 #MATH SREstateTemp @SREstateCost/@SREstateGain
 #MATH SRCasinoTemp @SRCasinoCost/@SRCasinoGain
 #MATH SRIslandTemp @SRIslandCost/@SRIslandGain
}
#ALIAS SRRun {
 #LOOP 5000 {
   #MATH SRNightCTemp @SRNightCCost/@SRNightCGain
   #MATH SRMansionTemp @SRMansionCost/@SRMansionGain
   #MATH SREstateTemp @SREstateCost/@SREstateGain
   #MATH SRCasinoTemp @SRCasinoCost/@SRCasinoGain
   #MATH SRIslandTemp @SRIslandCost/@SRIslandGain
   #IF (%int( @SRNightCTemp) <= %int( @SRMansionTemp)) {
     #VARIABLE SRPurchase "NightClub"
     #VARIABLE SRLowestTemp @SRNightCTemp
   } {
     #VARIABLE SRPurchase "Mansion"
     #VARIABLE SRLowestTemp @SRMansionTemp
   }
   #IF (%int( @SRLowestTemp) <= %int( @SREstateTemp)) {
     #VARIABLE SRPurchase @SRPurchase
     #VARIABLE SRLowestTemp @SRLowestTemp
   } {
     #VARIABLE SRPurchase "Estate"
     #VARIABLE SRLowestTemp @SREstateTemp
   }
   #IF (%int( @SRLowestTemp) <= %int( @SRCasinoTemp)) {
     #VARIABLE SRPurchase @SRPurchase
     #VARIABLE SRLowestTemp @SRLowestTemp
   } {
     #VARIABLE SRPurchase Casino
     #VARIABLE SRLowestTemp @SRCasinoTemp
   }
   #IF (%int( @SRLowestTemp) <= %int( @SRIslandTemp)) {
     #VARIABLE SRPurchase @SRPurchase
     #VARIABLE SRLowestTemp @SRLowestTemp
   } {
     #VARIABLE SRPurchase "Island"
     #VARIABLE SRLowestTemp @SRIslandTemp
   }
   #ECHO @SRPurchase - @SRLowestTemp
   #IF (@SRPurchase = "NightClub") {#ADD SRNightCCost 100}
   #IF (@SRPurchase = "Mansion") {#ADD SRMansionCost 350}
   #IF (@SRPurchase = "Estate") {#ADD SREstateCost 300}
   #IF (@SRPurchase = "Casino") {#ADD SRCasinoCost 120}
   #IF (@SRPurchase = "Island") {#ADD SRIslandCost 25}
 }
}
#VAR SRMansionCost {11795} {_nodef}
#VAR SRMansionGain {7.0} {_nodef}
#VAR SRMansionTemp {1685} {_nodef}
#VAR SRCasinoCost {20760} {_nodef}
#VAR SRCasinoGain {15.0} {_nodef}
#VAR SRCasinoTemp {1384} {_nodef}
#VAR SRIslandCost {2925} {_nodef}
#VAR SRIslandGain {2.0} {_nodef}
#VAR SRIslandTemp {1462.5} {_nodef}
#VAR SRLowestTemp {12212.5} {_nodef}
#VAR SREstateCost {87000} {_nodef}
#VAR SREstateGain {65.0} {_nodef}
#VAR SREstateTemp {1338.46154785156} {_nodef}
#VAR SRNightCCost {2750} {_nodef}
#VAR SRNightCGain {2.0} {_nodef}
#VAR SRNightCTemp {1375} {_nodef}
#VAR SRPurchase {Island}


If anyone could point me in the right direction thank you Very Happy
If it's just something i'll have to live with then, aw well Crying or Very sad

What I like about this code more than the excel version is because in excel i did the computations for the items 1,000 times each. I lined them all up so that I had all 5,000 rows in one line. sorted them by the calc that I was using.

Then ran the zMud version and logged that.
In the excel version the 5,000th item listed was
Mansion 51635.00

In zMud the 5,000th item was
Island 12212.50

I don't even want to guess how many more thousands of lines i would have needed in excel to get those results.
*huggles zmud for saving money*
_________________
http://www.Aardwolf.com
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Tue Jul 14, 2009 2:08 pm   
 
Even though I had mentioned to use %int earlier, try using Mattlofton's suggestion of %float instead, considering you are working with decimal numbers. I should have realized that earlier, but didn't. :P

Charneus
Reply with quote
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Tue Jul 14, 2009 3:21 pm   
 
he'd told me previously: Use .0 or %float(#) to use floating-point math.
So i've been using the .0 method
Code:
#VAR SREstateCost {87000} {_nodef}
#VAR SREstateGain {65.0} {_nodef}
#VAR SREstateTemp {1338.46154785156} {_nodef}

so that's working.
My problem now is that sometimes it thinks a decimal is lower than the whole #

Unless there's another part that i'm not understanding.
_________________
http://www.Aardwolf.com
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Tue Jul 14, 2009 3:37 pm   
 
What I'm saying is change:

Code:
#IF (%int( @SRNightCTemp) <= %int( @SRMansionTemp))

into:
Code:
#IF (%float(@SRNightCTemp)<= %float(@SRMansionTemp))


That should solve the problem.

Charneus
Reply with quote
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Tue Jul 14, 2009 4:10 pm   
 
oh.
I'll check as soon as i can.
work beckons.
They never understand the zmud is far more important!
_________________
http://www.Aardwolf.com
Reply with quote
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Tue Jul 14, 2009 6:01 pm   
 
Perfect Char!!! Mr. Green Mr. Green Mr. Green Mr. Green

Now if only I can get this to correctly use large #'s in the billions...really wanted to just plug in how much $ i had and spit out what I could buy...aw well.
_________________
http://www.Aardwolf.com
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Tue Jul 14, 2009 9:16 pm   
 
That's a problem with the max size of a signed integer, which is 2,147,483,648. CMUD raises the limit to 9,223,372,036,854,775,808, which is much better. Beyond that, there's this thread that adds limited support for larger numbers, or you could write something yourself that would break apart large numbers into multiple items, or store them as a string instead.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Tue Jul 14, 2009 11:57 pm   
 
Shocked Holy ...
LOVE IT!!!!
Wish i'd known about that sooner!! Would have saved me from going to bed after 3AM for 3 days straight.

Since this is my 1st touch of #SCRIPT i have a question:
I don't seem to find the scripts in the settings when i do a search for like islessthan
I know I can type #script and get it listed, but where exactly is it?
Will i have to input all the #SCRIPTs if i shut down and restart zMud?
_________________
http://www.Aardwolf.com
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Wed Jul 15, 2009 7:19 am   
 
I suspect you'll have to re-input your #scripts, yes. In this case, zMUD is using the Windows Script Host to communicate with, I think, VBScript, and when zMUD closes the link stops.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net