I’d like to see the input as an array of strings. That makes it more ugly to use 52 cards for input. But, as I understand it, the game rules work for smaller sets of cards equally well and that might nudge future contributors to stay with smaller amounts of cards in proposed tests.
With the current implementation, yes.
If we want to remove this particular feature, nothing changes at the algorithmic level because we still carry the number of cards and tricks with us if we reach the end of the game.
Yes, the values are precisely defined.
I considered the number of cards and tricks starting from the first round.
Other implementations added or considered only the duration of the loop, i.e. how many cards and tricks have passed since we played the same round.
Personally, I would leave it like this.
In my opinion, if we want to give the exercise a MEDIUM difficulty, we should use arrays and that’s the end of it.
Then, anyone who wants to implement the exercise on their own track will do what they think is best for their users.
I confirm that the algorithm must work with any deck length.
Note, the difficulty is set at the track level and is language dependent. The exact difficulty level isn’t relevant here.
Do the tests expect a deck with 52 cards? Or is this irrelevant for the result?
EDIT: I believe many test cases are from famous games, right? They are marked as, for instance, “Kleber 1999” or “Nessler 2012”.
Are we following enough of the rules of the games for those results to still be valid? I’m asking because it was implied that the rules might be different in the exercise.
The tests of the famous matches are all 52 cards.
The tests to develop the step-by-step algorithm are of varying numbers of cards.
The smallest for now is with 2 cards, the largest is about 200 or more
There are actually only a few rules to follow.
The only problem is that nowhere can I find written the rules for how the various cases where players finish their decks should be considered:
- with a number card, while they are not paying
- with a number card, while they are paying
- with a number card, while they have finished paying
- with a payment card
The tests were written considering the rules I also used to play with (equal to the professor’s python code reported earlier in the topic):
- The players have not yet played a payment card and one of them finishes their deck.
The game does not end as soon as the player’s deck runs out but on the next turn, after the opponent has placed
another card, and the player cannot respond. - The simplest case. If the player runs out of cards while paying (without answering with a payout card), then the game ends. There is no doubt in this case.
- This is the doubtful case. If a player pays the penalty perfectly with only number cards by finishing their deck, at the moment the game ends and a new round with zero cards in the player’s deck is not made.
- The player’s deck ends with a payment card. The turn passes to the opponent.
If the opponent uses only number cards, the player takes the stack.
If the opponent uses a payment card, the player loses by falling back to case 2.
If the opponent has no cards, the player wins.
If the opponent runs out of cards, the opponent falls in case 2 or 3 or 4.
That said, I know these rules might be a little confusing, but for now we have implemented them.
It’s much, much easier to change things before any track implemented anything
Nothing is actually merged yet so now is the best time to change things to make them as good as possible.
I think that in all of those situations the player gets all the cards in the deck, right?
In the two first cases, they get because the opponent can’t play;
In the third, they get because if the opponent pays the penalty with only numbers, then this is a trick and all cards in the pile go to the player. As the opponent has no cards left, the player now has all the cards, after collecting from the pile.
In the fourth, if the player uses a payment card:
1- if the opponent uses only number cards, the player collects the pile and in no moment any player had all the cards in the deck, so no one won;
2- if the opponent uses a payment card, the player can’t respond (because they have no cards) and so the opponent collects the pile and now has all the cards in the deck, winning the game;
3- if the opponent has no cards, they can’t pay and so the player collects the pile (which must have all the cards of the deck since both players don’t have any card remaining). So, the player now has all the cards of the deck, winning the game;
4- if the opponent runs out of cards, they fall in one of the other cases.
So, it seems that the ending (winning) condition is indeed collecting all the cards of the deck - which means there’s no cards in the pile and also no cards with the opponent.
What do you think?
The more I think about it, the more I’m convinced this is the best route. It’s simple. It’s clear. It is pretty close to what we already have.
Totally agree
I think simplifying is fine.
My only fear is that by writing only this, we leave room for interpretation.
I would feel more comfortable knowing all the cases written in detail.
On second thought, however, since this is an exercise, a person finds more satisfaction in finding edge cases and solving them on their own (with the help of the guide tests).
You’ve convinced me. If everyone agrees, you can simplify it however you like.
I think we all understand the rules more or less at this point. ![]()
The tests that will be developed should remove interpretation ambiguity. As a practice exercise, it leaves room for the student to explore, in a concept exercise the append file will likely address anything that needs to be interpreted specifically for that track’s concepts.
PR merged!
Thank you all for your support!
You have been great and extremely helpful.
I can’t wait to see which tracks it will be implemented on and the solutions from various users. ![]()
Welcome to “Insiders” as well!
And especially thank you for being patient through the most coordinated first contribution I have seen in a long time!
All beginner’s luck. ![]()
It’s always nice to see people who care about what they do, even in their own small way.
The community you have created is simply fantastic. ![]()
Congrats on adding the new exercise. Sorry I couldn’t contribute more to the discussion last week, but I’ll work on adding the exercise to Arturo, CoffeeScript, LFE, Pyret, Racket, and Vim Script in the upcoming weeks if folks don’t get to it first.
Can someone reopen the issue to add the icon to this exercise?
Thank you.