bot.gen
Class Gen

java.lang.Object
  extended bybot.gen.Gen

public class Gen
extends Object

This is a utility class that takes boards and does stuff to them.


Constructor Summary
Gen()
           
 
Method Summary
static Square acidLine(Board b, int sx, int sy, int dx, int dy, int len)
          Draw a line len units long starting at sx, sy going dx,dy per step.
static void addSquare(Board b, int xcor, int ycor)
          Add a square at given coordinates.
static void addSquare(Board b, int x, int y, Actor a)
          Add square with given actor in it.
static void addSquare(Board b, int x, int y, Thing t)
          Add square with given thing in it.
static void addSquare(Board b, Point p)
          Add a square at given coordinates.
static void addSquare(Board b, Point p, Thing t)
          Add a square at given coordinates.
static Square drawBranch(Board board, int sx, int sy, int branchLength)
          Starting at sx,sy wander around randomly in branchLength segments from the origin.
static Square getRandomEvenSquare(Board b)
          Nab a square with coordinates that are even numbers.
static Square getRandomSquare(Board b, boolean need_empty)
           
static void landAtOrigin(Board board)
          Make starting spot the origin.
static Square line(Board b, int sx, int sy, int dir, int len)
          Draw a line len units long starting at sx, sy going dir Take len steps.
static Square line(Board b, int sx, int sy, int dx, int dy, int len)
          Draw a line len units long starting at sx, sy going dx,dy per step.
static Thing makeRandomThing()
           
static Thing makeRandomThing(boolean danger)
          Generate a random object.
static Thing makeRandomThing(String[] objects)
           
static void moveOut(Board b, Square s)
          Randomly place any actor or thing currently on the given square so the square is empty.
static int numEmptiesNextdoor(Board b, Point p)
          Return number of non-wall squares next to where the given square is.
static void place(Board b, int x, int y, Thing t)
          Place thing at given coordinates.
static void placeRandomThings(Board board, int num)
           
static void randomActorPlace(Board b, Actor thing)
           
static void randomKeyPlace(Board b)
          Place key on random square in board (that does not have anything else there
static void randomThingPlace(Board b, Thing thing)
           
static void setActor(Board b, int x, int y, Actor a)
          Place thing at given coordinates.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Gen

public Gen()
Method Detail

line

public static Square line(Board b,
                          int sx,
                          int sy,
                          int dir,
                          int len)
Draw a line len units long starting at sx, sy going dir Take len steps. Includes first step, and the last. (So # squares added is len + 1)

Returns:
last square placed

line

public static Square line(Board b,
                          int sx,
                          int sy,
                          int dx,
                          int dy,
                          int len)
Draw a line len units long starting at sx, sy going dx,dy per step. Take len steps. Includes first step, and the last. (So # squares added is len + 1)

Returns:
last square placed

acidLine

public static Square acidLine(Board b,
                              int sx,
                              int sy,
                              int dx,
                              int dy,
                              int len)
Draw a line len units long starting at sx, sy going dx,dy per step. Put acid in each square. Take len steps. Includes first step, and the last. (So # squares added is len + 1)

Returns:
last square placed

addSquare

public static void addSquare(Board b,
                             int xcor,
                             int ycor)
Add a square at given coordinates.


addSquare

public static void addSquare(Board b,
                             Point p)
Add a square at given coordinates.


addSquare

public static void addSquare(Board b,
                             Point p,
                             Thing t)
Add a square at given coordinates.


addSquare

public static void addSquare(Board b,
                             int x,
                             int y,
                             Thing t)
Add square with given thing in it.


addSquare

public static void addSquare(Board b,
                             int x,
                             int y,
                             Actor a)
Add square with given actor in it.


drawBranch

public static Square drawBranch(Board board,
                                int sx,
                                int sy,
                                int branchLength)
Starting at sx,sy wander around randomly in branchLength segments from the origin.

Returns:
last square reached

getRandomSquare

public static Square getRandomSquare(Board b,
                                     boolean need_empty)

getRandomEvenSquare

public static Square getRandomEvenSquare(Board b)
Nab a square with coordinates that are even numbers.


landAtOrigin

public static void landAtOrigin(Board board)
Make starting spot the origin.


randomKeyPlace

public static void randomKeyPlace(Board b)
Place key on random square in board (that does not have anything else there


randomThingPlace

public static void randomThingPlace(Board b,
                                    Thing thing)

randomActorPlace

public static void randomActorPlace(Board b,
                                    Actor thing)

moveOut

public static void moveOut(Board b,
                           Square s)
Randomly place any actor or thing currently on the given square so the square is empty.


place

public static void place(Board b,
                         int x,
                         int y,
                         Thing t)
Place thing at given coordinates. Square must exist and be blank.


setActor

public static void setActor(Board b,
                            int x,
                            int y,
                            Actor a)
Place thing at given coordinates. Square must exist and be blank.


numEmptiesNextdoor

public static int numEmptiesNextdoor(Board b,
                                     Point p)
Return number of non-wall squares next to where the given square is.


placeRandomThings

public static void placeRandomThings(Board board,
                                     int num)

makeRandomThing

public static Thing makeRandomThing()

makeRandomThing

public static Thing makeRandomThing(boolean danger)
Generate a random object. True means the object could be a bomb or other dangerous thing to interact with. False means the object is fully safe.

Parameters:
danger -
Returns:
A brand new thing.

makeRandomThing

public static Thing makeRandomThing(String[] objects)