I need help on a maze game...

I need to create a maze game, consist of a 14x18 grid that contains various obstacles. At the beginning of the game, the player is positioned at the upper left-hand corner of the grid. Each space of the board may have one of the following items in it: an immovable block, a moveable block, a bomb, or nothing. The items in the game have the following behavior:
1. The player is controlled by the user. The player may move up, down, left, or right.
2. An empty space is empty. Anything may move into an empty space.
3. An immovable block cannot move. Nothing may move the grid space that an immovable block occupies.
4. A moveable block can be pushed by the user. It cannot be pushed off of the grid. It cannot be pushed onto a space that an immovable block occupies. A movable block can be pushed into a space that is occupied by another moveable block provided that the second moveable block can move in turn.
5. A bomb space looks just like an empty space, however it's behavior is quite different. Only when something moves into its space does it become visible. If a player moves into the space, the bomb explodes, killing the player. If a moveable piece is moved into a bomb space, the bomb becomes visible. The bomb will still be active, meaning a player will still want to avoid this grid location.
The goal of the game is for the player to move from the upper left-hand corner to any grid location in the rightmost column. The player is moved by the input entered by the user.
So far, I have succesfully made the Simple console input for this game. The source code is as following.
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class SimpleConsoleInput
* Get a single character from the user
* @return value entered by the user
public char getChar()
BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 1);
System.out.print(":");
// Declare and initialize the char
char character = ' ';
// Get the character from the keyboard
boolean successfulInput = false;
while( !successfulInput )
try
character = (char) br.read();
successfulInput = true;
catch (NumberFormatException ex)
System.out.println("Please enter a character: ");
catch(Exception ex)
System.out.println(ex);
System.exit(0);
// Return the character obtained from the keyboard
return character;
* Get a single character from the user
* @return value entered by the user
* @param prompt - String to prompt the user with
public char getChar(String prompt)
BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 1);
System.out.print(prompt + ":");
// Declare and initialize the char
char character = ' ';
// Get the character from the keyboard
boolean successfulInput = false;
while( !successfulInput )
try
character = (char) br.read();
successfulInput = true;
catch (NumberFormatException ex)
System.out.println("Please enter a character: ");
catch(Exception ex)
System.out.println(ex);
System.exit(0);
// Return the character obtained from the keyboard
return character;
* Get a double from the user
* @return value entered by the user
public double getDouble()
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print(":");
// Declare and initialize the double
double number = 0.0;
// Get the number from the keyboard
boolean successfulInput = false;
while( !successfulInput )
try
String line = br.readLine();
number = Double.parseDouble(line);
successfulInput = true;
catch (NumberFormatException ex)
System.out.println("Please enter a double: ");
catch(Exception ex)
System.out.println(ex);
System.exit(0);
// Return the number obtained from the keyboard
return number;
* Get a double from the user
* @return value entered by the user
* @param prompt - String to prompt the user with
public double getDouble(String prompt)
BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 1);
System.out.print(prompt + ":");
// Declare and initialize the double
double number = 0.0;
// Get the number from the keyboard
boolean successfulInput = false;
while( !successfulInput )
try
String line = br.readLine();
number = Double.parseDouble(line);
successfulInput = true;
catch (NumberFormatException ex)
System.out.println("Please enter a double: ");
catch(Exception ex)
System.out.println(ex);
System.exit(0);
// Return the number obtained from the keyboard
return number;
* Get an int from the user
* @return value entered by the user
public int getInt()
BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 1);
System.out.print(":");
// Declare and initialize the int
int number = 0;
// Get the number from the keyboard
boolean successfulInput = false;
while( !successfulInput )
try
String line = br.readLine();
number = Integer.parseInt(line);
successfulInput = true;
catch (NumberFormatException ex)
System.out.println("Please enter an integer: ");
catch(Exception ex)
System.out.println(ex);
System.exit(0);
// Return the number obtained from the keyboard
return number;
* Get an int from the user
* @return value entered by the user
* @param prompt - String to prompt the user with
public int getInt(String prompt)
BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 1);
System.out.print(prompt + ":");
// Declare and initialize the int
int number = 0;
// Get the number from the keyboard
boolean successfulInput = false;
while( !successfulInput )
try
String line = br.readLine();
number = Integer.parseInt(line);
successfulInput = true;
catch (NumberFormatException ex)
System.out.println("Please enter an integer: ");
catch(Exception ex)
System.out.println(ex);
System.exit(0);
// Return the number obtained from the keyboard
return number;
* Get a String from the user
* @return value entered by the user
public String getString()
BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
System.out.print(":");
String name = null;
// Get the string from the keyboard
boolean successfulInput = false;
while( !successfulInput )
try
name = console.readLine();
successfulInput = true;
catch (NumberFormatException ex)
System.out.println("Please enter a string: ");
catch(Exception ex)
System.out.println(ex);
System.exit(0);
return name;
* Get a String from the user
* @return value entered by the user
* @param prompt - String to prompt the user with
public String getString(java.lang.String prompt)
BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
System.out.print(prompt + ":");
String name = null;
// Get the string from the keyboard
boolean successfulInput = false;
while( !successfulInput )
try
name = console.readLine();
successfulInput = true;
catch (NumberFormatException ex)
System.out.println("Please enter a string: ");
catch(Exception ex)
System.out.println(ex);
System.exit(0);
return name;
* The main program for the SimpleInput class
* @param args - The command line arguments
public static void main(java.lang.String[] args)
SimpleConsoleInput i = new SimpleConsoleInput();
i.getString("Please Enter an Integer for me");
Now is the bard part for me...
I need to generate a random maze wioth those items. So far I can only make the maze using a template. The part of maze generator is given below...
public class Maze extends Applet {
String levels[] = {
"M^^^^#####" +
"M^^^^# #" +
"M^^^^#$ #" +
"M^^### $##" +
"M^^# $ $ #" +
"M### # ## #^^^######" +
"M# # ## ##### ..#" +
"M# $ $ ..#" +
"M##### ### #@## ..#" +
"M^^^^# #########" +
"M^^^^#######",
"M############" +
"M#.. # ###" +
"M#.. # $ $ #" +
"M#.. #$#### #" +
"M#.. @ ## #" +
"M#.. # # $ ##" +
"M###### ##$ $ #" +
"M^^# $ $ $ $ #" +
"M^^# # #" +
"M^^############",
"M^^^^^^^^########" +
"M^^^^^^^^# @#" +
"M^^^^^^^^# $#$ ##" +
"M^^^^^^^^# $ $#" +
"M^^^^^^^^##$ $ #" +
"M######### $ # ###" +
"M#.... ## $ $ #" +
"M##... $ $ #" +
"M#.... ##########" +
"M########M",
"M^^^^^^^^^^^########" +
"M^^^^^^^^^^^# ....#" +
"M############ ....#" +
"M# # $ $ ....#" +
"M# $$$#$ $ # ....#" +
"M# $ $ # ....#" +
"M# $$ #$ $ $########" +
"M# $ # #" +
"M## #########" +
"M# # ##" +
"M# $ ##" +
"M# $$#$$ @#" +
"M# # ##" +
"M###########",
"M^^^^^^^^#####" +
"M^^^^^^^^# #####" +
"M^^^^^^^^# #$## #" +
"M^^^^^^^^# $ #" +
"M######### ### #" +
"M#.... ## $ $###" +
"M#.... $ $$ ##" +
"M#.... ##$ $ @#" +
"M######### $ ##" +
"M^^^^^^^^# $ $ #" +
"M^^^^^^^^### ## #" +
"M^^^^^^^^^^# #" +
"M^^^^^^^^^^######",
"M######^^###" +
"M#.. #^##@##" +
"M#.. ### #" +
"M#.. $$ #" +
"M#.. # # $ #" +
"M#..### # $ #" +
"M#### $ #$ #" +
"M^^^# $# $ #" +
"M^^^# $ $ #" +
"M^^^# ## #" +
"M^^^#########",
"M^^^^^^^#####" +
"M^####### ##" +
"M## # @## $$ #" +
"M# $ #" +
"M# $ ### #" +
"M### #####$###" +
"M# $ ### ..#" +
"M# $ $ $ ...#" +
"M# ###...#" +
"M# $$ #^#...#" +
"M# ###^#####" +
"M####",
"M^^^^^^^^^^#######" +
"M^^^^^^^^^^# ...#" +
"M^^^^^^##### ...#" +
"M^^^^^^# . .#" +
"M^^^^^^# ## ...#" +
"M^^^^^^## ## ...#" +
"M^^^^^### ########" +
"M^^^^^# $$$ ##" +
"M^##### $ $ #####" +
"M## #$ $ # #" +
"M#@ $ $ $ $ #" +
"M###### $$ $ #####" +
"M^^^^^# #" +
"M^^^^^########",
"M^###^^#############" +
"M##@#### # #" +
"M# $$ $$ $ $ ...#" +
"M# $$$# $ #...#" +
"M# $ # $$ $$ #...#" +
"M### # $ #...#" +
"M# # $ $ $ #...#" +
"M# ###### ###...#" +
"M## # # $ $ #...#" +
"M# ## # $$ $ $##..#" +
"M# ..# # $ #.#" +
"M# ..# # $$$ $$$ #.#" +
"M##### # # #.#" +
"M^^^^# ######### #.#" +
"M^^^^# #.#" +
"M^^^^###############",
"M^^^^^^^^^^####" +
"M^^^^^####^# #" +
"M^^^### @###$ #" +
"M^^## $ #" +
"M^## $ $$## ##" +
"M^# #$## #" +
"M^# # $ $$ # ###" +
"M^# $ # # $ #####" +
"M#### # $$ # #" +
"M#### ## $ #" +
"M#. ### ########" +
"M#.. ..#^####" +
"M#...#.#" +
"M#.....#" +
"M#######",
"M^^####" +
"M^^# ###########" +
"M^^# $ $ $ #" +
"M^^# $# $ # $ #" +
"M^^# $ $ # #" +
"M### $# # #### #" +
"M#@#$ $ $ ## #" +
"M# $ #$# # #" +
"M# $ $ $ $ #" +
"M^#### #########" +
"M^^# #" +
"M^^# #" +
"M^^#......#" +
"M^^#......#" +
"M^^#......#" +
"M^^########",
"M################" +
"M# #" +
"M# # ###### #" +
"M# # $ $ $ $# #" +
"M# # $@$ ## ##" +
"M# # $ $ $###...#" +
"M# # $ $ ##...#" +
"M# ###$$$ $ ##...#" +
"M# # ## ##...#" +
"M##### ## ##...#" +
"M^^^^##### ###" +
"M^^^^^^^^# #" +
"M^^^^^^^^#######",
"M^^^#########" +
"M^^## ## #####" +
"M### # # ###" +
"M# $ #$ # # ... #" +
"M# # $#@$## # #.#. #" +
"M# # #$ # . . #" +
"M# $ $ # # #.#. #" +
"M# ## ##$ $ . . #" +
"M# $ # # #$#.#. #" +
"M## $ $ $ $... #" +
"M^#$ ###### ## #" +
"M^# #^^^^##########" +
"M^####",
"M^^^^^^^#######" +
"M^####### #" +
"M^# # $@$ #" +
"M^#$$ # #########" +
"M^# ###......## #" +
"M^# $......## # #" +
"M^# ###...... #" +
"M## #### ### #$##" +
"M# #$ # $ # #" +
"M# $ $$$ # $## #" +
"M# $ $ ###$$ # #" +
"M##### $ # #" +
"M^^^^### ### # #" +
"M^^^^^^# # #" +
"M^^^^^^######## #" +
"M^^^^^^^^^^^^^####",
"M^^^^#######" +
"M^^^# # #" +
"M^^^# $ #" +
"M^### #$ ####" +
"M^# $ ##$ #" +
"M^# # @ $ # $#" +
"M^# # $ ####" +
"M^## ####$## #" +
"M^# $#.....# # #" +
"M^# $..**. $# ###" +
"M## #.....# #" +
"M# ### #######" +
"M# $$ # #" +
"M# # #" +
"M###### #" +
"M^^^^^#####",
"M#####" +
"M# ##" +
"M# #^^####" +
"M# $ #### #" +
"M# $$ $ $#" +
"M###@ #$ ##" +
"M^# ## $ $ ##" +
"M^# $ ## ## .#" +
"M^# #$##$ #.#" +
"M^### $..##.#" +
"M^^# #.*...#" +
"M^^# $$ #.....#" +
"M^^# #########" +
"M^^# #" +
"M^^####",
"M^^^##########" +
"M^^^#.. # #" +
"M^^^#.. #" +
"M^^^#.. # ####" +
"M^^####### # ##" +
"M^^# #" +
"M^^# # ## # #" +
"M#### ## #### ##" +
"M# $ ##### # #" +
"M# # $ $ # $ #" +
"M# @$ $ # ##" +
"M#### ## #######" +
"M^^^# #" +
"M^^^######",
"M^^^^^###########" +
"M^^^^^# . # #" +
"M^^^^^# #. @ #" +
"M^##### ##..# ####" +
"M## # ..### ###" +
"M# $ #... $ # $ #" +
"M# .. ## ## ## #" +
"M####$##$# $ # # #" +
"M^^## # #$ $$ # #" +
"M^^# $ # # # $## #" +
"M^^# #" +
"M^^# ########### #" +
"M^^####^^^^^^^^^####",
"M^^######" +
"M^^# @####" +
"M##### $ #" +
"M# ## ####" +
"M# $ # ## #" +
"M# $ # ##### #" +
"M## $ $ # #" +
"M## $ $ ### # #" +
"M## # $ # # #" +
"M## # #$# # #" +
"M## ### # # ######" +
"M# $ #### # #....#" +
"M# $ $ ..#.#" +
"M####$ $# $ ....#" +
"M# # ## ....#" +
"M###################",
"M^^^^##########" +
"M##### ####" +
"M# # $ #@ #" +
"M# #######$#### ###" +
"M# # ## # #$ ..#" +
"M# # $ # # #.#" +
"M# # $ # #$ ..#" +
"M# # ### ## #.#" +
"M# ### # # #$ ..#" +
"M# # # #### #.#" +
"M# #$ $ $ #$ ..#" +
"M# $ # $ $ # #.#" +
"M#### $### #$ ..#" +
"M^^^# $$ ###....#" +
"M^^^# ##^######" +
"M^^^########"
final static char wall = '#';
final static char floor = ' ';
final static char me = '@';
final static char bomb = '&';
final static char movableBlock = '*';
final static char goal = '.';
Would someone please help me on this game...

More information about this game:
The game should generate a random obstacle course for the player. The first column of the grid, however, should consist of all empty pieces, with the exception of the upper left-hand corner, which is the grid location where the player initially resides.
Enter a loop in which the following things happen (not necessarily in this order):
Print the current board configuration. Additionally, a key should be printed describing what each piece is.
Get an action from the user. The player can move up, down, left, or right. Use the following controls: up = 'i', down = 'm', left = 'j', right = 'k'. The player can move at most one block at a time. Of course, if the player tries to move into a spot occupied by an immovable block, the player will not move.
Inform the player whether they have won, or if they have lost (a player loses if they step on a bomb piece).
If the player types 'q', the game should terminate.
I am still stuck on this maze generator stuff.... Please help me....

Similar Messages

  • HT203200 I need help on purchasing a game I forgot my security question answers. and it's been awhile since I downloaded anything.. how do I find out the answers or change them without knowing the old answers??

    I need help on purchasing a game I forgot my security question answers. and it's been awhile since I downloaded anything.. how do I find out the answers or change them without knowing the old answers??

    Alternatives for Help Resetting Security Questions and Rescue Mail
         1. Apple ID- All about Apple ID security questions.
         2. Rescue email address and how to reset Apple ID security questions
         3. Apple ID- Contacting Apple for help with Apple ID account security.
         4. Fill out and submit this form. Select the topic, Account Security.
         5.  Call Apple Customer Service: Contacting Apple for support in your
              country and ask to speak to Account Security.
    How to Manage your Apple ID: Manage My Apple ID

  • Hello need help I download a game from 4shared and it an iPhone game . It show up and my iTunes but I can't sync it to my phone I need help

    Hello need help I download a game from 4shared and it an iPhone game . It show up and my iTunes but I can't sync it to my phone I need help

    Wowowowow I was told I can get any app from the net and it will work thank

  • Need help with ending a game

    i'm making a game at the moment.......
    i need help with a way to check all the hashmaps of enimies in a class called room......i need to check if they all == 0...when they all equal zero the game ends......
    i know i can check the size of a hash map with size().....but i want to check if all the hashmaps within all the rooms == 0.

    First of all stop cross posting. These values in the HashMap, they are a "Collection" of values, so what is wrong with reply two and putting all these collections of values into a super collection? A collection of collections? You can have a HashMap of HashMaps. One HashMap that holds all your maps and then you can use a for loop to check if they are empty. A map is probably a bad choice for this operation as you don't need a key and an array will be much faster.
    HashMap [] allMaps = {new HashMap(),new HashMap()};

  • Need help for my "pairs" game! Do Help me!

    Hi
    Will somebody help me about my midterm project? I am about to make a static game called pairs...Now the first thing i need to know is "how to create a two dimensional array of JButtons?" I already know how to make some GUI components like menus, radio buttons..etc. I also got my images ready..another problem is how to use math random to randomly assign the images to the buttons. I really need help and I'm new here. Will somebody show me a very very simple code of this game. pls do help. Im 17 yrs old and new in programming.
    my email: [email protected]
    All help is appreciated.

    Don't cross-post.
    No, we won't do your homework for you.
    Nobody cares how old you are or how new you are to programming.
    When is this due?
    %

  • I need help: hunt the wumpus game

    i'm trying to write the hunt the wumpus game with simple conditions: (check-marked the ones i already accomplished)
    [x]the pits will be placed randomly
    [x] the wumpus is placed in the maze randomly (not sure if i did that one correctly)
    [x] the player starts on the lower left of the maze row 3 col 0
    -the player will only have 1 chance to shoot the Wumpus
    [x]if the player is close to the Wumpus then there would be a prompt saying there is stench around
    [x]if the player is close to a pit then she/he will be prompted that there is a breeze.
    -if the player falls in a pit or gets eaten by the wumpus the game will be over and the map of the maze will be shown. I used 0 for empty cells and p for pits and w for wumpus in the array.
    There is some problem with the program i've written so far but i don't know how to fix it. also, i don't know how to check if the wumpus will be in the direction the player wants to shoot. i'd appreciate any suggestions
    import java.util.*;
    public class playWumpus
        //initMaze METHOD
        //put the pits and wumpus into the world
        public static void initMaze(char [][] maze)
            Random r = new Random();
            for (int row = 0; row <4; row ++)
                maze[row][col] = '0';    <<<<<<there is a problem here: col cannot be resolved
            int pitRow, pitCol;
            for (int pitNum = 0; pitNum <4; pitNum++)
                pitRow = r.nextInt(4); //randomly choose row
                pitCol = r.nextInt(6); //randomly choose column
                if (pitRow == 3 && pitCol == 0)//start location
                    pitCol=5;
            maze [pitRow][pitCol] = 'p'; //places the pits in the maze randomly
            maze [r.nextInt(4)][r.nextInt(6)] = 'w'; //places the wumpus randomly in the maze
        }// end of Maze method
        //CHECKMOVE method
        //possible outcomes: run into the wall , fall into the pit, eaten by wumpus,
        //feel breeze, smell stench, nothing.
        public static int checkMove(char [] [] maze, int newRow, int newCol)
            //checks if they run into a wall
            if (newRow<0 || newRow>3 || newCol<0 || newCol>5)
                System.out.println("You hit a wall");
                return 0;
                // it will return to the main method and places 0 in the state variable
            else if (maze[newRow][newCol] == 'p') 
            //this checks the maze if there is a P in that location
                System.out.println("You fall into a pit");
                return 2;
                // it will return to the main method and places 2 in the state variable
            else if (maze[newRow][newCol] == 'w')//checks for the wumpus
                System.out.println("You've eaten by the Wumpus!!");
            //checks for the breeze (right,left,down,up)   //<<is the following if-statement correct?>>>
            if (
                (newCol>0 && maze[newRow][newCol-1] == 'p') ||
                (newCol<5 && maze[newRow][newCol+1] =='p') ||
                (newRow>0 && maze[newCol][newRow-1] == 'p') ||
                (newRow<3 && maze[newCol][newRow+1] =='p')
                System.out.println("You feel a breeze");
            return 1;
        }//end of the maze method
        public static void main(String [ ] args)
            char [ ] [ ] maze = new char [4][6]; //the actual map of the game
            int playerRow=3, playerCol=0;  // player location aka lat/long
            Scanner in= new Scanner(System.in);   //<<there is something wrong with my scanner:The method nextInt(int) in the type Scanner is not applicable for the arguments (InputStream)>>>
            int move, state;
            // state of the game
            // state   0= illegal move, 1= legal move, 3= end game
            initMaze (maze); // calling the initMaze method
            do
                System.out.println("What would you like to do? 1=up, 2=down, 3=right 4=left, 5=shoot");
                move = in.nextInt(System.in);   //<<eclipse is telling me that the type is incorrect>>
                if (move ==1) // move up in the world
                    state = checkMove(maze, playerRow-1,playerCol); //these are coordinates
                    if ( state >0 ) // legal move
                        playerRow = playerRow-1;
                if (move ==2) // move down in the world
                    state = checkMove(maze, playerRow+1,playerCol);
                    if ( state >0 ) // legal move
                        playerRow = playerRow+1;
                if (move ==3) // move right in the world
                    state = checkMove(maze, playerRow,playerCol+1);
                    if ( state >0 ) // legal move
                        playerCol = playerCol+1;
                if (move ==4) // move left in the world
                    state = checkMove(maze, playerRow,playerCol-1);
                    if ( state >0 ) // legal move
                        playerRow = playerCol-1;
                if (move == 5) // shoot the wumpus in the world
                    System.out.println("Which direction would you like to shoot? 1=up, 2=down, 3=right, 4=left");
                    int shootDir = in.nextInt(System.in);
                    // check if the wumpus gets killed
                    if (  shootDir == 1 )  //<<not sure on how to check if the dir they are shooting has the wumpus in there>>
                        System.out.println("You shot the Wumpus!");
            }while (state!=2);
        }//end of main
    }//end of class

    First you need to fix some basic errors:
    1)
    move = in.nextInt(System.in);   Should be:
    move = in.nextInt();   2) You have to initialize some of your vairables like pitRow, pitCol, and col...maybe more...
    3) As for your 'col' variable you need to implement not only the rows but columns as well. Maybe you could do something like this:
    for (int row = 0; row <4; row ++)
                 for(int col = 0; col < 4; col ++)
                maze[row][col] = '0';   // <<<<<<there is a problem here: col cannot be resolved
            }Hope this helps.

  • RE: Need Help with Designing a game of  "GO"

    I have got the GUI sorted thanks to some source code supplied by Noah.W. I wish to add animation to the program below.
    Can someone please help me with the capture methods in the below code. I basically need it to capture all pieces that have been surrounded by opposing pieces. This may be one piece or a whole group captured.
    At the moment it only does it for one piece.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    public class GoGame extends JFrame
    public GoGame()
         getContentPane().setLayout(null);
         setBounds(10,10,510,520);
         getContentPane().add(new TheTable());
         setVisible(true);
    public class TheTable extends JPanel
         int[][]points  = new int[19][19];
         boolean black  = true;
    public TheTable()
         setBounds(20,20,453,453);
         addMouseListener(new MouseAdapter()
              public void mouseReleased(MouseEvent m)
                   Point p = clickOnIntersection(m.getPoint());
                   if (p != null && points[p.x/25][p.y/25] == 0)
                        int x = p.x/25;
                        int y = p.y/25;
                        if (black)
                             points[x][y] = 1;
                             black = false;
                             capture(x,y,2,1);
                             capture(x,y,1,2);
                        else
                             points[x][y] = 2;
                             black = true;
                             capture(x,y,1,2);
                             capture(x,y,2,1);
                        repaint();
    private Point clickOnIntersection(Point p)
         Rectangle rh = new Rectangle(0,0,getWidth(),5);
         Rectangle rv = new Rectangle(0,0,5,getHeight());
         for (int h=0; h < 19; h++)
              rh.setLocation(0,h*25-2);
              if (rh.contains(p))
                   for (int v=0; v < 19; v++)
                        rv.setLocation(v*25-2,0);
                        if (rv.contains(p)) return(new Point(v*25+1,h*25+1));
         return(null);
    private void capture(int x1, int y1, int col0, int col1)
         for (int x=Math.max(0,x1-2); x < Math.min(19,x1+2); x++)
              for (int y=Math.max(0,y1-2); y < Math.min(19,y1+2); y++)
                   if (points[x][y] == col0) capture(x,y,col1);
    private void capture(int x, int y, int col)
         if (x > 0  && points[x-1][y] != col) return;
         if (x < 18 && points[x+1][y] != col) return;
         if (y > 0  && points[x][y-1] != col) return;
           if (y < 18 && points[x][y+1] != col) return;
         points[x][y] = 0;
    public void paintComponent(Graphics g)
         super.paintComponent(g);
         Graphics2D g2 = (Graphics2D)g;
         g2.setPaint(new GradientPaint(getWidth(),getHeight(),Color.yellow,0,0,Color.red,true));
         g2.fillRect(0,0,getWidth(),getHeight());
         g2.setColor(Color.black);
         for (int n=0; n < 19; n++)
              g2.fillRect(0,n*25,getWidth(),3);
              g2.fillRect(n*25,0,3,getHeight());
         g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);          
         g2.setColor(Color.green) ;
         for (int n=0; n < 3; n++)
              g2.fillOval(25*3-1,n*150+74,5,5);
              g2.fillOval(25*9-1,n*150+74,5,5);
              g2.fillOval(25*15-1,n*150+74,5,5);
         for (int x=0; x < 19; x++)
              for (int y=0; y < 19; y++)
                   if (points[x][y] != 0)
                        if (points[x][y] == 1) g.setColor(Color.black);     
                        if (points[x][y] == 2) g.setColor(Color.white);     
                        g2.fillOval(x*25-9,y*25-9,20,20);
    public static void main(String[] args)
         GoGame game = new GoGame();
         game.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    I am also willing to reward �20 via Paypal for the complete solution to the game of "GO", excluding the animation element. Half can be emailed first, then the rest after payment.

  • I need help with an app game purchase

    I recently added 20$ to my account with 2 10$ Itunes cards. I play the app called clash of clans, in the game you can buy things with itunes, I tried to make a purchase for 19.99 when there is just about 21 $ in my itunes and it's telling me I have insufficient funds. This is odd becusee a couple days ago I did the same thing with the itunes card but now I'm getting this error. I checked my itunes again and I have the money, please help!

    What country are you in ? If you are in the US then does your state's sales tax take it over what you have on your account ?

  • Need help creating text based game in Java

    Alright, I'm taking a big leap and I'm jumping a little out of league here. Anyways here are my two classes...I'm sure I've got plenty of errors :-/ One other thing. I have only programmed the battle section of the program so don't worry about the other 5 sections when fixing the code.
    import cs1.Keyboard;
    public class Knights
        public static void main (String[] args)
            // Object Declaration
            KnightsAccount player1 = new Account (1, 100, 200);
            // variable declarations
            boolean run = true;
            int choice;
            // Game Start
            System.out.println ("Welcome to Knights.");
            System.out.println ("--------------------------------------");
            System.out.println ("You are a level 1 character.  With 100 HP and 200 gold...good luck.");
            System.out.println ();
            while (run == true)
                System.out.println ();
                System.out.println ("Enter the number of the option you would like to do");
                System.out.println ();
                System.out.println ("1. Battle");
                System.out.println ("2. Train");
                System.out.println ("3. Work");
                System.out.println ("4. Rest");
                System.out.println ("5. Stats");
                System.out.println ("6. Quit");
                choice = Keyboard.readInt();
                if (choice == 1)
                    player1.battle();
                else if (choice == 2)
                    player1.train();
                else if (choice == 3)
                    player1.work();
                else if (choice == 4)
                    player1.rest();
                else if (choice == 5)
                    player1.stats();
                else
                    run = false;
    }And here is the second class...
    import java.util.Random;
    public class KnightsAccount
        public String winner;
        public int exp = 0;
        public void Account (int level, int hitPoints, int gold) {}
        public battle ()
            Random generator = new Random();
            int pumpkinHP = 80;
            int playerAttack, pumpkinAttack;
            System.out.println ("Engaged in combat with an Evil Pumpkin!");
            while (hitPoints > 0 && pumpkinHP > 0)
                if (pumpkinHP > 0)
                    playerAttack = generator.nextInt(15);
                    hitPoints -= playerAttack;
                    System.out.println ("Player 1 attacked Evil Pumpkin for " + playerAttack + ".");
                    System.out.println ("Evil Pumpkin has " + hitPoints + " HP left.");
                if (pumpkinHP <= 0)
                    pumpkinDead();
                if (hitPoints > 0 && !(pumpkinHP <= 0))
                    pumpkinAttack = generator.nextInt(12);
                    hitPoints -= pumpkinAttack;
                    System.out.println ("Evil Pumpkin attacked Player1 for " + pumpkinAttack + ".");
                    System.out.println ("Player 1 has " + pumpkinHP + " HP left.");
                if (hitPoints <= 0)
                    playerDead();
            return winner;
        private pumpkinDead ()
            System.out.println ("Success!  You have defeated the Evil Pumpkin with " + hitPoints + "HP left!");
            System.out.println ("For you good deed you earned 20 exp.");
            exp += 20;
            return exp;
        private void playersDead ()
            System.out.println ("You have been defeated.  Go home before we pelt melty cheeze at you.");
    }Whoever can help me I'd be grateful. I know there are probably a lot of things wrong here. Also if some of you could post your AIM or MSN so that I can get some one on one help on any of the smaller problems I run acrost that would help a lot too.
    Duke dollars to whoever helps me ;)
    AIM: Trebor DoD
    MSN: [email protected]

    You should really create a GameCharacter object that contains the
    statistics for a character (player or non-player) in the game.
    public class GameCharacter {
       private double attackStrength;
       private double defenseStrength;
       private String name;
       private String[] bodyParts;
       private Random = new Random();
    public GameCharacter(String name, String[] bodyParts, double attackSt, double defenseSt){
       this.attackStrength = attackSt;
       this.defenseStrength = defenseSt;
       this.bodyParts = bodyParts;
       this.name = name;
    // put lots of methods in here to get and set the information
    public String getName(){
      return this.name;
    public String getRandomBodyPart(){
       return this.bodyParts[random.nextInt(this.bodyParts.length)];
    }You then create your "knight" character and your "rabid pumpkin"
    character.
    Your fight method then just takes two GameCharacter objects and uses
    the information they contain to fight the battle.
    public void fight(GameCharacter a, GameCharacter b) {
       boolean fightOver = false;
       Random rn = new Random();
       double attackValue;
       while(!fightOver) {
           attackValue = a.getAttackStrength()*rn.nextDouble();
           System.out.println(a.getName()+" attacks "+b.getName()+"'s "+b.getRandomBodyPart()+" for "+attackValue+" points");
    }The above is not the fighting loop of course. I just put it in to
    demostrate how the fight method can be made generic. It takes any
    two characters and uses their defensive and attack information to
    calculate the fight outcome. It also uses the descriptions that the characters have
    to make the fight more interesting. (the getRandomBodyPart method in
    particular)
    matfud

  • Need help with " Number guessing game " please?

    This is what teacher requires us to do for this assignment:
    Write a program that plays a simple number guessing game. In this game the user will think of a number and the program will do the guessing. After each guess from the program, the user will either indicate that the guess is correct (by typing �c�), or that the next guess should be higher (by typing �h�), or that it should be lower (by typing �l�). Here is a sample output for a game. In this particular game the user thinks of the number 30:
    $java GuessingGameProgram
    Guess a number between 0 and 100
    Is it 50? (h/l/c): l
    Is it 25? (h/l/c): h
    Is it 37? (h/l/c): l
    Is it 31? (h/l/c): l
    Is it 28? (h/l/c): h
    Is it 29? (h/l/c): h
    Is it 30? (h/l/c): c
    Thank you for playing.
    $
    This program is implementing a binary search algorithm, dividing the range of possible values in half with each guess. You can implement any algorithm that you want, but, all things being equal, binary search is the best algorithm.
    Write the program so that the functionality is split between two classes: GuessingGameProgram, and NumberGuesser.
    GuessingGameProgram will only be used for its main function. It should instantiate a NumberGuesser, and it will be responsible for the loop that notifies the user of the next guess, reads the �h�, �l�, or �c� from the user, and sends an appropriate message to the number guesser accordingly.
    The guesses themselves should all be generated by the NumberGuesser class. Here is a diagram of the members and methods for the class. Notice that the members are unspecified. Feel free to give your NumberGuesser class any members (which we have also been calling fields, or instance variables) that you find useful. Make them all private.
    NumberGuesser
    NumberGuesser(int upperLimit, int lowerLimit)
    int guess()
    void higher()
    void lower()
    The constructor should take two integer arguments, a lower and upper bound for the guesses. In your program the constructor will be called with bounds of 0 and 100.
    The guess method should return the same value if it is called more than once without intervening calls to the lower or higher methods. The class should only change its guess when it receives a message indicating that its next guess should be higher or lower.
    Enjoy. Focus your attention on the NumberGuesser class. It is more interesting than the GuessingGameProgram class because it is a general-purpose class, potentially useful to anybody who is writing a number guessing game. Imagine, for instance, that a few weeks from now you are asked to write a number guessing game with a graphical Java Applet front end. If you NumberGuesser class is well written, you may be able to reuse it without any modifications.
    I'm new to JAVA and I'm set with my 2nd homework where I'm so confused. I know how to do something of this source in C language, but I'm a bit confused with Java. This is the code me and my classmate worked on, I know it's not 100% of what teacher asked, but is there any way possibly you guys could help me? I wrote this program if the game is played less then 10 times, thought I would then re-create a program without it, but now I'm confused, and my class book has nothing about this :( and I'm so confused and lost, can you please help? And out teacher told us that it's due the end of this week :( wish I knew what to do. Thank you so so much.
    Here's the code:
    import java.text.*;
    import java.io.*;
    class GuessingGame
    public static void main( String[] args ) throws IOException
    BufferedReader stdin = new BufferedReader(new InputStreamReader( System.in ) );
    int guess = 0, limit = 9, x = 0, n, a = 0 ;
    double val = 0 ;
    String inputData;
    for ( x = 1; x <= 10; x++)      //number of games played
    System.out.println("round " + x + ":");
    System.out.println(" ");
    System.out.println("I am thinking of a number from 1 to 10. ");
    System.out.println("You must guess what it is in three tries. ");
    System.out.println("Enter a guess: ");
    inputData = stdin.readLine();
    guess = Integer.parseInt( inputData );
    val = Math.random() * 10 % limit + 1;     //max limit is set to 9
    NumberFormat nf = NumberFormat.getNumberInstance();
    nf.setMaximumFractionDigits(0);               //format number of decimal places
    String s = nf.format(val);
    val = Integer.parseInt( s );
         for ( n = 1; n <= 3; n++ )      //number of guess's made
                   if ( guess == val)
                        System.out.println("RIGHT!!");                    //if guess is right
                        a = a + 1;
                        System.out.println("You have won " + a + " out of " + x + " rounds");
    System.out.println(" ");
    n = 3;
    continue;
              if (n == 3 && guess != val)                         //3 guesses and guess is wromg
                        System.out.println("wrong");
    System.out.println("The correct number was " + val);
                        System.out.println("You have won " + a + " out of " + x + " rounds");
    System.out.println(" ");
    continue;
                   //how close guess is to value
                   if ( guess == val - 1 || val + 1 == guess) //Within 1
                   System.out.println("hot");
         else if ( guess == val - 2 || val + 2 == guess) // Within 2
                   System.out.println("warm");
              else
                   System.out.println("cold");                         // Greater than 3
         inputData = stdin.readLine();
         guess = Integer.parseInt( inputData );
    //ratings
    if ( a <= 7)
         System.out.println("Your rating is: imbecile.");
    else if ( a <= 8)
         System.out.println("Your rating is: getting better but, dumb.");
    else if (a <= 9)
         System.out.println("Your rating is: high school grad.");
    else if ( a == 10)
         System.out.println("Your rating is: College Grad.!!!");

    Try this.
    By saying that, I expect you ,and your classmate(s), to study this example and then write your own. Hand it in as-is and you'll be rumbled as a homework-cheat in about 20ms ;)
    When you have an attempt where you can explain, without refering to notes, every single line, you've cracked it.
    Also (hint) comment your version well so your tutor is left with the impression you know what you're doing.
    In addition (huge hint) do not leave the static inner class 'NumberGuesser' where it is. Read your course notes and find out where distinct classes should go.
    BTW - Ever wonder if course tutors scan this forum for students looking for help and/or cheating?
    It's a double edged sword for you newbies. If you ask a sensible, well researched question, get helpful answers and apply them to your coursework, IMHO you should get credit for doing that.
    On the other hand, if you simply post your assignment and sit there hoping some sucker like me will do it for you, you should be taken aside and given a good kicking - or whatever modern educational establishments consider appropriate abmonishment ;)
    I'd say this posting is, currently, slap bang between the two extreemes, so impress us. Post your solution in the form you intend to hand it in, and have us comment on it.
    Good luck!
    import java.io.InputStreamReader;
    import java.io.BufferedReader;
    public class GuessingGame
         public static void main(String[] args)
              throws Exception
              BufferedReader reader= new BufferedReader(
                   new InputStreamReader(System.in));
              NumberGuesser guesser= new NumberGuesser(0, 100);
              System.out.println(
                   "\nThink of a number between 0 and 100, oh wise one...");
              int guess= 0;
              while (true) {
                   guess= guesser.guess();
                   System.out.print("\nIs it " +guesser.guess() +"? (h/l/c) ");
                   String line= reader.readLine();
                   if (line == null) {
                        System.out.println(
                             "\n\nLeaving? So soon? But we didn't finish the game!");
                        break;
                   if (line.length() < 1) {
                        System.out.println("\nPress a key, you muppet!");
                        continue;
                   switch (line.toLowerCase().charAt(0)) {
                        case 'h':  
                             guesser.higher();
                             break;
                        case 'l':     
                             guesser.lower();
                             break;
                        case 'c':
                             System.out.println("\nThank you for playing.");
                             System.exit(0);
                        default:
                             System.out.println(
                                  "\nHow hard can it be? Just press 'h' 'l' or 'c', ok?");
                             continue;
                   if (guess == guesser.guess()) {
                        System.out.println(
                             "\nIf you're going to cheat, I'm not playing!");
                        break;
         private static class NumberGuesser
              private int mLower;
              private int mUpper;
              private int mGuess;
              NumberGuesser(int lowerLimit, int upperLimit)
                   mLower= lowerLimit;
                   mUpper= upperLimit;
                   makeGuess();
              private void makeGuess() {
                   mGuess= mLower + ((mUpper - mLower) / 2);
              int guess() {
                   return mGuess;
              void higher()
                   mLower= mGuess;
                   makeGuess();
              void lower()
                   mUpper= mGuess;
                   makeGuess();
    }                  

  • Need help with a guessing game

    Hi. hopefully, this is a really easy issue to resolve. I had to write a program that administers a guessing game, where the computer chooses a random number, and the user has to guess the number. If the user doesn't get it within 5 guesses, they lose and start all over with a new number. I have this all in a while loop (as per my instructions). My issue is that whenever the user enters 0, the program should quit with the users final score and so on. My program will not quit unless the 0 is entered on the last (fifth) guess. please help, it would be very appreciated. Here is my code:
    import java.util.Scanner;
      public class guessgame {
        public static void main(String[] args) {
          Scanner scanner = new Scanner (System.in);
            int randnum;        //random number generated by computer
            int userguess = 1;      //number the user guesses
            int userscore = 0;      //number of correct guesses by user
            int compscore = 0;      //number of times not guessed
            int guessnum = 0;       //number of guesses for one number
            int gamenum = 0;        //number of games played
        System.out.println ("I will choose a number between 1 and 10");
        System.out.println ("Try to find the number using as few guesses as possible");
        System.out.println ("After each guess i will tell you if you are high or low");
        System.out.println ("Guess a number (or 0 to quit)");
        while (userguess != 0) {
          randnum = 1 + (int)(Math.random() * 10); //generates random number
          gamenum ++;
          userguess = userguess;
            for (guessnum = 1; guessnum < 6 && userguess != randnum; guessnum ++) {
                userguess = scanner.nextInt();
                userguess = userguess;
               if (guessnum >= 5) {
                  System.out.println ("You did not guess my number!");
                                  } //closes if statement
               if (userguess == randnum) {
                 userscore ++;
                 System.out.println ("You guessed it! It took you " + guessnum + " tries.");
                 System.out.println ("If you want to play again, enter a guess");
                 System.out.println ("If you do not want to play again, enter 0");
                                        } //closes if statement
               else if (userguess < randnum)
                 System.out.println ("Your guess is too low");
               else if (userguess > randnum)
                 System.out.println ("Your guess is too high");
                                                          }//closes for loop
                              } //closes while loop
    compscore = gamenum - userscore;
            System.out.println ("Thanks for playing! You played " + gamenum + " games");
            System.out.println ("Out of those " + gamenum + " games, you won " + userscore + " times");
            System.out.println ("That means that I won " + compscore + " times"); 
    } //closes main
    } //ends guessgame class

    The problem with your program is that the while loop doesn't get checked. The condition of the while loop will only get checked each iteration, and not during one iteration. The time you are in your for-loop is still one iteration so it won't check if userguess is 0. see it liek this
    While: is userguess 0, no, do 1 iteration
    while-iteration-forloop: check 5 guesses, userguess can be anything even 0 while loop won't stop.
    end of for loop
    end of while-iteration
    new while iteration, is userguess 0?
    and so on.
    HTH,
    Lima

  • Need help installing an older Game

    Hi fans
    I dug out an old PPC game today that I haven't played for ages.  It's called Final Doom for the Mac LC-90KK086-030.  I think the software is circa 1996.
    I try to run it's installer but it fails with the following message "You can't open the application Final DOOM Installer because the Classic environment is no longer supported.".
    Will installing Rosetta fix this?
    To be honest I thought I had already installed Rosetta, but a Finder search has failed to locate it for some reason.

    No; if it would, you would have already been asked to install it. It's a system component and not locatable by a search.
    Use the PowerMac or eMac to play the game.
    (58095)

  • Need help with Connect 4 game, IndexOutOfRangeException was unhandled

    Hi! I've been struggling with this for a while now, the issue is that as soon i move a game piece to the field i get this errorats "IndexOutOfRangeException was unhandled" and i don't know why since my intention with the code was to use for loops
    look through the 2D array thats based on two constants: BOARDSIZEx = 9 and BOARDSIZEy = 6. Instead of traditional 7*6 connect 4 grid i made it 9 squares wide due to having pieces on the side to drag and drop.
    Here's the code for my checkwin:
    public bool checkWin(Piece[,] pieceArray, bool movebool)
    bool found = false;
    //Horizontal
    for (int i = 0; i < BOARDSIZEx - 3; i++)
    for (int j = 0; j < BOARDSIZEy; j++)
    if ((pieceArray[i, j] != null)
    && (pieceArray[i, j] == pieceArray[i, j + 1])
    && (pieceArray[i, j] == pieceArray[i, j + 2])
    && (pieceArray[i, j] == pieceArray[i, j + 3]))
    if (pieceArray[i, j].IsStarter != movebool)
    found = true;
    goto Done; //interesting way of getting out of nested for loop
    //for more on goto: http://stackoverflow.com/questions/324831/breaking-out-of-a-nested-loop
    //Vertikal
    for (int i = 0; i < BOARDSIZEx; i++)
    for (int j = 0; j < BOARDSIZEy - 3; j++)
    if ((pieceArray[i, j] != null)
    && (pieceArray[i, j] == pieceArray[i + 1, j]) && (pieceArray[i, j] == pieceArray[i + 2, j])
    && (pieceArray[i, j] == pieceArray[i + 3, j]))
    if (pieceArray[i, j].IsStarter != movebool)
    found = true;
    goto Done; //interesting way of getting out of nested for loop
    //for more on goto: http://stackoverflow.com/questions/324831/breaking-out-of-a-nested-loop
    //Diagonal, Lower left to upper right
    for (int i = 0; i < BOARDSIZEx - 3; i++)
    for (int j = 0; j < BOARDSIZEy - 3; j++)
    if ((pieceArray[i, j] != null)
    && (pieceArray[i, j] == pieceArray[i + 1, j +1])
    && (pieceArray[i, j] == pieceArray[i + 2, j + 2])
    && (pieceArray[i, j] == pieceArray[i + 3, j + 3]))
    if (pieceArray[i, j].IsStarter != movebool)
    found = true;
    goto Done; //interesting way of getting out of nested for loop
    //for more on goto: http://stackoverflow.com/questions/324831/breaking-out-of-a-nested-loop
    //Diagonal, upper left to lower right
    for (int i = 0; i >= BOARDSIZEx; i--)
    for (int j = 0; j < BOARDSIZEy - 3; j++)
    if ((pieceArray[i, j] != null)
    && (pieceArray[i, j] == pieceArray[i - 1, j + 1])
    && (pieceArray[i, j] == pieceArray[i - 2, j + 2])
    && (pieceArray[i, j] == pieceArray[i - 3, j +3]))
    if (pieceArray[i, j].IsStarter != movebool)
    found = true;
    goto Done; //interesting way of getting out of nested for loop
    //for more on goto: http://stackoverflow.com/questions/324831/breaking-out-of-a-nested-loop
    Done:
    return !found;
    It's at the vertical check that the error occurs and also my checkwin doesnt seem to respond to the call in the game.cs code.
    //check for win
    bool moveBool = true; //returns yes or no depending on whether both players have moved their pieces
    if (move % 2 == 0) moveBool = false;
    bool win = rules.checkWin(pieceArray, moveBool);
    //The game is won!
    if (win)
    string winningPlayerName = player1.Name; //creating a new player instance, just for shortening the code below
    if (moveBool == false) winningPlayerName = player2.Name; //if it was player 2 who won, the name changes
    message = winningPlayerName + " has won the game!\n\n"; //The name of the player
    Board.PrintMove(message); //Print the message
    if (moveBool == true) player1.Score += 1; else player2.Score += 1; //update score for the players
    //The player's labels get their update texts (score)
    Board.UpdateLabels(player1, player2);
    //Here, depending on what one wants to do, the board is reset etc.
    else
    move++; //draw is updated
    And here's a picture on how it looks like at the moment.
    Thanks in Advance!
    Student at the University of Borås, Sweden

    for (int i = 0; i < BOARDSIZEx; i++) // If BOARDSizex is the number of elements in the first dimension...
    for (int j = 0; j < BOARDSIZEy - 3; j++)
    if ((pieceArray[i, j] != null)
    && (pieceArray[i, j] == pieceArray[i + 1, j]) && (pieceArray[i, j] == pieceArray[i + 2, j])
    && (pieceArray[i, j] == pieceArray[i + 3, j])) // Then [i + anything, j] will be out of range.
    You probably meant to add the one, two, or three to the j rather than the i.

  • I need help finding an old game I used to play

    It was a space adventure rpg and you had a yellow ship, and you flew around and collected resources and fought enemies. All I remember is the yellow ship. Help!

    The first step in Upgrading... is to Snow Leopard = OS X 10.6.x
    It is Not available as a download... It is a Paid Upgrade.
    Do this first...
    Check that your Mac meets the System Requirements for Snow Leopard...
    Snow Leopard Tech Specs
    http://support.apple.com/kb/SP575
    If so... Purchase a Snow Leopard Install Disc...
    http://store.apple.com/us/product/MC573Z/A/mac-os-x-106-snow-leopard
    Other countries...
    http://support.apple.com/kb/HE57
    After the Successful Install, run Software Update to get the latest updates for Snow Leopard and iTunes.
    Next... MAVERICKS...
    Check here to see if your Mac is compatible...
    http://www.apple.com/osx/how-to-upgrade/

  • TS1702 I am using iPad 3, today I upgraded it to iOS 6 however after updating a particular application is not functioning properly. it's Candy Shoot, need help in playing that game

    I am currently using iPad 3, and upgraded it to ios6 today. However after updating the software e a particular game Candy Shoot is not functioning properly. Please suggest how to get it solved

    thanks, but can you tell me how do I get in touch with the app development team?

Maybe you are looking for