Page 1 of 2

Mining ideas / code from other games

Posted: 16 February 2021, 05:39
by Ciffy
Is there an easy way to look at the code for other games? I want to learn how to rotate the view / board so that your pieces are always on the bottom (like in chess, your pieces are always the ones closest to you, but it knows how to display that info upside down for your opponent). Is it just deciding which way is "right" and displaying it normally and when not "right" do it upside down? 2 players only for now.

Also, there's nothing in the tutorial about limiting a game's number of players; it just says to lower the player count before creating the game. Is there anyway (again, like in chess) to say, "this game will only take 2 players".

Re: Mining ideas / code from other games

Posted: 16 February 2021, 09:39
by Bids
Hi, there is a BGA code sharing page where you can see the code of some game. You can look in google for BGA code sharing. You can change the number of players in the gameinfos.inc.php file. Hope it helps :)

Re: Mining ideas / code from other games

Posted: 16 February 2021, 11:50
by XCID
On the studio projects list, you can gain read access to most of the games.

Re: Mining ideas / code from other games

Posted: 17 February 2021, 04:35
by RavingWanderer
In particular, the tutorial Hearts game will show you how to orient the player displays so that the current player is "south".

Re: Mining ideas / code from other games

Posted: 17 February 2021, 08:24
by tchobello
you can find chess, checkers or xiang qi code in studio projects (don't forget to select 'already published')...

Re: Mining ideas / code from other games

Posted: 17 February 2021, 10:58
by junibegood
Is there anyway (again, like in chess) to say, "this game will only take 2 players".
This is defined in "gameinfos.inc.php". See documentation here : https://en.doc.boardgamearena.com/Game_ ... of_players

Re: Mining ideas / code from other games

Posted: 20 February 2021, 06:27
by Ciffy
Thanks all. I couldn't make heads or tails out of the Hearts stuff, but chess is what I'm trying to model after and, thankfully, I think I see how it's handling the board positioning based on color. Love the fact that you can get read only to other stuff to learn with.

Now I just need to get you people to comment your code! >_>

Re: Mining ideas / code from other games

Posted: 20 February 2021, 10:09
by LaszloK
The best code to learn from usually has few comments.
Comments are not like Schindler's List. They are not "pure good". Indeed, comments are, at best, a necessary evil. If our programming languages were expressive enough, or if we had the talent to subtly wield those languages to express our intent, we would not need comments very much - perhaps not at all. The proper use of comments is to compensate for our failure to express ourself in code.
(Robert C. Martin, "Clean Code", p. 53.)

Re: Mining ideas / code from other games

Posted: 20 February 2021, 10:40
by Tisaac
LaszloK wrote: 20 February 2021, 10:09 The best code to learn from usually has few comments.
Comments are not like Schindler's List. They are not "pure good". Indeed, comments are, at best, a necessary evil. If our programming languages were expressive enough, or if we had the talent to subtly wield those languages to express our intent, we would not need comments very much - perhaps not at all. The proper use of comments is to compensate for our failure to express ourself in code.
(Robert C. Martin, "Clean Code", p. 53.)
I think he is referring more to the framework code structure rather than what is inside the functions. If you don't know how the framework works, it's pretty to hard to understand what's going on. Read the docs, again and again, that's probably the best advice I can give you.

Re: Mining ideas / code from other games

Posted: 21 February 2021, 05:09
by Ciffy
Yeah, it's more a matter of understanding how the piece data is stored so that it can be displayed from either side. Since I also don't know the framework, it's just a steeper curve. I'll get there though.