Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a finiteness test #5

Merged
merged 4 commits into from
Jun 8, 2023

Conversation

alessandro-gentilini
Copy link
Contributor

Hello Mr. Mayer,
thank you for your program that is the standard de facto for the quest to infiniteness of Beggar my Neighbour.

I am from Italy where we play "Camicia" which is described by Marc M. Paulhusa in this way:

For the record, the Italian game of "Camicia" is played with a 40 card deck with 12 court cards (4 each of values 1, 2, and 3). Playing a billion random deals of Camicia also failed to produce any cycles.

Some years ago I was an avid seeker but then I stopped the quest and now to my surprise I found that Camicia was declared non terminating in 2016b and in 2017c.

My ancient C++ code confirmed the infiniteness but it is a rat nest and so I am proposing you to add a finiteness test to your program, my proposal is very simple but I am not 100% sure it is correct.

P.S. I forgot a print(finite) as a last line.

All the best,
Alessandro

aMarc M. Paulhus (1999) Beggar My Neighbour, The American Mathematical Monthly, 106:2, 162-165, DOI: 10.1080/00029890.1999.12005024
bSee https://cstheory.stackexchange.com/questions/22175/does-this-game-terminate/52560#52560
cSee see https://github.com/drago-96/cavacamisa/blob/master/infinite/20170217.txt and https://github.com/drago-96/cavacamisa

A proposal for a finiteness test.
@matthewmayer
Copy link
Owner

Thanks! do you have a sample of a starting hand which causes an infinite loop?

@alessandro-gentilini
Copy link
Contributor Author

alessandro-gentilini commented Mar 11, 2023

Hello!
Starting hands: --3-2-2-3-31-----31-/--1--2----2-------1-.

Since Camicia has different cards, in order to test it, I modified your penalty_value_of function in this way:

def penalty_value_of(card):
    values = {"1":1,"2":2,"3":3}
    return values[card]

@LeoDog896
Copy link

By the way, I made a faster simulator (written in Rust): https://github.com/LeoDog896/beggar-my-neighbour

It handles these cases a lot faster.

@matthewmayer
Copy link
Owner

For sure python is a terrible choice if you want something fast enough to check large numbers of games!

@matthewmayer matthewmayer merged commit 49c4178 into matthewmayer:master Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants