Java- Play Tetris

profilehcokevin
tetris5044-api.jar

help-doc.html

JavaScript is disabled on your browser. Skip navigation links
  • Prev
  • Next

How This API Document Is Organized

This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
  • Package

    Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:

    • Interfaces (italic)
    • Classes
    • Enums
    • Exceptions
    • Errors
    • Annotation Types
  • Class/Interface

    Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

    • Class inheritance diagram
    • Direct Subclasses
    • All Known Subinterfaces
    • All Known Implementing Classes
    • Class/interface declaration
    • Class/interface description
    • Nested Class Summary
    • Field Summary
    • Constructor Summary
    • Method Summary
    • Field Detail
    • Constructor Detail
    • Method Detail

    Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.

  • Annotation Type

    Each annotation type has its own separate page with the following sections:

    • Annotation Type declaration
    • Annotation Type description
    • Required Element Summary
    • Optional Element Summary
    • Element Detail
  • Enum

    Each enum has its own separate page with the following sections:

    • Enum declaration
    • Enum description
    • Enum Constant Summary
    • Enum Constant Detail
  • Use

    Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.

  • Deprecated API

    The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.

  • Index

    The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.

  • Prev/Next

    These links take you to the next or previous class, interface, package, or related page.

  • Frames/No Frames

    These links show and hide the HTML frames. All pages are available with or without frames.

  • All Classes

    The All Classes link shows all classes and interfaces except non-static nested types.

  • Serialized Form

    Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.

  • Constant Field Values

    The Constant Field Values page lists the static final fields and their values.

This help file applies to API documentation generated using the standard doclet. Skip navigation links
  • Prev
  • Next

constant-values.html

JavaScript is disabled on your browser. Skip navigation links
  • Prev
  • Next

Constant Field Values

Contents

edu.vt.*

  • edu.vt.cs5044.tetris. Board 
    Modifier and Type Constant Field Value
    public static final int HEIGHT 24
    public static final int HEIGHT_LIMIT 20
    public static final int WIDTH 10
Skip navigation links
  • Prev
  • Next

allclasses-frame.html

All Classes

index.html

stylesheet.css

/* Javadoc style sheet */ /* Overall document style */ @import url('resources/fonts/dejavu.css'); body { background-color:#ffffff; color:#353833; font-family:'DejaVu Sans', Arial, Helvetica, sans-serif; font-size:14px; margin:0; } a:link, a:visited { text-decoration:none; color:#4A6782; } a:hover, a:focus { text-decoration:none; color:#bb7a2a; } a:active { text-decoration:none; color:#4A6782; } a[name] { color:#353833; } a[name]:hover { text-decoration:none; color:#353833; } pre { font-family:'DejaVu Sans Mono', monospace; font-size:14px; } h1 { font-size:20px; } h2 { font-size:18px; } h3 { font-size:16px; font-style:italic; } h4 { font-size:13px; } h5 { font-size:12px; } h6 { font-size:11px; } ul { list-style-type:disc; } code, tt { font-family:'DejaVu Sans Mono', monospace; font-size:14px; padding-top:4px; margin-top:8px; line-height:1.4em; } dt code { font-family:'DejaVu Sans Mono', monospace; font-size:14px; padding-top:4px; } table tr td dt code { font-family:'DejaVu Sans Mono', monospace; font-size:14px; vertical-align:top; padding-top:4px; } sup { font-size:8px; } /* Document title and Copyright styles */ .clear { clear:both; height:0px; overflow:hidden; } .aboutLanguage { float:right; padding:0px 21px; font-size:11px; z-index:200; margin-top:-9px; } .legalCopy { margin-left:.5em; } .bar a, .bar a:link, .bar a:visited, .bar a:active { color:#FFFFFF; text-decoration:none; } .bar a:hover, .bar a:focus { color:#bb7a2a; } .tab { background-color:#0066FF; color:#ffffff; padding:8px; width:5em; font-weight:bold; } /* Navigation bar styles */ .bar { background-color:#4D7A97; color:#FFFFFF; padding:.8em .5em .4em .8em; height:auto;/*height:1.8em;*/ font-size:11px; margin:0; } .topNav { background-color:#4D7A97; color:#FFFFFF; float:left; padding:0; width:100%; clear:right; height:2.8em; padding-top:10px; overflow:hidden; font-size:12px; } .bottomNav { margin-top:10px; background-color:#4D7A97; color:#FFFFFF; float:left; padding:0; width:100%; clear:right; height:2.8em; padding-top:10px; overflow:hidden; font-size:12px; } .subNav { background-color:#dee3e9; float:left; width:100%; overflow:hidden; font-size:12px; } .subNav div { clear:left; float:left; padding:0 0 5px 6px; text-transform:uppercase; } ul.navList, ul.subNavList { float:left; margin:0 25px 0 0; padding:0; } ul.navList li{ list-style:none; float:left; padding: 5px 6px; text-transform:uppercase; } ul.subNavList li{ list-style:none; float:left; } .topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { color:#FFFFFF; text-decoration:none; text-transform:uppercase; } .topNav a:hover, .bottomNav a:hover { text-decoration:none; color:#bb7a2a; text-transform:uppercase; } .navBarCell1Rev { background-color:#F8981D; color:#253441; margin: auto 5px; } .skipNav { position:absolute; top:auto; left:-9999px; overflow:hidden; } /* Page header and footer styles */ .header, .footer { clear:both; margin:0 20px; padding:5px 0 0 0; } .indexHeader { margin:10px; position:relative; } .indexHeader span{ margin-right:15px; } .indexHeader h1 { font-size:13px; } .title { color:#2c4557; margin:10px 0; } .subTitle { margin:5px 0 0 0; } .header ul { margin:0 0 15px 0; padding:0; } .footer ul { margin:20px 0 5px 0; } .header ul li, .footer ul li { list-style:none; font-size:13px; } /* Heading styles */ div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { background-color:#dee3e9; border:1px solid #d0d9e0; margin:0 0 6px -8px; padding:7px 5px; } ul.blockList ul.blockList ul.blockList li.blockList h3 { background-color:#dee3e9; border:1px solid #d0d9e0; margin:0 0 6px -8px; padding:7px 5px; } ul.blockList ul.blockList li.blockList h3 { padding:0; margin:15px 0; } ul.blockList li.blockList h2 { padding:0px 0 20px 0; } /* Page layout container styles */ .contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { clear:both; padding:10px 20px; position:relative; } .indexContainer { margin:10px; position:relative; font-size:12px; } .indexContainer h2 { font-size:13px; padding:0 0 3px 0; } .indexContainer ul { margin:0; padding:0; } .indexContainer ul li { list-style:none; padding-top:2px; } .contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { font-size:12px; font-weight:bold; margin:10px 0 0 0; color:#4E4E4E; } .contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { margin:5px 0 10px 0px; font-size:14px; font-family:'DejaVu Sans Mono',monospace; } .serializedFormContainer dl.nameValue dt { margin-left:1px; font-size:1.1em; display:inline; font-weight:bold; } .serializedFormContainer dl.nameValue dd { margin:0 0 0 1px; font-size:1.1em; display:inline; } /* List styles */ ul.horizontal li { display:inline; font-size:0.9em; } ul.inheritance { margin:0; padding:0; } ul.inheritance li { display:inline; list-style:none; } ul.inheritance li ul.inheritance { margin-left:15px; padding-left:15px; padding-top:1px; } ul.blockList, ul.blockListLast { margin:10px 0 10px 0; padding:0; } ul.blockList li.blockList, ul.blockListLast li.blockList { list-style:none; margin-bottom:15px; line-height:1.4; } ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { padding:0px 20px 5px 10px; border:1px solid #ededed; background-color:#f8f8f8; } ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { padding:0 0 5px 8px; background-color:#ffffff; border:none; } ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { margin-left:0; padding-left:0; padding-bottom:15px; border:none; } ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { list-style:none; border-bottom:none; padding-bottom:0; } table tr td dl, table tr td dl dt, table tr td dl dd { margin-top:0; margin-bottom:1px; } /* Table styles */ .overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary { width:100%; border-left:1px solid #EEE; border-right:1px solid #EEE; border-bottom:1px solid #EEE; } .overviewSummary, .memberSummary { padding:0px; } .overviewSummary caption, .memberSummary caption, .typeSummary caption, .useSummary caption, .constantsSummary caption, .deprecatedSummary caption { position:relative; text-align:left; background-repeat:no-repeat; color:#253441; font-weight:bold; clear:none; overflow:hidden; padding:0px; padding-top:10px; padding-left:1px; margin:0px; white-space:pre; } .overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link, .useSummary caption a:link, .constantsSummary caption a:link, .deprecatedSummary caption a:link, .overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover, .useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover, .overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active, .useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active, .overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited, .useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited { color:#FFFFFF; } .overviewSummary caption span, .memberSummary caption span, .typeSummary caption span, .useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span { white-space:nowrap; padding-top:5px; padding-left:12px; padding-right:12px; padding-bottom:7px; display:inline-block; float:left; background-color:#F8981D; border: none; height:16px; } .memberSummary caption span.activeTableTab span { white-space:nowrap; padding-top:5px; padding-left:12px; padding-right:12px; margin-right:3px; display:inline-block; float:left; background-color:#F8981D; height:16px; } .memberSummary caption span.tableTab span { white-space:nowrap; padding-top:5px; padding-left:12px; padding-right:12px; margin-right:3px; display:inline-block; float:left; background-color:#4D7A97; height:16px; } .memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab { padding-top:0px; padding-left:0px; padding-right:0px; background-image:none; float:none; display:inline; } .overviewSummary .tabEnd, .memberSummary .tabEnd, .typeSummary .tabEnd, .useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd { display:none; width:5px; position:relative; float:left; background-color:#F8981D; } .memberSummary .activeTableTab .tabEnd { display:none; width:5px; margin-right:3px; position:relative; float:left; background-color:#F8981D; } .memberSummary .tableTab .tabEnd { display:none; width:5px; margin-right:3px; position:relative; background-color:#4D7A97; float:left; } .overviewSummary td, .memberSummary td, .typeSummary td, .useSummary td, .constantsSummary td, .deprecatedSummary td { text-align:left; padding:0px 0px 12px 10px; } th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th, td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{ vertical-align:top; padding-right:0px; padding-top:8px; padding-bottom:3px; } th.colFirst, th.colLast, th.colOne, .constantsSummary th { background:#dee3e9; text-align:left; padding:8px 3px 3px 7px; } td.colFirst, th.colFirst { white-space:nowrap; font-size:13px; } td.colLast, th.colLast { font-size:13px; } td.colOne, th.colOne { font-size:13px; } .overviewSummary td.colFirst, .overviewSummary th.colFirst, .useSummary td.colFirst, .useSummary th.colFirst, .overviewSummary td.colOne, .overviewSummary th.colOne, .memberSummary td.colFirst, .memberSummary th.colFirst, .memberSummary td.colOne, .memberSummary th.colOne, .typeSummary td.colFirst{ width:25%; vertical-align:top; } td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { font-weight:bold; } .tableSubHeadingColor { background-color:#EEEEFF; } .altColor { background-color:#FFFFFF; } .rowColor { background-color:#EEEEEF; } /* Content styles */ .description pre { margin-top:0; } .deprecatedContent { margin:0; padding:10px 0; } .docSummary { padding:0; } ul.blockList ul.blockList ul.blockList li.blockList h3 { font-style:normal; } div.block { font-size:14px; font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; } td.colLast div { padding-top:0px; } td.colLast a { padding-bottom:3px; } /* Formatting effect styles */ .sourceLineNo { color:green; padding:0 30px 0 0; } h1.hidden { visibility:hidden; overflow:hidden; font-size:10px; } .block { display:block; margin:3px 10px 2px 0px; color:#474747; } .deprecatedLabel, .descfrmTypeLabel, .memberNameLabel, .memberNameLink, .overrideSpecifyLabel, .packageHierarchyLabel, .paramLabel, .returnLabel, .seeLabel, .simpleTagLabel, .throwsLabel, .typeNameLabel, .typeNameLink { font-weight:bold; } .deprecationComment, .emphasizedPhrase, .interfaceName { font-style:italic; } div.block div.block span.deprecationComment, div.block div.block span.emphasizedPhrase, div.block div.block span.interfaceName { font-style:normal; } div.contentContainer ul.blockList li.blockList h2{ padding-bottom:0px; }

deprecated-list.html

JavaScript is disabled on your browser. Skip navigation links
  • Prev
  • Next

Deprecated API

Contents

Skip navigation links
  • Prev
  • Next

edu/vt/cs5044/tetris/package-frame.html

edu.vt.cs5044.tetris

Interfaces

Classes

Enums

edu/vt/cs5044/tetris/package-use.html

JavaScript is disabled on your browser. Skip navigation links
  • Prev
  • Next

Uses of Package edu.vt.cs5044.tetris

  • Classes in edu.vt.cs5044.tetris used by edu.vt.cs5044.tetris 
    Class and Description
    Board Represents a tetris game board, including all fixed blocks.
    Placement Represents a single possible placement of a shape within the well.
    RandomMode Represents the modes of randomness used for the game.
    Rotation Represents each of the four unique 90° rotations.
    Shape Represents each of the seven distinct tetromino shapes.
Skip navigation links
  • Prev
  • Next

edu/vt/cs5044/tetris/RandomMode.html

JavaScript is disabled on your browser. Skip navigation links edu.vt.cs5044.tetris

Enum RandomMode

  • All Implemented Interfaces:
    Serializable, Comparable< RandomMode>
    public enum RandomMode
    extends Enum<
                            RandomMode>
                        
    Represents the modes of randomness used for the game.

    This enum is only meaningful for the OPTIONAL portion of this assignment.

    • Enum Constant Summary

      Enum Constants 
      Enum Constant and Description
      NORMAL Stream of randomness for normal play.
      TEST1 Repeatable stream of randomness (variant 1).
      TEST2 Repeatable stream of randomness (variant 2).
      TEST3 Repeatable stream of randomness (variant 3).
      TEST4 Repeatable stream of randomness (variant 4).
    • Method Summary

      All Methods  Static Methods  Concrete Methods 
      Modifier and Type Method and Description
      static Set< RandomMode> getTestSet() Fetch the set of all test-related values.
      static RandomMode valueOf(String name) Returns the enum constant of this type with the specified name.
      static RandomMode[] values() Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • NORMAL
        public static final 
                                                RandomMode NORMAL
                                            
        Stream of randomness for normal play. This mode indicates a stream that is not repeatable.
      • TEST1
        public static final 
                                                RandomMode TEST1
                                            
        Repeatable stream of randomness (variant 1). This is to be used for testing purposes, to ensure consistent results.
      • TEST2
        public static final 
                                                RandomMode TEST2
                                            
        Repeatable stream of randomness (variant 2). This is to be used for testing purposes, to ensure consistent results.
      • TEST3
        public static final 
                                                RandomMode TEST3
                                            
        Repeatable stream of randomness (variant 3). This is to be used for testing purposes, to ensure consistent results.
      • TEST4
        public static final 
                                                RandomMode TEST4
                                            
        Repeatable stream of randomness (variant 4). This is to be used for testing purposes, to ensure consistent results.
    • Method Detail

      • values
        public static 
                                                RandomMode[] values()
                                            
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (RandomMode c : RandomMode.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf
        public static 
                                                RandomMode valueOf(String name)
                                            
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • getTestSet
        public static Set<
                                                RandomMode> getTestSet()
                                            
        Fetch the set of all test-related values. This set includes all RandomMode values except NORMAL.
        Returns:
        set of test-related values.
Skip navigation links

edu/vt/cs5044/tetris/package-summary.html

JavaScript is disabled on your browser. Skip navigation links
  • Prev Package
  • Next Package

Package edu.vt.cs5044.tetris

This package holds the various components of the Tetris 5044 game engine.

See:  Description

  • Interface Summary 
    Interface Description
    AI Interface the game engine uses to communicate with AI implementations.
  • Class Summary 
    Class Description
    Board Represents a tetris game board, including all fixed blocks.
    Placement Represents a single possible placement of a shape within the well.
    ShapeStream Generates a stream of random shapes for a tetris game.
    Tetris5044 Main class for Tetris 5044.
  • Enum Summary 
    Enum Description
    RandomMode Represents the modes of randomness used for the game.
    Rotation Represents each of the four unique 90° rotations.
    Shape Represents each of the seven distinct tetromino shapes.

Package edu.vt.cs5044.tetris Description

This package holds the various components of the Tetris 5044 game engine. Skip navigation links
  • Prev Package
  • Next Package

edu/vt/cs5044/tetris/Tetris5044.html

JavaScript is disabled on your browser. Skip navigation links
  • Summary: 
  • Nested | 
  • Field | 
  • Constr | 
  • Method
  • Detail: 
  • Field | 
  • Constr | 
  • Method
edu.vt.cs5044.tetris

Class Tetris5044

  • Object
    • Tetris5044
  • public class Tetris5044
    extends Object
    Main class for Tetris 5044.

    This class is only used to launch the graphical version of the game.

    Version:
    2022.Spring
    Author:
    Prof. Oliva
    • Method Summary

      All Methods  Static Methods  Concrete Methods 
      Modifier and Type Method and Description
      static void main(String[] args) Launches the Tetris 5044 application.
      • Methods inherited from class Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • main
        public static void main(String[] args)
        Launches the Tetris 5044 application.
        Parameters:
        args - currently ignored
Skip navigation links
  • Summary: 
  • Nested | 
  • Field | 
  • Constr | 
  • Method
  • Detail: 
  • Field | 
  • Constr | 
  • Method

edu/vt/cs5044/tetris/AI.html

JavaScript is disabled on your browser. Skip navigation links
  • Summary: 
  • Nested | 
  • Field | 
  • Constr | 
  • Method
  • Detail: 
  • Field | 
  • Constr | 
  • Method
edu.vt.cs5044.tetris

Interface AI

  • public interface AI
    Interface the game engine uses to communicate with AI implementations.

    ACADEMIC NOTE: You must develop an implementation of this interface.

    • Method Detail

      • findBestPlacement
                                                Placement findBestPlacement(
                                                Board currentBoard,
                                    
                                                Shape shape)
                                            
        Determine the best placement available for a shape in a board. All possible columns for all possible rotations of the given shape should be considered. For each combination, implementations should call Board.getResultBoard(Shape, Placement) to generate the resultant board after a hypothetical placement. The implementation must calculate a relative cost value for each resultant board, then return the Placement object associated with the lowest cost (most preferable).
        Parameters:
        currentBoard - the existing board.
        shape - the shape to be placed in the board.
        Returns:
        the best move as computed by the implementation.
      • getColumnHeightRange
        int getColumnHeightRange(
                                                Board board)
                                            
        Compute the range of column heights of a board (see academic note). Finds the height of the tallest and shortest columns within a board. Height is the based on the largest row number containing a block. Note that if the highest row containing a block in some column is r, the height of that column is r+1. Columns containing no blocks have a height of zero. The result is the difference between the tallest and shortest heights.

        As an example, the following board has a column height range of 2:

         |          |
         |          |
         |          |
         |## ##    #|
         |# ##### ##|
         |#### #####|
         |# ##### ##|
         |## #######|
         |######### |
         | #########|
         | #########|
         |###  #####|
         |####### ##|
         |######## #|
         | #### ####|
         +----------+
         

        ACADEMIC NOTE: This method would normally be declared as private. We're exposing it as public only for formal testing purposes.

        Parameters:
        board - the Board to evaluate.
        Returns:
        the difference in height between the tallest column and the shortest column.
      • getAverageColumnHeight
        int getAverageColumnHeight(
                                                Board board)
                                            
        Compute the average height of all the columns of a board (see academic note). Sums the total height of all columns of a board, then divides by the number of columns. Integer division is used, so the result is truncated. Height is the based on the largest row number containing a block. Note that if the highest row containing a block in some column is r, the height of that column is r+1. Columns containing no blocks have a height of zero.

        As an example, the following board has an average column height of 11:

         |          |
         |          |
         |          |
         |## ##    #|
         |# ##### ##|
         |#### #####|
         |# ##### ##|
         |## #######|
         |######### |
         | #########|
         | #########|
         |###  #####|
         |####### ##|
         |######## #|
         | #### ####|
         +----------+
         

        ACADEMIC NOTE: This method would normally be declared as private. We're exposing it as public only for formal testing purposes.

        Parameters:
        board - the Board to evaluate.
        Returns:
        the truncated average height of the columns.
      • getTotalGapCount
        int getTotalGapCount(
                                                Board board)
                                            
        Compute the total gap count of a board (see academic note). Counts the number of gaps residing within a board. A gap is a defined as any location without a block, where a block exists in any higher row of the same column.

        As an example, the following board has a total gap count of 14:

         |          |
         |          |
         |          |
         |## ##    #|
         |# ##### ##|
         |#### #####|
         |# ##### ##|
         |## #######|
         |######### |
         | #########|
         | #########|
         |###  #####|
         |####### ##|
         |######## #|
         | #### ####|
         +----------+
         

        ACADEMIC NOTE: This method would normally be declared as private. We're exposing it as public only for formal testing purposes.

        Parameters:
        board - the Board to evaluate.
        Returns:
        the number of gaps.
      • getColumnHeightVariance
        int getColumnHeightVariance(
                                                Board board)
                                            
        Compute the sum of variances of adjacent column heights (see academic note). Computes the sum of the absolute values of differences in heights of adjacent columns, as measured from either edge of the board to the other. Note that for a board of width w, there are w-1 adjacent column heights. Height is the based on the largest row number containing a block. Note that if the highest row containing a block in some column is r, the height of that column is r+1. Columns containing no blocks have a height of zero.

        As an example, the following board has a column height variance of 6:

         |          |
         |          |
         |          |
         |## ##    #|
         |# ##### ##|
         |#### #####|
         |# ##### ##|
         |## #######|
         |######### |
         | #########|
         | #########|
         |###  #####|
         |####### ##|
         |######## #|
         | #### ####|
         +----------+
         

        ACADEMIC NOTE: This method would normally be declared as private. We're exposing it as public only for formal testing purposes.

        Parameters:
        board - the Board to evaluate.
        Returns:
        the sum of variances of adjacent column heights.
Skip navigation links
  • Summary: 
  • Nested | 
  • Field | 
  • Constr | 
  • Method
  • Detail: 
  • Field | 
  • Constr | 
  • Method

edu/vt/cs5044/tetris/ShapeStream.html

JavaScript is disabled on your browser. Skip navigation links edu.vt.cs5044.tetris

Class ShapeStream

  • Object
    • ShapeStream
  • public class ShapeStream
    extends Object
    Generates a stream of random shapes for a tetris game.

    This class is only meaningful for the OPTIONAL portion of this assignment.

    • Constructor Summary

      Constructors 
      Constructor and Description
      ShapeStream( RandomMode mode) Construct a new ShapeStream in the specified RandomMode.
    • Method Summary

      All Methods  Instance Methods  Concrete Methods 
      Modifier and Type Method and Description
      Shape nextShape() Fetch the next random Shape from this stream.
      • Methods inherited from class Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ShapeStream
        public ShapeStream(
                                                RandomMode mode)
                                            
        Construct a new ShapeStream in the specified RandomMode.
        Parameters:
        mode - specifies the source of randomness for the stream; must not be null.
    • Method Detail

      • nextShape
        public 
                                                Shape nextShape()
                                            
        Fetch the next random Shape from this stream.
        Returns:
        the next random Shape from this stream.
Skip navigation links

edu/vt/cs5044/tetris/Board.html

JavaScript is disabled on your browser. Skip navigation links edu.vt.cs5044.tetris

Class Board

  • Object
    • Board
  • public class Board
    extends Object
    Represents a tetris game board, including all fixed blocks. This class is effectively immutable, because there are no public mutators.
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static int HEIGHT Height of the game board, in blocks.
      static int HEIGHT_LIMIT Height limit of the game board, in blocks.
      static int WIDTH Width of the game board, in blocks.
    • Constructor Summary

      Constructors 
      Constructor and Description
      Board() Construct a new empty board.
      Board(String... initialBlocks) Construct a new board with the specified initial blocks.
    • Method Summary

      All Methods  Instance Methods  Concrete Methods 
      Modifier and Type Method and Description
      boolean equals(Object obj) Test for equivalence with another Board.
      boolean[][] getFixedBlocks() Fetch a two-dimensional boolean array representing the fixed blocks of the board.
      Board getResultBoard( Shape shape, Placement place) Generate a new board that is the result of placing a new shape in this board.
      int hashCode() Hash code for this Board.
      String toString() Generate a multi-line ASCII art visualization of this board.
      • Methods inherited from class Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • WIDTH
        public static final int WIDTH
        Width of the game board, in blocks.
        See Also:
        Constant Field Values
      • HEIGHT
        public static final int HEIGHT
        Height of the game board, in blocks.
        See Also:
        Constant Field Values
      • HEIGHT_LIMIT
        public static final int HEIGHT_LIMIT
        Height limit of the game board, in blocks. If any block becomes fixed at or above this row index during normal play, the game ends.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Board
        public Board()
        Construct a new empty board. The constructed Board object will contain no fixed blocks.
      • Board
        public Board(String... initialBlocks)
        Construct a new board with the specified initial blocks. Specify a variable number of String values as arguments. Each String represents one row of the board.

        The last row specified is placed at the bottom (row index 0) of the board. No more than HEIGHT rows may be specified. If fewer rows are specified, the unspecified rows will be empty.

        Each row must have exactly WIDTH characters. The first character represents the left edge of the board. Each character must be either a space ' ' or a hash '#'. A hash means a single fixed block exists at that position. A space means no fixed block exists at that position.

        Parameters:
        initialBlocks - blocks to include in the board
    • Method Detail

      • getFixedBlocks
        public boolean[][] getFixedBlocks()
        Fetch a two-dimensional boolean array representing the fixed blocks of the board. The array is arranged such that the first index selects the column, and the second index selects the row. The left-most column is index 0, and the bottom-most row is index 0. The right-most column index is WIDTH - 1, and the top-most row index is HEIGHT - 1.

        A boolean value of true within the array indicates the presence of a fixed block at that location within the board; a false value within the array indicates there is no block present at that location

        As an example of using the returned value, array[3][1] will be true if there is a block present at the intersection of column index 3 (the fourth column, counting from the left) with row index 1 (the second row, counting from the bottom), or false if there is no block.

        NOTE: The returned array is mutable, but mutating it will not affect the Board object.

        Returns:
        a 2D boolean array representing the fixed columns of the board.
      • getResultBoard
        public 
                                                Board getResultBoard(
                                                Shape shape,
                                    
                                                Placement place)
                                            
        Generate a new board that is the result of placing a new shape in this board. First a copy of this board is created. The Shape is placed at the top of this copy, rotated according to the Placement rotation, then moved horizontally such that the left-most block is in the Placement column. The block is then dropped until it locks into place, then all completely full rows (if any) are cleared as in normal play. The copy, after this activity has been performed on it, is returned.

        Note: This method is NOT a mutator. It does not change the original Board object in any way.

        Parameters:
        shape - the Shape to place.
        place - a Placement containing the rotation and horizontal location for the shape.
        Returns:
        a new Board representing the result of the placement.
      • toString
        public String toString()
        Generate a multi-line ASCII art visualization of this board. The walls of the board are represented as '*' characters above the HEIGHT_LIMIT, and as '|' characters otherwise. The bottom of the board is represented by a row of '-' characters. Fixed blocks are represented by '#' characters; empty locations are represented by spaces. ACADEMIC NOTE: This is for troubleshooting purposes ONLY. This is NOT meant to be used for testing via JUnit, nor for the optional challenge.
        Overrides:
        toString in class Object
        Returns:
        a rudimentary ASCII art depiction of the board.
      • equals
        public boolean equals(Object obj)
        Test for equivalence with another Board. Two boards are equivalent if and only if they contain the same arrangement of fixed blocks. This method is consistent with the hashCode() implementation, and so is suitable for use within a HashSet or HashMap.
        Overrides:
        equals in class Object
        Parameters:
        obj - the other board object.
        Returns:
        true if the boards are equivalent; false otherwise.
      • hashCode
        public int hashCode()
        Hash code for this Board. The result is consistent with equals() and so Board objects are suitable for use within a HashSet or HashMap.
        Overrides:
        hashCode in class Object
        Returns:
        hash code for this Board object.
Skip navigation links

edu/vt/cs5044/tetris/Rotation.html

JavaScript is disabled on your browser. Skip navigation links edu.vt.cs5044.tetris

Enum Rotation

  • All Implemented Interfaces:
    Serializable, Comparable< Rotation>
    public enum Rotation
    extends Enum<
                            Rotation>
                        
    Represents each of the four unique 90° rotations.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant and Description
      CCW_180 Rotate 180° counter-clockwise.
      CCW_270 Rotate 270° counter-clockwise.
      CCW_90 Rotate 90° counter-clockwise.
      NONE No rotation; the default orientation.
    • Method Summary

      All Methods  Static Methods  Concrete Methods 
      Modifier and Type Method and Description
      static Rotation valueOf(String name) Returns the enum constant of this type with the specified name.
      static Rotation[] values() Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • NONE
        public static final 
                                                Rotation NONE
                                            
        No rotation; the default orientation.
      • CCW_90
        public static final 
                                                Rotation CCW_90
                                            
        Rotate 90° counter-clockwise.
      • CCW_180
        public static final 
                                                Rotation CCW_180
                                            
        Rotate 180° counter-clockwise.
      • CCW_270
        public static final 
                                                Rotation CCW_270
                                            
        Rotate 270° counter-clockwise.
    • Method Detail

      • values
        public static 
                                                Rotation[] values()
                                            
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Rotation c : Rotation.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf
        public static 
                                                Rotation valueOf(String name)
                                            
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
Skip navigation links

edu/vt/cs5044/tetris/Placement.html

JavaScript is disabled on your browser. Skip navigation links edu.vt.cs5044.tetris

Class Placement

  • Object
    • Placement
  • public class Placement
    extends Object
    Represents a single possible placement of a shape within the well. The placement is specified by a rotation, along with the horizontal location of the left-most block of the rotated shape. This class is immutable.
    • Constructor Summary

      Constructors 
      Constructor and Description
      Placement( Rotation rotation, int column) Construct a new Placement from the arguments provided.
    • Method Summary

      All Methods  Instance Methods  Concrete Methods 
      Modifier and Type Method and Description
      boolean equals(Object obj) Test for equivalence with another Placement.
      int getColumn() Fetch the specified column index.
      Rotation getRotation() Fetch the specified rotation.
      int hashCode() Hash code for this Placement.
      String toString() Generates a simple human-readable representation of this object.
      • Methods inherited from class Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Placement
        public Placement(
                                                Rotation rotation,
                         int column)
                                            
        Construct a new Placement from the arguments provided. The specified rotation is performed before the horizontal movement to the specified column.
        Parameters:
        rotation - specifies the rotation to be applied to the shape.
        column - left-most block of the rotated shape goes in this column index.
    • Method Detail

      • getRotation
        public 
                                                Rotation getRotation()
                                            
        Fetch the specified rotation.
        Returns:
        rotation.
      • getColumn
        public int getColumn()
        Fetch the specified column index. Note that the left-most column of the board is 0. The left-most block of the rotated shape goes in the specified column index.
        Returns:
        column.
      • toString
        public String toString()
        Generates a simple human-readable representation of this object.
        Overrides:
        toString in class Object
        Returns:
        simple representation of this object.
      • equals
        public boolean equals(Object obj)
        Test for equivalence with another Placement. Two placements are equivalent if and only if they contain the same column and same rotation values. This method is consistent with the hashCode() implementation, and so is suitable for use within a HashSet or HashMap.
        Overrides:
        equals in class Object
        Parameters:
        obj - the other placement.
        Returns:
        true if the placements are equivalent; false otherwise.
      • hashCode
        public int hashCode()
        Hash code for this Placement. The result is consistent with equals() and so Placement objects are suitable for use within a HashSet or HashMap.
        Overrides:
        hashCode in class Object
        Returns:
        hash code for this Placement object.
Skip navigation links

edu/vt/cs5044/tetris/Shape.html

JavaScript is disabled on your browser. Skip navigation links edu.vt.cs5044.tetris

Enum Shape

  • Object
  • All Implemented Interfaces:
    Serializable, Comparable< Shape>
    public enum Shape
    extends Enum<
                            Shape>
                        
    Represents each of the seven distinct tetromino shapes.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant and Description
      I The "I" shape.
      J The "J" shape.
      L The "L" shape.
      O The "O" shape.
      S The "S" shape.
      T The "T" shape.
      Z The "Z" shape.
    • Method Summary

      All Methods  Static Methods  Instance Methods  Concrete Methods 
      Modifier and Type Method and Description
      Set< Rotation> getValidRotationSet() Get the set of valid rotations for this shape.
      int getWidth( Rotation rotation) Get the width of this shape, in blocks, after applying a specified rotation.
      static Shape valueOf(String name) Returns the enum constant of this type with the specified name.
      static Shape[] values() Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • I
        public static final 
                                                Shape I
                                            
        The "I" shape. In the default orientation, it looks like this:
             #
             #
             #
             #
         
      • O
        public static final 
                                                Shape O
                                            
        The "O" shape. In the default orientation, it looks like this:
             ##
             ##
         
      • T
        public static final 
                                                Shape T
                                            
        The "T" shape. In the default orientation, it looks like this:
              #
             ###
         
      • J
        public static final 
                                                Shape J
                                            
        The "J" shape. In the default orientation, it looks like this:
              #
              #
             ##
         
      • L
        public static final 
                                                Shape L
                                            
        The "L" shape. In the default orientation, it looks like this:
             #
             #
             ##
         
      • S
        public static final 
                                                Shape S
                                            
        The "S" shape. In the default orientation, it looks like this:
             ##
            ##
         
      • Z
        public static final 
                                                Shape Z
                                            
        The "Z" shape. In the default orientation, it looks like this:
            ##
             ##
         
    • Method Detail

      • values
        public static 
                                                Shape[] values()
                                            
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Shape c : Shape.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf
        public static 
                                                Shape valueOf(String name)
                                            
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • getValidRotationSet
        public Set<
                                                Rotation> getValidRotationSet()
                                            
        Get the set of valid rotations for this shape. Returns a set of Rotation values that can be applied to this shape to result in distinct orientations.
        Returns:
        the a set of valid Rotation values.
      • getWidth
        public int getWidth(
                                                Rotation rotation)
                                            
        Get the width of this shape, in blocks, after applying a specified rotation. The rotation parameter must be contained in the Set returned by getValidRotationSet().
        Parameters:
        rotation - the rotation to apply.
        Returns:
        the width of the rotated shape, in blocks.
Skip navigation links

edu/vt/cs5044/tetris/class-use/RandomMode.html

JavaScript is disabled on your browser. Skip navigation links
  • Prev
  • Next

Uses of Class edu.vt.cs5044.tetris.RandomMode

Skip navigation links
  • Prev
  • Next

edu/vt/cs5044/tetris/class-use/Tetris5044.html

JavaScript is disabled on your browser. Skip navigation links
  • Prev
  • Next

Uses of Class edu.vt.cs5044.tetris.Tetris5044

No usage of edu.vt.cs5044.tetris.Tetris5044 Skip navigation links
  • Prev
  • Next

edu/vt/cs5044/tetris/class-use/AI.html

JavaScript is disabled on your browser. Skip navigation links
  • Prev
  • Next

Uses of Interface edu.vt.cs5044.tetris.AI

No usage of edu.vt.cs5044.tetris.AI Skip navigation links
  • Prev
  • Next

edu/vt/cs5044/tetris/class-use/ShapeStream.html

JavaScript is disabled on your browser. Skip navigation links
  • Prev
  • Next

Uses of Class edu.vt.cs5044.tetris.ShapeStream

No usage of edu.vt.cs5044.tetris.ShapeStream Skip navigation links
  • Prev
  • Next

edu/vt/cs5044/tetris/class-use/Board.html

JavaScript is disabled on your browser. Skip navigation links
  • Prev
  • Next

Uses of Class edu.vt.cs5044.tetris.Board

Skip navigation links
  • Prev
  • Next

edu/vt/cs5044/tetris/class-use/Rotation.html

JavaScript is disabled on your browser. Skip navigation links
  • Prev
  • Next

Uses of Class edu.vt.cs5044.tetris.Rotation

Skip navigation links
  • Prev
  • Next

edu/vt/cs5044/tetris/class-use/Placement.html

JavaScript is disabled on your browser. Skip navigation links
  • Prev
  • Next

Uses of Class edu.vt.cs5044.tetris.Placement

Skip navigation links
  • Prev
  • Next

edu/vt/cs5044/tetris/class-use/Shape.html

JavaScript is disabled on your browser. Skip navigation links
  • Prev
  • Next

Uses of Class edu.vt.cs5044.tetris.Shape

Skip navigation links
  • Prev
  • Next

script.js

function show(type) { count = 0; for (var key in methods) { var row = document.getElementById(key); if ((methods[key] & type) != 0) { row.style.display = ''; row.className = (count++ % 2) ? rowColor : altColor; } else row.style.display = 'none'; } updateTabs(type); } function updateTabs(type) { for (var value in tabs) { var sNode = document.getElementById(tabs[value][0]); var spanNode = sNode.firstChild; if (value == type) { sNode.className = activeTableTab; spanNode.innerHTML = tabs[value][1]; } else { sNode.className = tableTab; spanNode.innerHTML = "<a href=\"javascript:show("+ value + ");\">" + tabs[value][1] + "</a>"; } } }

index-all.html

JavaScript is disabled on your browser. Skip navigation links
  • Prev
  • Next
A  B  E  F  G  H  M  N  P  R  S  T  V  W 

A

AI - Interface in edu.vt.cs5044.tetris
Interface the game engine uses to communicate with AI implementations.

B

Board - Class in edu.vt.cs5044.tetris
Represents a tetris game board, including all fixed blocks.
Board() - Constructor for class Board
Construct a new empty board.
Board(String...) - Constructor for class Board
Construct a new board with the specified initial blocks.

E

edu.vt.cs5044.tetris - package edu.vt.cs5044.tetris
This package holds the various components of the Tetris 5044 game engine.
equals(Object) - Method in class Board
Test for equivalence with another Board.
equals(Object) - Method in class Placement
Test for equivalence with another Placement.

F

findBestPlacement(Board, Shape) - Method in interface AI
Determine the best placement available for a shape in a board.

G

getAverageColumnHeight(Board) - Method in interface AI
Compute the average height of all the columns of a board (see academic note).
getColumn() - Method in class Placement
Fetch the specified column index.
getColumnHeightRange(Board) - Method in interface AI
Compute the range of column heights of a board (see academic note).
getColumnHeightVariance(Board) - Method in interface AI
Compute the sum of variances of adjacent column heights (see academic note).
getFixedBlocks() - Method in class Board
Fetch a two-dimensional boolean array representing the fixed blocks of the board.
getResultBoard(Shape, Placement) - Method in class Board
Generate a new board that is the result of placing a new shape in this board.
getRotation() - Method in class Placement
Fetch the specified rotation.
getTestSet() - Static method in enum RandomMode
Fetch the set of all test-related values.
getTotalGapCount(Board) - Method in interface AI
Compute the total gap count of a board (see academic note).
getValidRotationSet() - Method in enum Shape
Get the set of valid rotations for this shape.
getWidth(Rotation) - Method in enum Shape
Get the width of this shape, in blocks, after applying a specified rotation.

H

hashCode() - Method in class Board
Hash code for this Board.
hashCode() - Method in class Placement
Hash code for this Placement.
HEIGHT - Static variable in class Board
Height of the game board, in blocks.
HEIGHT_LIMIT - Static variable in class Board
Height limit of the game board, in blocks.

M

main(String[]) - Static method in class Tetris5044
Launches the Tetris 5044 application.

N

nextShape() - Method in class ShapeStream
Fetch the next random Shape from this stream.

P

Placement - Class in edu.vt.cs5044.tetris
Represents a single possible placement of a shape within the well.
Placement(Rotation, int) - Constructor for class Placement
Construct a new Placement from the arguments provided.

R

RandomMode - Enum in edu.vt.cs5044.tetris
Represents the modes of randomness used for the game.
Rotation - Enum in edu.vt.cs5044.tetris
Represents each of the four unique 90° rotations.

S

Shape - Enum in edu.vt.cs5044.tetris
Represents each of the seven distinct tetromino shapes.
ShapeStream - Class in edu.vt.cs5044.tetris
Generates a stream of random shapes for a tetris game.
ShapeStream(RandomMode) - Constructor for class ShapeStream
Construct a new ShapeStream in the specified RandomMode.

T

Tetris5044 - Class in edu.vt.cs5044.tetris
Main class for Tetris 5044.
toString() - Method in class Board
Generate a multi-line ASCII art visualization of this board.
toString() - Method in class Placement
Generates a simple human-readable representation of this object.

V

valueOf(String) - Static method in enum RandomMode
Returns the enum constant of this type with the specified name.
valueOf(String) - Static method in enum Rotation
Returns the enum constant of this type with the specified name.
valueOf(String) - Static method in enum Shape
Returns the enum constant of this type with the specified name.
values() - Static method in enum RandomMode
Returns an array containing the constants of this enum type, in the order they are declared.
values() - Static method in enum Rotation
Returns an array containing the constants of this enum type, in the order they are declared.
values() - Static method in enum Shape
Returns an array containing the constants of this enum type, in the order they are declared.

W

WIDTH - Static variable in class Board
Width of the game board, in blocks.
A  B  E  F  G  H  M  N  P  R  S  T  V  W  Skip navigation links
  • Prev
  • Next

package-list

edu.vt.cs5044.tetris

allclasses-noframe.html

All Classes