This is the most baffling and puzzling bug I have ever encountered or read about..

Discussions about BGA (all languages)
Forum rules
Warning: challenging a moderation in Forum = 10 days ban
More info & details about how to challenge a moderation: viewtopic.php?p=119756
Ceaseless
Posts: 1316
Joined: 12 November 2022, 17:06

Re: This is the most baffling and puzzling bug I have ever encountered or read about..

Post by Ceaseless »

FrankJones wrote: 06 July 2025, 16:54 If I had written a post entitled, "What a mysterious and baffling bug; in my game of chess, my opponent's turn was skipped and I got 2 turns in a row", would people still be saying, "Oh, that sounds like a normal common bug"?
You moved your pawn forward two spaces, didn't you? ;)

Just wait until they see en passant.
FrankJones
Posts: 2456
Joined: 30 June 2024, 00:24

Re: This is the most baffling and puzzling bug I have ever encountered or read about..

Post by FrankJones »

I remember the first time I was captured En Passant :) I thought, "What on earth just happened"?

Anyway, if anyone actually does see or hear about a similar bug to the one I experienced, in which a player's turn is outright skipped, and this thread comes to mind, please post. I would be curious to see whether the developer for that game (or a BGA developer) is able to determine the cause.
User avatar
RicardoRix
Posts: 2541
Joined: 29 April 2012, 23:43

Re: This is the most baffling and puzzling bug I have ever encountered or read about..

Post by RicardoRix »

One of the few ways next player turns might be handled:

https://en.doc.boardgamearena.com/Main_ ... r_handling

The state machine which is used to handle the changes between player turns and actions and rounds is pretty complicated.

I think nik says it pretty well, where bugs by design are intentionally not meant to happen, and if they're not happening straight away and get immediately fixed so you never see them, then they are almost always some kind of edge case.
FrankJones
Posts: 2456
Joined: 30 June 2024, 00:24

Re: This is the most baffling and puzzling bug I have ever encountered or read about..

Post by FrankJones »

RicardoRix wrote: 07 July 2025, 20:09 One of the few ways next player turns might be handled:

https://en.doc.boardgamearena.com/Main_ ... r_handling

The state machine which is used to handle the changes between player turns and actions and rounds is pretty complicated.

I think nik says it pretty well, where bugs by design are intentionally not meant to happen, and if they're not happening straight away and get immediately fixed so you never see them, then they are almost always some kind of edge case.
Thank you for this link. I took a look, and I find this code very readable. (I learned Java and Python, and a small amount of JavaScript).

So, if I were programming a simple game where each player makes one move and then the active player changes, I would use the simplest function available. Perhaps this one:

$this->activeNextPlayer()

In my experience as an amateur programmer (by "amateur" I do not mean "unskilled", I just mean it was a hobby and not a profession), I used other techniques that in retrospect seem silly, such as an if/else block.

if(active_player==player_1)
(active_player=player_2)
else
(active_player=player_1)

Kind of silly, and would become more and more convoluted for increasingly higher player counts.
But it always worked, and my games functioned :)

Back to the original topic:

In my Aquatica game, my best guess (and one that has been strongly suggested by at least 2 other professional developers) is that something caused the change-player function to execute twice. That would be consistent with the game log showing two active-player changes, even though the second player never made a move.

My understanding is that many things can cause such an occurrence; it's rare but not inexplicable, and likely has nothing to do with the Aquatica code, which until that occurrence, had successfully changed the active player with a 100000 out of 100000 success rate, as far as I know.

I have posted this thread and continued to post in this thread because this is interesting to me. I took a programming boot camp, quit because the schedule and commute were too intense, and then spent 6 months learning Java, Python, SQL, on my own. I enjoyed it, and I wanted to become a developer. I still might. But mostly I want to program games, and I have been told repeatedly that's a rough life with little reward.

Anyway, nobody inferred any of that from my posts, even though these are perfectly reasonable explanations for my high level of interest in this occurrence.
User avatar
Meeplelowda
Posts: 3857
Joined: 14 March 2020, 10:31

Re: This is the most baffling and puzzling bug I have ever encountered or read about..

Post by Meeplelowda »

FrankJones wrote: 08 July 2025, 01:12 $this->activeNextPlayer()
Now I'm curious how this method is implemented.
Play Now lobby 4ever! https://boardgamearena.com/lobby
FrankJones
Posts: 2456
Joined: 30 June 2024, 00:24

Re: This is the most baffling and puzzling bug I have ever encountered or read about..

Post by FrankJones »

Meeplelowda wrote: 08 July 2025, 06:41
FrankJones wrote: 08 July 2025, 01:12 $this->activeNextPlayer()
Now I'm curious how this method is implemented.
Here's how I have done it:
(I'll just write the code logic in normal English)

After completing the resolution of one player's turn:

1) Check for gameOver condition.
2) If the game is over, execute the code to calculate the score and display the end-game page, banners, stats, etc.
3) If the game is not over, execute the code to change the active player to the next player, perhaps by calling that function: $this->activeNextPlayer()
4) Execute the code to display to the players that it is the next player's turn.
User avatar
Meeplelowda
Posts: 3857
Joined: 14 March 2020, 10:31

Re: This is the most baffling and puzzling bug I have ever encountered or read about..

Post by Meeplelowda »

FrankJones wrote: 08 July 2025, 17:10
Meeplelowda wrote: 08 July 2025, 06:41
FrankJones wrote: 08 July 2025, 01:12 $this->activeNextPlayer()
Now I'm curious how this method is implemented.
Here's how I have done it:
(I'll just write the code logic in normal English)

After completing the resolution of one player's turn:

1) Check for gameOver condition.
2) If the game is over, execute the code to calculate the score and display the end-game page, banners, stats, etc.
3) If the game is not over, execute the code to change the active player to the next player, perhaps by calling that function: $this->activeNextPlayer()
4) Execute the code to display to the players that it is the next player's turn.
I had a more specific question about how it's implemented in the BGA framework. I've similarly coded a two-player game that needed to switch between players with basically the same logic as yours:

