Problem 348 available for testing

Back to General discussions forum

Rodion (admin)     2023-06-01 22:00:14
User avatar

Hi Friends! as most problems I have created recently were buggy :) I suppose we can try different approach. The new problem is available but not listed yet, so that it can be tried by enthusiasts and any necessary amends could be made before it is finalized (it can't be successfully solved in its current state).

Trick-Taking Game

For some time I wished to have some traditional card game exercise (particularly because I don't well understand how they are programmed in the sense of "computer player" algorithm). Here comes simple game with very primitive "computer opponent" (you'll see it can less or more logically defend but it attacks randomly). Several simultaneous games are to be played - and I guess we need to set some threshold of games won to judge the problem as solved. For example 10 of 15 games should be won (draw doesn't mean victory!) or so.

Thus the questions, besides spotting some bugs or description flaws, are:

  • does it make sense to try making machine attack more clever than random (and what logic you suggest) - or it is enough as is?
  • what amount of games to play and threshold value to win you suggest?
  • any other suggestions (deck size? I feel it is better to have odd number of ranks)

Thanks in advance!

P.S. interactive problems now should work with JSON format also, using the Content-Type:application/json header, e.g.:

curl http://codeabbey-games.atwebpages.com/tricks.php \
    -HContent-Type:application/json 
    -d '{"token":"dhXR6/3xWYBMM+5KiXFvbjQw","move":"Y4 W5 X0"}'

{"states":"+X4 >Y2+X1 -Y3>X4","scores":"0:1 0:1 1:0"}
CSFPython     2023-06-03 18:17:18

I have spent some time playing with this and have a number of observations to make.

Draws are fairly common in the game so I think the suggested scoring strategy is unfair, in that a sequence of games with 9 wins and 5 draws would be deemed to be equal to one with 9 wins and 1 draw. I propose a system where we award 1 point for a win, no points for a draw and -1 point for a loss. So a player with 9 wins, 4 draws and 2 losses would have a score of 7.

I initially set up what I assumed to be the same strategy as Rodion, i.e. a sensible defence strategy but a random choice for attack moves. Using the scoring system above and setting the number of games to 19 (the maximum allowed) the average score over a large number of game sequences was very close to 0, indicating that the two strategies were fairly matched. What was also interesting was that the variation in the score for sequences of 19 games varied between -4 and 4. This fairly large variation is down to the randomness of the deals. For this reason I would suggest that the number of games in a sequence is not less than 20.

I went on to implement a reasonable attack strategy and kept to 19-game sequences. After a large number of sequences I found that the range of scores was again about 8 units but that the distribution had shifted, giving a mean score of about 2. This suggests that any strategy is likely to lead to a wide distribution of scores (probably with a width of around 8).

I would suggest that game sequences are of 20 games (although more would be better). If 20 games are chosen and the scoring system that I have suggested is used, then I would suggest that a score of 6 or 7 should be set as the target for solving the problem. This would mean (even with a good strategy) possibly needing to run the program several times before achieving the target.

One final point - I didn't find any problems with the way in which the system is running. I think that aspect of the problem works well.

Rodion (admin)     2023-06-04 06:18:15
User avatar

Hi Clive! Thanks a lot for such thorough testing - you see I'm still much at loss about how to go about creating problems on games-of-chance - so the insight like this is much helpful!

Two minor changes were made to the game according to your advice, if I got it right :)

  • up to 200 games could be started
  • when all games are ended the score is shown as proposed (+1 for every game won, -1 for every game lost)

If I understand correctly, your advanced strategy is expected to score about 20 points over 200 games - is it ok to set such score as winning condition? We agree that anyway some especially unlucky user may want to re-run the game few times :)

At the same time there is a chance that some very lucky user may score enough points even with strategy equal to one used on server... But probably even this would provide some exercise so perhaps it's ok?

UPD: also I wonder whether adding more ranks should improve distribution... With say 9 ranks instead of 7 we still can mark every of them easily with a single digit... And I'm under impression that odd number is better.

CSFPython     2023-06-04 19:16:41

Rodion, I see that you have allowed up to 200 games to be chosen. I also notice that you have implemented the points scoring system.

The first minor point is that the score is reported as a number of games won, rather than as a score. For example, the system might give the message: "You won -2 games".

I have experimented with sequences of 200 games. Everything still works correctly, although (not surprisingly) there is still are large variation in the score. With 200 games I would suggest a target score of at least 30; probably something between 30 and 40. Over a large number of sequences the smallest score was 14 and the largest 58.

I had also considered moving to 9 ranks. If this is the only change then I think it would make very little difference. The reason for this is that, in the early part of the game, there is very little scope to get an attack strategy that is significantly better than random choice. The attack strategy becomes signifcant towards the end of the game. However, I do think that moving to 9 ranks would be an improvement provided that the game starts (and continues) with the players having 9 cards each (rather than 7). This makes the end-game longer, which should help.

Rodion (admin)     2023-06-05 06:12:18
User avatar

Clive, thanks a lot once more! Then let it go live with these amends you suggest - to summarize:

  • game is played with 36 card (9 ranks in 4 suits)
  • players operate with 9-card hands
  • to win one need to score at least 35 after all games are completed

Probably after trying to win against it myself I'll be able to make further problems of the kind (if any) less imperfect and dull... need to start trying with something at least to get better grasp on the subject :)

CSFPython     2023-06-05 09:05:48

Rodion, I've tried the final version and everything works as it should. I was hoping for improved scores over the 7 card version but the range of scores over a number of games seemed to be very much the same as before. Nevertheless, the increased number of cards improves the scope for a range of different strategies. I deliberately set out to produce a reasonable strategy rather than a world beater, so I know it can be improved. I think the final target score is fair. It should give any serious attempt a good chance of success.

Rodion (admin)     2023-06-05 09:58:10
User avatar

Clive, thanks a lot for cooperation! As about strategies it would be interesting to revive the idea of creating "duels" between two participants' algorithms - though I never was good at this, but it is also curious to see gurus engaged in such challenges :)

gardengnome     2023-06-09 21:27:14
User avatar

I am little bit late to the party, but thanks for this problem. 35 is fair and reasonable as a target score. Interestingly, my strategy works rather well in the early parts of the game - I have seen intermediate results of over +100 - but it fades badly towards the end ...

Please login and solve 5 problems to be able to post at forum