G
G
GingerSibe2022-02-20 19:54:58
C++ / C#
GingerSibe, 2022-02-20 19:54:58

How is the move passed from player to player in a computer board game?

Hello, there are computer board games where 2 people play in one session, they throw dice, make moves on the map, etc.
So the question itself is how the transfer of the move from player to player is done, through what and how this can be done at all, and preferably in more detail.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vasily Bannikov, 2022-02-20
@vabka

Well, something like this:
game.SwitchToNextPlayer();

F
freeExec, 2022-02-20
@freeExec

Apparently you missed the paragraph of structure, data and algorithms.
I don't know what answer you expect, in an abstract game it would be: change the index of the current player and start over.

M
Mimocodil, 2022-02-21
@Ezekiel4

This is done in two steps:
1. The data is a kind of pointer to whose turn it is now. You can make, for example, a boolean variable (approx. tic-tac-toe: the move of the cross is false, the zero is true), a number (approx. MMO game: player id), or an enumeration (approx. Warcraft: RedPlayer, BluePlayer, TealPlayer, etc). It is possible and others (symbol, string-name, IP or something else).
2. Condition - every move the game checks which player moves.
How it works - each player can move, but the game does not consider it a move (nothing changes). For example, just taps on the screen, which the game will not respond to if this player does not match the player whose turn it is.
Imagine chess. If the current player is white, then black can of course use the mouse/touchscreen, but nothing will happen. And vice versa, the game will accept similar actions of the white opponent.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question