codesimian
Class PuyoGame

java.lang.Object
  extended by codesimian.PuyoGame

public class PuyoGame
extends java.lang.Object

Puyo (a game like Tetris) is made mostly of CodeSimian code. That code sometimes uses reflection to call Java functions, like the function(s) in this class.


Constructor Summary
PuyoGame()
           
 
Method Summary
static int[] biggestGroupOfSquares(CS[] listOfSquares, int squaresWide, java.lang.String fileNameOfEmptySquare)
          Chooses which squares to delete (you should replace them with pictures of empty squares).
static boolean changeAllOfOneFileNameToAnOther(CS[] listOfSquares, java.lang.String fileNameFrom, java.lang.String fileNameTo)
          example: change all filenames 'redFace.jpg' to 'empty.jpg' to delete all the redFace squares.
static int deleteByKeywordOrName(CS listOfSquares, java.lang.String keywordOrNameOfACSToDelete, CS replaceWithACopyOfMe)
          returns how many CSs were deleted from listOfSquares (and replaced with replaceWith)
static int[] getAdjacentSquares(int totalSquares, int squaresWide, int squareIndex)
          Returns the indexs of the squares adjacent to squareIndex.
static boolean reverse(CS list)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PuyoGame

public PuyoGame()
Method Detail

biggestGroupOfSquares

public static int[] biggestGroupOfSquares(CS[] listOfSquares,
                                          int squaresWide,
                                          java.lang.String fileNameOfEmptySquare)
Chooses which squares to delete (you should replace them with pictures of empty squares).

SUMMARY, WHAT I WROTE BEFORE BUILDING THIS FUNCTION:
Array of booleans, all start at false. For each square, check all 4 directions to see if its the same color, but if the adjacent square's boolean is true then ignore it, and if any are the same color, push the new square onto a stack and continue from it. Find groups of adjacent squares that are the same color. Do not save the groups, but when you find the right one, return it. Return the biggest group.

Parameters:
listOfSquares[] - the squares on the game board, same as CodeSimian.Squares.P(0)
squaresWide - a 1-dimensional array is being used as a 2-dimensional array. How many squares per row?
fileNameOfEmptySquare - is needed so groups of adjacent empty squares will not be returned.
Returns:
indexs of the group of squares that should be deleted next. Returns an empty array if no squares should be deleted. Does not return ALL groups. Get the first group, delete it, then call this again to get other groups.

getAdjacentSquares

public static int[] getAdjacentSquares(int totalSquares,
                                       int squaresWide,
                                       int squareIndex)
Returns the indexs of the squares adjacent to squareIndex. There will be 2, 3, or 4 adjacent squares, depending on which edges the square touches. Board must be at least 2x2.


changeAllOfOneFileNameToAnOther

public static boolean changeAllOfOneFileNameToAnOther(CS[] listOfSquares,
                                                      java.lang.String fileNameFrom,
                                                      java.lang.String fileNameTo)
example: change all filenames 'redFace.jpg' to 'empty.jpg' to delete all the redFace squares.


deleteByKeywordOrName

public static int deleteByKeywordOrName(CS listOfSquares,
                                        java.lang.String keywordOrNameOfACSToDelete,
                                        CS replaceWithACopyOfMe)
returns how many CSs were deleted from listOfSquares (and replaced with replaceWith)


reverse

public static boolean reverse(CS list)