ID:1600188
 
It suddenly dawned on me today that games are really seemingly infinite loops with a built in break condition. For instance, chess is a game that continues as long as either king is not in checkmate. It can go on for eternity (with time limits removed) if both players opt to create a scenario in which neither king ever enters checkmate. It's almost comical if you ask me. I wonder why I hadn't though of this sooner.

I'm gonna try to program my 2 player games as infinite loops from now on, hopefully the loopcheck won't screw me over.
lol no the loopcheck won't screw you over.
I disagree. Chess can only go on infinitely if both players actively try not to play the game, by moving their pieces around but never attacking each other. Otherwise it is impossible for a game to go on infinitely. If it is not possible for either king to be checkmated, it's a stalemate. There is also usually a rule about repetition, if the same position is repeated too many times then the game is drawn.

Perhaps it is true that most games involve some sort of repetition, whether it is players taking turns or just a series of matches or rounds in a real-time game. But it's not an infinite loop if there is a break condition, especially one that is clearly the goal of the game.
I prefer to think of games as problems. Not all problems have a solution. For example Minecraft has no winning condition. In essence these are 'infinite loops' in that no input gives a final output.

For problems/games that have a solution there are two types.

1.Solutions without cycles. This is a game of tic-tac-toe. Each input leads irreversibly to a final output.

2.Solutions with cycles. This is Doom, Super Mario. Some inputs in succession will lead to the final output of the game. Some won't.

In essence because input is based on choice, one can choose to repeat a cycle of inputs that don't lead to the end output. For example running in a circle or back and forth.
In response to Zecronious
Zecronious wrote:
For example Minecraft has no winning condition.

Actually it does have The End, where you go and fight the final boss to win the game. Of course you can still continue playing :)
You should avoid programming entire things as actual loops though. Imo anyway.

You'd get a much faster response if you allow the player's input to dictate the actions instead of waiting for a loop to pick up on a signal. Also the cpu overhead could be costly.
Of course, physics engines require one loop running constantly to drive movement regardless of player input.
@Lugia319:
In case you weren't aware of this, you're absolutely correct!
Computer games are "realtime interactive simulations".

That's how computer games are actually programmed. BYOND hides this (it's called, the game's "life cycle"), but it's definitely in there.
In response to Gooseheaded
Gooseheaded wrote:
@Lugia319:
In case you weren't aware of this, you're absolutely correct!
Computer games are "realtime interactive simulations".

That's how computer games are actually programmed. BYOND hides this (it's called, the game's "life cycle"), but it's definitely in there.

He is. The lifecycle loop does in fact exist within BYOND. We just can't see it.