com.threerings.puzzle.data
Class Board

java.lang.Object
  extended by com.threerings.puzzle.data.Board
All Implemented Interfaces:
Streamable, Cloneable
Direct Known Subclasses:
DropBoard

public abstract class Board
extends Object
implements Cloneable, Streamable

An abstract base class for generating and storing puzzle board data.


Nested Class Summary
protected static class Board.BoardRandom
          Used to generate random numbers.
 
Nested classes/interfaces inherited from interface com.threerings.io.Streamable
Streamable.Closure
 
Field Summary
protected  Board.BoardRandom _rando
          The object we use to generate our random numbers.
 
Constructor Summary
Board()
           
 
Method Summary
 Board clone()
           
abstract  void dump()
          Outputs a string representation of the board contents.
abstract  void dumpAndCompare(Board other)
          Outputs a string representation of the board contents, interlaced with the supplied comparison board.
abstract  boolean equals(Board other)
          Returns whether this board is equal to the given comparison board.
 Random getRandom()
          Returns the random number generator used by the board to generate random numbers for our puzzles.
protected  int getSeedForEvent(int pidx, int gevent)
          Returns a number of bits to read off the random number generator for this event.
 void initializeSeed(long seed)
          Sets the seed in the board's random number generator and calls populate().
protected  boolean isSeedingEvent(int pidx, int gevent)
          Returns whether this event is the sort of thing we should use to generate extra noise on our random number generator.
protected  void populate()
          Called after the seed is set in the board to give derived classes a chance to do things like populating the board with random pieces.
 void seedFromEvent(int pidx, int gevent)
          Allows puzzles to add extra noise to their random number generators based on the specific events sent from the client to make it more difficult for a hacked client to predict things such as piece generation.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_rando

protected transient Board.BoardRandom _rando
The object we use to generate our random numbers.

Constructor Detail

Board

public Board()
Method Detail

dump

public abstract void dump()
Outputs a string representation of the board contents.


dumpAndCompare

public abstract void dumpAndCompare(Board other)
Outputs a string representation of the board contents, interlaced with the supplied comparison board.


equals

public abstract boolean equals(Board other)
Returns whether this board is equal to the given comparison board.


clone

public Board clone()
Overrides:
clone in class Object

initializeSeed

public void initializeSeed(long seed)
Sets the seed in the board's random number generator and calls populate().


getRandom

public Random getRandom()
Returns the random number generator used by the board to generate random numbers for our puzzles.


populate

protected void populate()
Called after the seed is set in the board to give derived classes a chance to do things like populating the board with random pieces.


seedFromEvent

public void seedFromEvent(int pidx,
                          int gevent)
Allows puzzles to add extra noise to their random number generators based on the specific events sent from the client to make it more difficult for a hacked client to predict things such as piece generation.

Parameters:
pidx - the player index that submitted the progress event.
gevent - the progress event itself.

isSeedingEvent

protected boolean isSeedingEvent(int pidx,
                                 int gevent)
Returns whether this event is the sort of thing we should use to generate extra noise on our random number generator.


getSeedForEvent

protected int getSeedForEvent(int pidx,
                              int gevent)
Returns a number of bits to read off the random number generator for this event. Subclasses can replace this with something that better understands the formats of its particular events if desired.