Jump to content

Diclonius Path Walking


Diclonius

Recommended Posts

int a = 10, b = 6;if(a > b) {	for(int i = b; i <= a; i++) {		}} else {	for(int i = a; i <= b; i++) {		}}=int a = 10, b = 6;for(int i = Math.min(a, b); i <= Math.max(a, b); i++) {}

But then the positions could be backwards. I need fullPath to be in order. I'm not just looping through all the tiles, I'm looping from pos1 to pos2

Edited by Diclonius
Link to comment
Share on other sites

I know that this will sound a bit fussy, but you really have to work on your java naming conventions. This will improve the readability and quality of your code so much in the long term!
things i recognised:

Objects = lowercase (Script s)

use the final keyword (final Script s, final boolean direction, ....)

Things i don't understand:
 

if(direction) {
			for(int u = 0; u < fullPath.size(); u++) {
				Position p = fullPath.get(u);
				if(S.distance(p) < 11) {
					int xOffSet = MethodProvider.random(3)-1;
					int yOffSet = MethodProvider.random(3)-1;
					return new Position(p.getX()+ xOffSet,p.getY()+yOffSet,S.myZ());
				}
			}
		} else {
			for(int u = fullPath.size()-1; u > 0; u=u-1) {
				Position p = fullPath.get(u);
				if(S.distance(p) < 10) {
					int xOffSet = MethodProvider.random(5)-2;
					int yOffSet = MethodProvider.random(5)-2;
					return new Position(p.getX()+ xOffSet,p.getY()+yOffSet,S.myZ());
				}
			}
		}

why do you have different offset based on the direction your walking?
why do you have different conditions? (S.distance(p) < 10 ...... S.distance(p) < 11)
please rework the things i told you and post again tongue.png

Edit: make Script private and rethink private/public on your methods...

Edited by codingstyle
Link to comment
Share on other sites

I know that this will sound a bit fussy, but you really have to work on your java naming conventions. This will improve the readability and quality of your code so much in the long term!

things i recognised:

Objects = lowercase (Script s)

use the final keyword (final Script s, final boolean direction, ....)

Things i don't understand:

if(direction) {			for(int u = 0; u < fullPath.size(); u++) {				Position p = fullPath.get(u);				if(S.distance(p) < 11) {					int xOffSet = MethodProvider.random(3)-1;					int yOffSet = MethodProvider.random(3)-1;					return new Position(p.getX()+ xOffSet,p.getY()+yOffSet,S.myZ());				}			}		} else {			for(int u = fullPath.size()-1; u > 0; u=u-1) {				Position p = fullPath.get(u);				if(S.distance(p) < 10) {					int xOffSet = MethodProvider.random(5)-2;					int yOffSet = MethodProvider.random(5)-2;					return new Position(p.getX()+ xOffSet,p.getY()+yOffSet,S.myZ());				}			}		}
why do you have different offset based on the direction your walking?

why do you have different conditions? (S.distance(p) < 10 ...... S.distance(p) < 11)

please rework the things i told you and post again tongue.png

Edit: make Script private and rethink private/public on your methods...

The different offsets and the 10 and 11 are just mistakes when copy and pasting between versions :P. I know my java conventions are poor, I was never tought java. I learnt it through videos and e-books so I haven't had the chance for people to point the mistakes I make so I really appreciate you doing so. Next year I plan to study computer science at uni so then I will hopefully learn these things. Edited by Diclonius
Link to comment
Share on other sites

The different offsets and the 10 and 11 are just mistakes when copy and pasting between versions tongue.png. I know my java conventions are poor, I was never tought java. I learnt it through videos and e-books so I haven't had the chance for people to point the mistakes I make so I really appreciate you doing so. Next year I plan to study computer science at uni so then I will hopefully learn these things.

http://docs.oracle.com/javase/tutorial/java/ even if you know most of the stuff there read it all again, because you may have some bad habits, which you didn't know of biggrin.png Also you will leran java naming conventions wink.png

  • Like 1
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...