Conway's Game of Life with std::set

I have planned out a implementation of Conway's Game of Life which will (hopefully) give the impression of being 'infinite'. It will use a sparse array which I will make using a set. So, when a new cell is created I will add it to the set. My problem is that won't eventually the co-ordinates get bigger than an int can store?

Is this a problem I need to worry about? If so, then should I use an int_64 or something? Or should I use a bingint class?

Sorry if my post is bad (it's my first one here).
Yes, if you wait longer than the universe will exist, you will encounter integer overflow. Except you can't unless you A. live forever and B. escape the end of the universe.
So I don't need to be worried about it?
I wouldn't worry about accidentally living forever and escaping the end of the universe with the program running the whole time.

If you're using a 32-bit system instead, then just use long long or std::int64_t or even std::intmax_t:
http://en.cppreference.com/w/cpp/header/cstdint
A 32-bit value will overflow within your natural life span, a 64-bit value will outlast the universe itself.

Required viewing:
https://www.youtube.com/watch?v=QJQ691PTKsA
Last edited on
Ahh. Yes. But that is only if there is only one move per second. If I go faster it may change. Still a 64bit number will still take a long time to run out.

Sorry for my stupid question.
Your question is not stupid at all, it is quite interesting to consider conway's game of life over an excessively elongated time period with infinite bounds.

If you do find that it runs out with some patterns you could always resort to a bignum library and use arbitrary precision.
Last edited on
Topic archived. No new replies allowed.