Code: Select all

    winner = None
    cur_player = player
    while winner == None:
        empty = board.get_empty_squares()
        move = random.choice(empty)
        board.move(move[0], move[1], cur_player)
        
        # Update state
        winner = board.check_win()
        cur_player = provided.switch_player(cur_player)
activeNextPlayer() seems to be the equivalent of switch_player() above except it is capable of handling more than 2 players, so I was wondering how they are doing it.
Play Now lobby 4ever! https://boardgamearena.com/lobby
FrankJones
Posts: 2456
Joined: 30 June 2024, 00:24

Re: This is the most baffling and puzzling bug I have ever encountered or read about..

Post by FrankJones »

Meeplelowda wrote: 08 July 2025, 18:11
I had a more specific question about how it's implemented in the BGA framework. I've similarly coded a two-player game that needed to switch between players with basically the same logic as yours:

Code: Select all

    winner = None
    cur_player = player
    while winner == None:
        empty = board.get_empty_squares()
        move = random.choice(empty)
        board.move(move[0], move[1], cur_player)
        
        # Update state
        winner = board.check_win()
        cur_player = provided.switch_player(cur_player)
activeNextPlayer() seems to be the equivalent of switch_player() above except it is capable of handling more than 2 players, so I was wondering how they are doing it.
I can attempt a reply here, but with a few caveats:
1) I am not sure my answer will be what you are seeking.

2) I can see from your posts that you know at least as much programing as I do, and likely a lot more. You may be a professional developer for all I know.

3) When we start talking about Framework, databases, system architecture, etc. my knowledge is pretty much nil. I learned how to write functional back-end programs in an IntelliJ IDE, using Python or Java. So, my games had no visual or graphic interface other than X’s and O’s in the coding window, or whichever characters I was using to mark pieces on the board. I had no interest in front-end stuff. Bored me to tears, and was frustrating to work on. I remember an assignment for which we needed to use JavaScript and/or html to design a webpage and make all sorts of fussy parameters to have the page look a specific way, and I could not get my code to execute a I wanted; things did no line up, or id not scale to size the way I intended, and I hated it. Of course, hiring managers probably want full-stack developers, not just back-end developers who can write fancy math algorithms that seem impressive probably only to people who aren’t already strong in mathematics. Ultimately, maybe that why I did not pursue it. I wanted to code strategy games, but only the back-end. I wanted to make sure the cards work, that the game executed properly, but I wanted to leave the front-end and display stuff to other people. I wanted to find and fix every bug that was causing a card or rule to be executed improperly.

4) That said, I did write complete programs that, in my opinion, were far more complex than the simple resolution of the effects of individual cards in a card game, which is why I have always found it puzzling when seemingly minor bugs persist (Generally not on this website, but on other platforms where the developers seem to not have the time or money to fix things, or just don’t understand the rules of the games they are programming).

Using a game such as Splendor as an example, where the turn order is fixed throughout the game, I would imagine the activeNextPlayer() function, in a multiplayer game, would require defining variables in some useful way:

FrankJones_player_number=0
Meeplelowda_player_number=1
TomBrady_player_number=2
Etc.

And then the activeNextPlayer function increments the active player number by 1; thus changing active player from 0 to 1, or 1 to 2, etc., with an instruction on how to handle it when the incrementation results in a player_number value that exceeds the highest one in the game, and cycles back to player_number 0.

In games in which it is not necessarily a simple clockwise or anti-clockwise turn order, something else would be needed, but it would still just involve basic use of variables, incrementation, and if/else blocks, or whatever is easiest. Or so I would think.

I suspect this is not exactly what you were asking, though?
User avatar
Meeplelowda
Posts: 3857
Joined: 14 March 2020, 10:31

Re: This is the most baffling and puzzling bug I have ever encountered or read about..

Post by Meeplelowda »

FrankJones wrote: 08 July 2025, 19:36 You may be a professional developer for all I know.
Definitely not a professional. Just a casual hobbyist.
FrankJones wrote: 08 July 2025, 19:36 Using a game such as Splendor as an example, where the turn order is fixed throughout the game, I would imagine the activeNextPlayer() function, in a multiplayer game, would require defining variables in some useful way:

FrankJones_player_number=0
Meeplelowda_player_number=1
TomBrady_player_number=2
Etc.

And then the activeNextPlayer function increments the active player number by 1; thus changing active player from 0 to 1, or 1 to 2, etc., with an instruction on how to handle it when the incrementation results in a player_number value that exceeds the highest one in the game, and cycles back to player_number 0.

In games in which it is not necessarily a simple clockwise or anti-clockwise turn order, something else would be needed, but it would still just involve basic use of variables, incrementation, and if/else blocks, or whatever is easiest. Or so I would think.
Seems like a reasonable way they could be doing it, but I'm wondering how they are doing it. In other words, is the actual code implementing activeNextPlayer() available? How does it handle games in which the turn order reverses each round or as an effect of a game action (like Sushi Go or Solo)?
Play Now lobby 4ever! https://boardgamearena.com/lobby
FrankJones
Posts: 2456
Joined: 30 June 2024, 00:24

Re: This is the most baffling and puzzling bug I have ever encountered or read about..

Post by FrankJones »

That is a good question. I'm hoping someone in this thread can provide some insight here.
Post Reply

Return to “Discussions”