cangiuli / hanabi

2 stars 1 forks source link

try to give a clue if you cannot discard #5

Open fpvandoorn opened 8 years ago

fpvandoorn commented 8 years ago

Also, if the newest clued card is definitely not playable, then it is treated as a safe hint.

Now players will almost never bomb if they cannot discard. If they cannot discard ...


Note: I noticed one thing in a game which confused me for a while: a play hint can be given by a player, but which is interpreted as a safe hint by the next player (if they clue rank including the oldest unclued card).

cangiuli commented 8 years ago

a play hint can be given by a player, but which is interpreted as a safe hint by the next player

This is definitely a bug. givePlayHint should also require that the hint is not a save hint, preferably by using a modified version of isSaveClue. (I can take a crack at that some time.)

Otherwise they will play their newest card (which is - I think - slightly better than playing a random card)

That seems reasonable.

cangiuli commented 8 years ago

I moved some code around, and defined a type SSet (yeah, I know) for sets of suits, and RSet for sets of ranks. I think these will make some of your code nicer. Soon I will make the clued functions use these instead of lists. (Of course, lists are still needed for ordered information.) But unfortunately these changes will break your new code...

fpvandoorn commented 8 years ago

But unfortunately these changes will break your new code...

That's alright. Feel free to break as much as you need :-)

cangiuli commented 8 years ago

Alright, take a look. I deleted cluedNotRank and cluedNotSuit, and replaced them with possibleRanks and a new version of possibleSuits. Both return sets instead of lists, and they look cleaner. I'm not sure that cluedRank and cluedSuit are still necessary, but I didn't delete them just in case.

In your pull request, I think the only affected function is isNotPlayable, which should get simpler.

cangiuli commented 8 years ago

I should point out that the difference between cluedSuit and possibleSuits is that the latter considers both positive and negative color hints, while the former only considers positive color hints.

fpvandoorn commented 8 years ago

I updated my commit.

In set-list.sml I didn't find an analogue of List.all. To check "for all x in A we have P x" is there a better way than List.all P (ListSet.toList A)?

fpvandoorn commented 8 years ago

Also, is there a way to print out only certain turns in the log, depending on whether some function was called during that turn? That would be helpful for debugging. Imperatively, I would add something like globalVar := true to the function, and let the trace be fn _ => if globalVar then (* print *); globalVar := false else (). Is there a nice way to do this is SML? I suppose we could make play output something of type action * bool, but that is a bit messy.

I'm now working on a better action when you have nothing else to do, but that doesn't happen very often :-)

fpvandoorn commented 8 years ago

Added one more commit.

cangiuli commented 8 years ago

To check "for all x in A we have P x" is there a better way than List.all P (ListSet.toList A)?

This is probably the right way to do it (although it's SSet.toList). If it comes up enough times we can add such a function to UtilHanabi. Note that toList is "free", since an SSet is just a sorted list anyway.

Also, is there a way to print out only certain turns in the log, depending on whether some function was called during that turn? That would be helpful for debugging.

I should factor out some of the printing code so that the players have access to the printing functions (although of course it wouldn't include their own cards). Then you could just print the relevant turns from inside the player logic. A temporary solution is to print "LOOK HERE" in the player whenever the condition comes up, and just search the full game log for it.

fpvandoorn commented 8 years ago

Note that toList is "free"

good point

Then you could just print the relevant turns from inside the player logic.

Oh, that would be nice. It doesn't matter what the current player has to judge whether the move is the correct one.

A temporary solution is to print "LOOK HERE"

Yes, I've indeed been doing that for now.

fpvandoorn commented 8 years ago

I added all my commits to this PR.

fpvandoorn commented 8 years ago

I played around a bit more. I made the following changes:

cangiuli commented 7 years ago

Can't we reconstruct turn number pretty straightforwardly from the rest of the game state? And are we using it anywhere?

fpvandoorn commented 7 years ago

We can reconstruct the turn number from the length of the log. It is currently only used when printing the game state. We can remove it if you want.

cangiuli commented 7 years ago

Even the players can reconstruct it, from the size of the deck / turns left, and number of players. That would be more efficient than checking the length of the log.

fpvandoorn commented 7 years ago

Even the players can reconstruct it, from the size of the deck / turns left, and number of players. That would be more efficient than checking the length of the log.

You mean by counting how much clues have been given? That works most of the time, but not always, since it's possible to play a 5 without getting a clue back.