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?