// Path: src/main/java/com/fluxchess/pulse/model/MoveType.java
// public static final int NOMOVETYPE = 5;
// 
// Path: src/main/java/com/fluxchess/pulse/model/Piece.java
// public static final int NOPIECE = 12;
// 
// Path: src/main/java/com/fluxchess/pulse/model/PieceType.java
// public static final int NOPIECETYPE = 6;
// 
// Path: src/main/java/com/fluxchess/pulse/model/Square.java
// public static final int NOSQUARE = 127;


import static com.fluxchess.pulse.model.MoveType.NOMOVETYPE;
import static com.fluxchess.pulse.model.Piece.NOPIECE;
import static com.fluxchess.pulse.model.PieceType.NOPIECETYPE;
import static com.fluxchess.pulse.model.Square.NOSQUARE;
/*
 * Copyright 2013-2021 Phokham Nonava
 *
 * Use of this source code is governed by the MIT license that can be
 * found in the LICENSE file.
 */
package com.fluxchess.pulse.model;


/**
 * This class represents a move as a int value. The fields are represented by
 * the following bits.
 * <ul>
 * <li><code> 0 -  2</code>: type (required)</li>
 * <li><code> 3 -  9</code>: origin square (required)</li>
 * <li><code>10 - 16</code>: target square (required)</li>
 * <li><code>17 - 21</code>: origin piece (required)</li>
 * <li><code>22 - 26</code>: target piece (optional)</li>
 * <li><code>27 - 29</code>: promotion type (optional)</li>
 * </ul>
 */
public final class Move {

	// These are our bit masks
	private static final int TYPE_SHIFT = 0;
	private static final int TYPE_MASK = MoveType.MASK << TYPE_SHIFT;
	private static final int ORIGIN_SQUARE_SHIFT = 3;
	private static final int ORIGIN_SQUARE_MASK = Square.MASK << ORIGIN_SQUARE_SHIFT;
	private static final int TARGET_SQUARE_SHIFT = 10;
	private static final int TARGET_SQUARE_MASK = Square.MASK << TARGET_SQUARE_SHIFT;
	private static final int ORIGIN_PIECE_SHIFT = 17;
	private static final int ORIGIN_PIECE_MASK = Piece.MASK << ORIGIN_PIECE_SHIFT;
	private static final int TARGET_PIECE_SHIFT = 22;
	private static final int TARGET_PIECE_MASK = Piece.MASK << TARGET_PIECE_SHIFT;
	private static final int PROMOTION_SHIFT = 27;
	private static final int PROMOTION_MASK = PieceType.MASK << PROMOTION_SHIFT;

	// We don't use 0 as a null value to protect against errors.
// Path: src/main/java/com/fluxchess/pulse/model/MoveType.java
// public static final int NOMOVETYPE = 5;
// 
// Path: src/main/java/com/fluxchess/pulse/model/Piece.java
// public static final int NOPIECE = 12;
// 
// Path: src/main/java/com/fluxchess/pulse/model/PieceType.java
// public static final int NOPIECETYPE = 6;
// 
// Path: src/main/java/com/fluxchess/pulse/model/Square.java
// public static final int NOSQUARE = 127;


// Path: src/main/java/com/fluxchess/pulse/model/Move.java
import static com.fluxchess.pulse.model.MoveType.NOMOVETYPE;
import static com.fluxchess.pulse.model.Piece.NOPIECE;
import static com.fluxchess.pulse.model.PieceType.NOPIECETYPE;
import static com.fluxchess.pulse.model.Square.NOSQUARE;

/*
 * Copyright 2013-2021 Phokham Nonava
 *
 * Use of this source code is governed by the MIT license that can be
 * found in the LICENSE file.
 */
package com.fluxchess.pulse.model;


/**
 * This class represents a move as a int value. The fields are represented by
 * the following bits.
 * <ul>
 * <li><code> 0 -  2</code>: type (required)</li>
 * <li><code> 3 -  9</code>: origin square (required)</li>
 * <li><code>10 - 16</code>: target square (required)</li>
 * <li><code>17 - 21</code>: origin piece (required)</li>
 * <li><code>22 - 26</code>: target piece (optional)</li>
 * <li><code>27 - 29</code>: promotion type (optional)</li>
 * </ul>
 */
public final class Move {

	// These are our bit masks
	private static final int TYPE_SHIFT = 0;
	private static final int TYPE_MASK = MoveType.MASK << TYPE_SHIFT;
	private static final int ORIGIN_SQUARE_SHIFT = 3;
	private static final int ORIGIN_SQUARE_MASK = Square.MASK << ORIGIN_SQUARE_SHIFT;
	private static final int TARGET_SQUARE_SHIFT = 10;
	private static final int TARGET_SQUARE_MASK = Square.MASK << TARGET_SQUARE_SHIFT;
	private static final int ORIGIN_PIECE_SHIFT = 17;
	private static final int ORIGIN_PIECE_MASK = Piece.MASK << ORIGIN_PIECE_SHIFT;
	private static final int TARGET_PIECE_SHIFT = 22;
	private static final int TARGET_PIECE_MASK = Piece.MASK << TARGET_PIECE_SHIFT;
	private static final int PROMOTION_SHIFT = 27;
	private static final int PROMOTION_MASK = PieceType.MASK << PROMOTION_SHIFT;

	// We don't use 0 as a null value to protect against errors.
	public static final int NOMOVE = (NOMOVETYPE << TYPE_SHIFT)