📄 brain.java
字号:
package cs111.tetris.brain;import cs111.tetris.data.Board;import cs111.tetris.data.Piece;/** * A brain instance contains "AI" code to decide the best position and rotation * to play a given piece on a given Board. * <p> * Anybody who wants to implement a new, improved AI can implement this interface. * The easiest way to implement your own Brain is to make a subclass of the * provided {@link LameBrain} implementation. */public interface Brain { /** * A Move instance is used by the Brain as simple data structure to store a * single move. A move (from a Brain's point of view) is a recommendation * of what a given piece should be rotated to and where it should come * to rest. */ public static class Move { /** * The x coordinate where the piece should come to rest. */ public int x; /** * The x coordinate where the piece should come to rest. */ public int y; /** * The rotation to which the piece should be rotated before * it comes to rest. */ public Piece piece; /** * A value that estimates how good/bad this move is. A higher * value is taken to mean "bad" a lower value means "good". */ public double score; } /** * Given a piece and a board, returns a move object that represents the best * play for that piece, or returns null if no play is possible. The board * should be in the committed state when this is called. "limitHeight" is * the bottom section of the board where pieces must come to rest -- * typically 20. If the passed in move is non-null, it is used to hold the * result (just to save the time to allocate memory). */ public Brain.Move bestMove(Board board, Piece piece, int limitHeight, Brain.Move move); /** * @return A String describing the brain version. This info will be * displayed in the UI so that it's easy to see which Brain is playing. */ public String getVersionInfo();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -