Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help
The ASP Free website provides in-depth information on the latest developer tools available from Microsoft. Our cadre of writers, highly experienced industry experts, reveals the best ways to use established technologies as well as new and emerging technologies. Our coverage of Microsoft's development and administration technologies is among the most respected in the IT industry today.

ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month!
Download and Activate to enter!

Intel® Graphics Performance Analyzers is a powerful tool suite for analyzing and optimizing your games, media, and graphics-intensive applications. Used by some of the best developers on the planet, Intel GPA lets you maximize your app’s performance.


Tutorials
| Forums

Download to Enter
| Contest Rules

DOWNLOAD INTEL® GPA FOR FREE

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 14th, 2006, 04:10 AM
yoyoyo yoyoyo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2006
Posts: 5 yoyoyo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 14 m 45 sec
Reputation Power: 0
Chutes and Ladders problem

hello. I am making a text version of Chutes and Ladders for a project I have to do for school. I am almost done i think, but I have a problem with my Chutes and Ladders part of the program. This is what I have so far.


code//

package APcompsci.Myprogs;

import cs1.Keyboard;

public class game1 {
private int [][] map= new int[10][10];
private final int SPACE = 0;
private final int PERSON = -1;
private double s = 0;
private boolean over = true;
private int total = 0;
private int total1 = 0;
private int r = 0;
private int c = 0;
Die d = new Die();

public void initialboard() {
//sets a new board up
for ( c = 0; c < 10; c++)
for (r = 0; r < 10; r++){
map[r][c] = SPACE;
map[5][6] = 88;
map[2][9] = 55;
map[4][9] = 33;
map[3][8] = 50;
map[9][7] = 77;
}
}

public void display() {
for ( c = 0; c< 10; c++){
System.out.println("");
for ( r = 0; r< 10; r++)
System.out.print("" + map[r][c] + "\t");
}
}

public void move(){
int u , count = 0, r = 0, c = 0, t = 0, q = 0;;

System.out.println("\n" + "Start at 1");
do{
map[r][c] = 0;
System.out.println("\n" + "press 1 to roll!!!");
u = Keyboard.readInt();
d.roll();
System.out.println("\n" + "you have rolled a " + d.getFaceValue());
total += d.getFaceValue();
System.out.println("the total is " + (total + 1));
r = total;
t = total - d.getFaceValue();
double s = total - d.getFaceValue();
if ((r / 10) > (s / 10)){
q = r/10;
r = r - q * 10;
c = c + 1;
}
else if ((r/10) <= (s/10) && ((r/10) == (t/10))){
q = r/10;
r = r - q * 10;
}
else {
r = total;

}

if (total >= 100){
break;
}
map[r][c] = PERSON;
chutes();
ladders();
display();
count++;
}while (total < 100);
System.out.println("You rolled " + count + " times to finish!");
}


public void chutes(){
int total1 = 0;

if (PERSON == map[2][9]){
map[2][9] = 55;
map[4][5] = PERSON;
total -= 37;
System.out.println("CHUTE!!!");
}
if (PERSON == map[4][9]){
map[4][9] = 33;
map[2][3] = PERSON;
total -= 62;
System.out.println("CHUTE!!!");
}
if (PERSON == map[3][8]){
map[3][8] = 50;
map[9][4] = PERSON;
total -= 34;
System.out.println("CHUTE!!!" );
}
if (PERSON == map[9][7]){
map[9][7] = 77;
map[7][6] = PERSON;
total -= 12;
System.out.println("CHUTE!!!");
display();
}
}

public void ladders(){
if (PERSON == map[5][6]){
map[5][6] = 88;
map[7][8] = PERSON;
total += 12;
System.out.println("LADDER!!!");
}
}

}

This is part that is wrong...

The good thing is that it does chute to a certain place when the PERSON lands on a Chute or a ladder, but when I roll again, it continues from the chute or ladder place instead of the new place where it's supposed to be and the PERSON just stays in the new spot. I've been working on this for like 3 hours and I've gotten no where... . If you can just guide me or help me to get somewhere that would be GREAT!!!

Reply With Quote
  #2  
Old January 14th, 2006, 02:30 PM
yoyoyo yoyoyo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2006
Posts: 5 yoyoyo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 14 m 45 sec
Reputation Power: 0
Hello. I'm still stuck. Please help me out in anyway. I'm not asking you guys to do my program for me.

Reply With Quote
  #3  
Old January 14th, 2006, 03:37 PM
crownjewel82 crownjewel82 is offline
rebel with a cause
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: May 2004
Location: The Batsh!t Crazy State.
Posts: 5,786 crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)  Folding Points: 53188 Folding Title: Beginner FolderFolding Points: 53188 Folding Title: Beginner FolderFolding Points: 53188 Folding Title: Beginner Folder
Time spent in forums: 3 Months 4 Days 5 h 36 m 14 sec
Reputation Power: 3459
How do you handle making a move?

When a player moves forward based on the dice you update their position on the board. Once they land on a chute you need to update that variable to whatever the new square is. If you've tried this and it doesn't work, you've got a problem in how you're handling player movement.
__________________
Resistance to tyrants is obedience to God. - Thomas Jefferson

Reply With Quote
  #4  
Old January 14th, 2006, 03:55 PM
yoyoyo yoyoyo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2006
Posts: 5 yoyoyo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 14 m 45 sec
Reputation Power: 0
not quite sure what you're saying. I update the board when the player moves, but I kinda do update the board when the person lands on the chute but it doesn't continue from that spot. I dunno how to fix that.

Reply With Quote
  #5  
Old January 15th, 2006, 07:50 PM
crownjewel82 crownjewel82 is offline
rebel with a cause
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: May 2004
Location: The Batsh!t Crazy State.
Posts: 5,786 crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)crownjewel82 User rank is General 37th Grade (Above 100000 Reputation Level)  Folding Points: 53188 Folding Title: Beginner FolderFolding Points: 53188 Folding Title: Beginner FolderFolding Points: 53188 Folding Title: Beginner Folder
Time spent in forums: 3 Months 4 Days 5 h 36 m 14 sec
Reputation Power: 3459
Ok. You updated the location of the person on the board but you didn't tell your loop where to start based on the new location of the person. I propose that instead of having the board track the person's location, let the person track it's own location.

In reviewing your code I've discovered some problems:
1. You are using single letter variable names. This may be fine for you but for someone else it is difficult. Also, when you come back to this in 6 months or a year you may not be able to tell. Use more descriptive variable names.

2. The next time you post code, please use [code][/ code] or [highlight=java][/ highlight] tags to display your code in a more readable format.

Reply With Quote
  #6  
Old January 16th, 2006, 03:51 AM
yoyoyo yoyoyo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2006
Posts: 5 yoyoyo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 14 m 45 sec
Reputation Power: 0
Thank you! got it now

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Chutes and Ladders problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.

© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 4 - Follow our Sitemap