Android Open Source - abalone-android Layout






From Project

Back to project page abalone-android.

License

The source code is released under:

GNU General Public License

If you think the Android project abalone-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
* Copyright (c) 2010-2011 Yaroslav Geryatovich, Alexander Yakushev
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*///  w w  w. j ava 2s  . co  m
package com.bytopia.abalone.mechanics;

/**
 * Class that represents an abstract factory of starting positions (layouts).
 * 
 * @author Bytopia
 */
public abstract class Layout {

  /**
   * Represents a non-existing cell.
   */
  public static final byte N = 0;

  /**
   * Represents an empty cell.
   */
  public static final byte E = 1;

  /**
   * Represents a cell with white marble.
   */
  public static final byte W = Side.WHITE;

  /**
   * Represents a cell with black marble.
   */
  public static final byte B = Side.BLACK;

  /**
   * Returns a two-dimensional array filled with definitions of cells for the
   * starting position with black marbles downside.
   * 
   * @return array that contains starting position with black marbles downside
   */
  public abstract byte[][] getBlackStartField();

  /**
   * Returns a mirrored layout with white marbles downside respectively.
   * 
   * @return array that contains starting position with white marbles downside
   */
  public byte[][] getWhiteStartField() {
    byte[][] field = getBlackStartField();
    byte t;
    for (int i = 1; i < 5; i++) {
      // TODO Cache-optimize here
      for (int j = Cell.minColumn[i]; j <= Cell.maxColumn[i]; j++) {
        t = field[i][j];
        field[i][j] = field[10 - i][Cell.maxColumn[10 - i] - j + 1];
        field[10 - i][Cell.maxColumn[10 - i] - j + 1] = t;
      }
    }
    return field;
  }

}




Java Source Code List

com.bytopia.abalone.BoardRenderer.java
com.bytopia.abalone.BoardView.java
com.bytopia.abalone.GameActivity.java
com.bytopia.abalone.GameOptionsActivity.java
com.bytopia.abalone.LoseBallsView.java
com.bytopia.abalone.MainMenuActivity.java
com.bytopia.abalone.Options.java
com.bytopia.abalone.Scenario.java
com.bytopia.abalone.SelectLayoutActivity.java
com.bytopia.abalone.SplashAcitvity.java
com.bytopia.abalone.TutorialActivity.java
com.bytopia.abalone.TutorialBoardView.java
com.bytopia.abalone.mechanics.AiAnn.java
com.bytopia.abalone.mechanics.AiBeatrice.java
com.bytopia.abalone.mechanics.AiCharlotte.java
com.bytopia.abalone.mechanics.AiDeborah.java
com.bytopia.abalone.mechanics.ArtificialIntilligence.java
com.bytopia.abalone.mechanics.BelgianLayout.java
com.bytopia.abalone.mechanics.Board.java
com.bytopia.abalone.mechanics.Cell.java
com.bytopia.abalone.mechanics.ClassicLayout.java
com.bytopia.abalone.mechanics.ConsoleWatcher.java
com.bytopia.abalone.mechanics.Debug.java
com.bytopia.abalone.mechanics.Direction.java
com.bytopia.abalone.mechanics.EmptyLayout.java
com.bytopia.abalone.mechanics.Game.java
com.bytopia.abalone.mechanics.GermanLayout.java
com.bytopia.abalone.mechanics.Group.java
com.bytopia.abalone.mechanics.Layout.java
com.bytopia.abalone.mechanics.MoveType.java
com.bytopia.abalone.mechanics.Move.java
com.bytopia.abalone.mechanics.Player.java
com.bytopia.abalone.mechanics.Side.java
com.bytopia.abalone.mechanics.TestLayout.java
com.bytopia.abalone.mechanics.Watcher.java