Veracity's MMG scripts

Veracity

Developer
Staff member
Over on the MMG Toolbox thread, I introduced the MMG Martingale script I wrote. I figured I should put it over here, rather than in "Scripting Discussion", since it's a real script, not just a proof of concept for the support I added to KoLmafia. I also include an MMG log parsing script I wrote which you may enjoy.

mmg.ash:

You can configure three things at the top of the script:

Code:
// set to true if betting from storage
boolean storage = false;

// if your meat on hand exceeds this amount, closet the excess
int closet_threshold = 1000000;

// maximum loss count you will tolerate
int loss_threshold = 20;

When you invoke the script, you will be prompted for 4 values:

amount - the amount of Meat to bet initially
factor - the amount to multiply the amount by if you lose. Traditional Martingale says 2.0, but increase it if you want to bankrupt yourself faster.
iterations - how many times to run each chain
chain_count - how many chains you want to run at once - from 1 to 5

mmg-log.ash:

This is also configurable:

Code:
// set to true to see bet statistics by player
boolean show_players = false;

// set to true to see bet statistics by date
boolean show_dates = true;

// file names in which to save bet archives
string player_file_name = "bet-archive-players." + my_name() + ".txt";
string date_file_name = "bet-archive-dates." + my_name() + ".txt";

When you run it, you are prompted for whether to load previously saved data or go to the mmg to fetch your two week full bet history (and save the data). It makes an HTML table of every player you played against, showing how many bets you made or took from each one, how many wins, how many losses, net winnings.

Have fun and good luck - unless you are playing against me. ;)

Edit: I have souped up mmg-log.ash. It now generates two HTML tables. The first is, as before, the players you gambled against. The second has one row per day, showing you how you did each day during the last two weeks. Both tables now print numbers with commas separating the thousands and millions - much easier to read!

Edit: More improvements to mmg-log.
- Include player name in saved data files
- Configurable to show players and/or dates, rather than always showing both.

Edit: Moved functions to print numbers with commas into mmg-utilities.ash. Both mmg.ash and mmg-log.ash import that file.
 

Attachments

  • mmg-utilities.ash
    533 bytes · Views: 1,376
  • mmg.ash
    4.5 KB · Views: 1,066
  • mmg-log.ash
    6.4 KB · Views: 585
Last edited:

Rinn

Developer
And suddenly half the players in the kingdom double their meat while the other half goes bankrupt.
 

Veracity

Developer
Staff member
And suddenly half the players in the kingdom double their meat while the other half goes bankrupt.

Not quite. Don't forget that the game takes its cut from every transaction. Something I've noticed a lot is that a player will make 5 bets for 100,000, say. I'll take 2 of them, winning one, and losing the other. Net result: both the person who offered the bets and I have less meat than we started.

I have seen this again and again and again - and the end-result is that the MMG is acting precisely as intended: it's meat sink, siphoning away meat from the various players, while randomly redistributing (less) meat from the less lucky to the more lucky.

In the long run, the RNG will bankrupt even the richest player by (temporarily) giving their meat to other players - who will, unless they quit while they are ahead, go bankrupt in turn.

I am currently on the "lucky" side of the coin, with Lifetime winnings exceeding 32 million. I've spent all my winning on things I wanted, rebuilt my stash, been wiped out a couple of times, and clawed my way back up again - several times. I should quit now while I am ahead - but it's damned seductive. I look at that 233 million emo roe in the mall, and think "Damn, Gina. I never gonna get that without über-luck. Gotta keep playing the MMG."

