data model for crumble?

24 views
Skip to first unread message

Misha Leder

unread,
Jan 5, 2009, 2:51:17 PM1/5/09
to cru...@googlegroups.com
I know a few of you tried to implement crumble. What data model have you used?

This is what I came up with:


Piece
  * color : {Black, White}
  * size[Horizontal, Vertical] : Rational 
  * start[Horizontal, Vertical] : Rational
  * connections[Top, Bottom, Left, Right] : array<Piece>

Board
  * size[Horizontal, Vertical] : Rational
  * pieces: array<Piece>
 
Any comments / suggestions?
Thanks!
-Misha  

William French

unread,
Jan 5, 2009, 9:48:21 PM1/5/09
to cru...@googlegroups.com
On Mon, Jan 5, 2009 at 2:51 PM, Misha Leder <misha...@gmail.com> wrote:
I know a few of you tried to implement crumble. What data model have you used?

This is what I came up with:


Piece
  * color : {Black, White}
  * size[Horizontal, Vertical] : Rational 
  * start[Horizontal, Vertical] : Rational

I store all four edges, so it's easier to decode the piece notation.  I also store the centers, mainly to simplify long splits.

  * connections[Top, Bottom, Left, Right] : array<Piece>

I have lists of corner-neighbors as well, used when scanning for captures.
 
Board
  * size[Horizontal, Vertical] : Rational

I just assume the board is 1x1

There are more elaborations that I won't go into now; I think my code is a bit over-engineered anyway.

http://crumble-engine.appspot.com/source/crumble_pack.zip


$

Adam Vartanian

unread,
Jan 5, 2009, 10:27:23 PM1/5/09
to cru...@googlegroups.com
> I know a few of you tried to implement crumble. What data model have you
> used?
> This is what I came up with:

Specifically in terms of pieces, I use the following:

Piece
* color : {"b", "w"}
* x, y : int
* height, width: int

Board
* pieces : Piece[]
* board : Piece[][]

My implementation has a minimum piece size, but the minimum size is
1/8 of an initial piece (ie, 1/4 in square, based on a the 2-inch
squares we're using to play), which we've never reached in real play
that I've seen, and it's just a constant so it could easily be
lowered. Board::board makes it really easy to look up what piece is
where. For instance, the piece directly above a piece is the piece at
Board::board[piece.x][piece.y + piece.height].

- Adam

Reply all
Reply to author
Forward
Message has been deleted
0 new messages