Thursday, November 3, 2022

Kitty Solver

 This is a na├»ve implementation of an optimizer for a card game called Kitty. The game is played with 9 cards and a player has to come up with three sets of three cards from the hand they are dealt. Each set has a priority order/score and there can be multiple ways to arrange the cards dealt in the hand to these three sets. The best arrangement to obtain these sets can sometimes be a little time-consuming for an inexperienced player, like myself. Hence, this program. It is probably of little use in the real world but it was a good mental exercise to implement into a functioning program.

Here's how it works, briefly:

- Creates a list of all possible arrangements/orderings of the cards in the given hand (that comes to be 9! i.e. 362,880)

- Not all of these combinations are unique as far as the game is concerned

- Each hand contains 3 sets of cards, each set consisting of 3 cards

- The ordering of the cards in a set doesn't matter, so each set, when created automatically sorts the given cards in descending order

- Scores each set of each hand of the arrangements according to the rules of the game, the score is a vector of 5 different possible sequences: `[trial_score, falash_score, run_score, jute_score, badhi_score]`. 

- Care should be taken while calculating each member of this vector such that the priority order within the sequence in question is respected, for e.g. while calculating the run_score for a set, the score for a A-K-Q run must be higher than an A-2-3 run; calculating the jute_score for a set, the score for a 2-2-A should be lower than 3-3-5, and so on.

- A scalar score is also calculated from this score vector wherein the elements of the vector are added with suitable weights such that the priority order of the different sequences (run vs. trial vs jute, etc.) are respected

- To get the highest scoring arrangement, the list of all possible arrangements (hands) are sorted by the simple sum of the scalar scores of all three sets of each hand

- For the best scoring hand, the highest scoring sets are placed toward the front, which is the final result

Here are some screenshots:







GitHub repo

Note: .NET Framework 4.8

Thursday, September 8, 2022

MeroShare Monitor

This is a simple console program written in Go, that auto applies to any open IPOs via your Meroshare account.

It requires details about your MeroShare account, such as your BOID, Password, DPID, etc., encrypts the most sensitive fields and stores them in a config file along with the corresponding key file. You can have multiple configs(profiles) that you can add via the --add switch. If no switch is provided, it parses all the available configs in the program directory and applies for each of them (if no config exists, it behaves as if the switch was provided).

The program also keeps logs of the IPOs applied to in a plaintext file in the same directory.

The initial idea was to automatically add the program to the windows Task Scheduler so that it runs at regular times but I've left that functionality out - it's not much of a hassle since it's a one-time fire and forget kind of thing that anyone should be able to do.

Note that it makes use of the exact same API that the actual MeroShare portal uses (which is quite clean and robust imho). The endpoints, authentication and the expected payloads are quite straightforward and really transparent, and easily readable from any modern web browser's developer tools.

The GitHub repo is available here