(FWIW, I tried my damndest to get an emo row via donation, the single day it was offered. I had no Mr. A in hand, and Paypal, for reasons of its own, decided to turn my donation attempt into a "we'll credit this for you in a couple of days. No worries!" rather than a "OK, your money is in the hands of Asymmetric." Obviously, that wasn't good enough - and I lost out on that familiar because of Paypal screwage. It's my biggest regret of the game. (My only other real regret is that I couldn't be bothered to "waste" 100 turns stargazing to get the Junior LAAAME Merit badge.) Sigh to both.)
 

Heffed

Member
Oh sure Veracity... Drag me back into the MMG... :eek:

I used that MMG mod based on KoLmafia (that was out what, two years ago or something?) quite extensively. I won and lost many a fortune. (I think Holatuwol was quite lucky, I lost a lot of meat to him)

After my fourth disastrous RNG experience I decided I was done with it. Now I'm reading what you've been doing with it and I'm wanting to do it again... :rolleyes:
 

Heffed

Member
Love the scripts! :)

Is there a way to gracefully abandon the MMG script? Last night I was a little over-exuberant with the number of iterations I told it I wanted to run. I decided I didn't want to wait it out as it was very early in the morning and bets were crawling.

I thought it would be nice if I could feed it a command that would tell the script to halt after the next win and give me the totals for the partial run.

This is probably beyond the scope of ASH.

I did use the log script (haven't tried the new version yet) but it was a little overkill just to show me the results of 20 minutes of betting. :eek:
 

Sputnik1

Member
I dont know if im running into the same problem as Heffed, but the script works great for about 10 minutes and then seems to stop without actually ending the script and doesn't print off the typical stats for the run. So im pretty sure that means it's not running through its full iterations per chain or reaching the max losses.
 

Bazaaretw

Member
I dont know if im running into the same problem as Heffed, but the script works great for about 10 minutes and then seems to stop without actually ending the script and doesn't print off the typical stats for the run. So im pretty sure that means it's not running through its full iterations per chain or reaching the max losses.

I am having this same issue of it just stopping, when I retry to run the script is gives me this:

> CURRENT: call scripts\mmg.ash
> QUEUED: call scripts\mmg.ash
 

Veracity

Developer
Staff member
Are you running with chat open? The only way we know what happened with bets you make is when when KoL gives you an event, saying that so-and-so took the bet and you won or lost. We can get the events in one of two ways:

- If you have chat open, KoL reliably gives you a chat message
- If you don't have chat open, those same messages get stuck up as events on main.php

mmg_event polls main.php, letting KoLmafia pick up events. If you have chat open, nothing is found there, but, aside from hitting the server for main.php once a second, no harm is done. If you don't have chat open, that's the only source of bet notification events - and apparently, it's not completely reliable.

I'll look at that issue, but until/unless I figure out what's up, keep chat open.
 

Veracity

Developer
Staff member
I studied the code and concluded that it's likely a problem with race conditions on the data structures we maintain to keep track of bets you've made, bets that have been taken, and bet result events: there are two, if not three, threads that can be accessing this data simultaneously - the script, the user typing things in the Relay Browser at the MMG, and chat.

I stuck in synchronization and tested by starting a series of 5 chains, each at 1037, and they all ran to completion - except the one that lost 10 times in a row and failed to place the 11th bet, because I didn't have the 1 million + in inventory to pay for it.

Nobody said that Science is cheap: testing this cost me over a million Meat. Easy come, easy go. :-/

Revision 7598 of KoLmafia has the synchronization. And I have uploaded improved versions of both mmg.ash and mmg-log.ash.

Have fun!
 

RobtheMagician

New member
Yeah, having the chat window open helps.
Why I'm wasting my key typing helping you cheap SOBs is beyond me.
You want the script better do like I did kick some meat his way so he can experiment.
That's what got us this improvement.
You want to win you have to repay the cosmic karma.
Do good things and good things happen.
20% of my winnings always go to others and I'm still on top.
I do the same in life and life is good to me.
Think about it.
It could change your life.
 

Sputnik1

Member
How about you calm down Rob, as soon as she mentioned that it lost her 1 million I started saving back up to repay her.

Edit:

Sorry Veracity, should've guessed by the avatar
 
Last edited:

Veracity

Developer
Staff member
Let's all calm down. I was not intending to complain - or beg, for that matter.

I believe that "RobtheMagician" is the happy user of my script who has (under a different name) sent me considerable meat to help me experiment with improving things. I really appreciate that. I used that meat - and more of my own - to test the improvements I recently made.

I do need to experiment more, since things are STILL not completely correct, and I don't understand why not. I'll get to it, by and by.

But please - let's all be civil.

Thanks!
 

RobtheMagician

New member
I apologize for using the wrong pronoun, or if my remarks offended anyone.
They were not intended to, and I remain as always in a state of perfect calm.
I believe that a person's dilligence and effort should be appreciated and rewarded.
It is even more deserving of such things when they ask for nothing for it.
I raise my glass to you Veracity, Cheers!

Back to the topic at hand...
I've seen wait counts in some other scripts. I wonder if something similar might be effective here.

Now my real question is...
Would it be in poor taste to use my winnings to by that tasteful gift summoning...
Then use it to send all the people who gave me over a million a mug that says, "I gave (insert user name here) over 1 million meat and all I got was this stupid mug"?
or maybe 10 million would be a better number, would be a lot fewer to give away.
I thought it might be nice. You know something for the display case.
 

Veracity

Developer
Staff member
I have determined that this is a KoL bug, unfortunately. I ran a series of 5 chains of 5 bets each. It hung after resolving 4 chains. Visiting the MMG in the Relay Browser showed no bet outstanding. So what happened?

- In chat, I received 29 notifications: 20 wins and 9 losses.
- My bet log shows 21 wins and 9 losses.

The chat notifications are not in the same order as the bet log (no big deal), but the missing notification is a big deal.

For the record, here is the key section of chat notifications:

lorialmighty took your 9,605 Meat bet, and you won, earning you 19,190 Meat.
BlazingHeart took your 1,037 Meat bet, and you won, earning you 2,071 Meat.
BlazingHeart took your 1,037 Meat bet, and you lost. Better luck next time.
BlazingHeart took your 1,037 Meat bet, and you lost. Better luck next time.
BlazingHeart took your 2,178 Meat bet, and you won, earning you 4,351 Meat.
TheRope took your 1,037 Meat bet, and you won, earning you 2,071 Meat.
BlazingHeart took your 2,178 Meat bet, and you won, earning you 4,351 Meat.
BlazingHeart took your 1,037 Meat bet, and you won, earning you 2,071 Meat.
nincompoop took your 1,037 Meat bet, and you lost. Better luck next time.

and the corresponding section from the bet log (massaged into chat format):

lorialmighty took your 9,605 Meat bet, and you won, earning you 19,190 Meat.
BlazingHeart took your 1,037 Meat bet, and you lost. Better luck next time.
BlazingHeart took your 1,037 Meat bet, and you won, earning you 2,071 Meat.
BlazingHeart took your 1,037 Meat bet, and you lost. Better luck next time.
TheRope took your 1,037 Meat bet, and you won, earning you 2,071 Meat.
BlazingHeart took your 2,178 Meat bet, and you won, earning you 4,351 Meat.
BlazingHeart took your 2,178 Meat bet, and you won, earning you 4,351 Meat.
BlazingHeart took your 1,037 Meat bet, and you won, earning you 2,071 Meat.
BlazingHeart took your 1,037 Meat bet, and you won, earning you 2,071 Meat.
nincompoop took your 1,037 Meat bet, and you lost. Better luck next time.

I have submitted a bug report. We'll see if I get a response.
 

Veracity

Developer
Staff member
I've changed mmg.ash to detect a dropped event: if we wait for 30 seconds (at one second intervals; although we don't use a countdown timer, we've always done that) without an event, we verify that KoL thinks we have bets outstanding. If we think we have outstanding bets, KoL doesn't know about them, and it's been 30 seconds without an event, we stop the script.

I also made the script print all meat amounts with commas separating thousands and millions.
 
Top