Page 1 of 1

Player colours aren't random: BGA Studio

Posted: 20 January 2022, 10:55
by RicardoRix
My game has 4 different player colours, each colour has slightly different powers, the colour assignment needs to be random.

But I have opened a bunch (at least 10) of 2 player games, and it's always the same colours to the same 0 and 1 colour, and it's the first 2 colours in the games options list. So I'm guessing it's not random?
4-player games seem randomised, but it's just 2-player which is stuck.

Is there a random colour option I've missed?

Code: Select all

'favorite_colors_support' => false,
'disable_player_order_swap_on_rematch' => false,

Re: Player colours aren't random: BGA Studio

Posted: 20 January 2022, 13:18
by thoun
Well you insert colors you want on setupNewGame, so you can replace default color assignment by your own :)

Re: Player colours aren't random: BGA Studio

Posted: 20 January 2022, 15:38
by RicardoRix
I just opened 6 games of cchess, and it was always 0=red 1=blue, with a random start player. I can't see how this is possible.

Yes. I think I fried my brain opening and closing so many games, but I can overcome it with this:

Code: Select all

	$r = bga_rand(0, count($default_colors) - 1);
			$color = $default_colors[$r];
			array_splice($default_colors, $r, 1);			
		    //$color = array_shift( $default_colors );

Re: Player colours aren't random: BGA Studio

Posted: 21 January 2022, 05:43
by ufm
It is totally natural, since BGA template uses array_shift() to assign colors.
Just manually randomize $default_colors or color assignment itself.

Re: Player colours aren't random: BGA Studio

Posted: 21 January 2022, 09:21
by RicardoRix
Yes, $default_colors will always be the same. But that data comes from behind a function, so it doesn't necessarily have to be fixed.
but the gameSetup $players array argument seems to come out randomised.

I think I was thrown in testing cchess, because that uses players colour preference, reattributeColorsBasedOnPreferences()

It would also be nice if randomised colour was an option, rather than having to manually do it. The same for colour preferences.