Jump to content

danielbrthwt

Active Members
  • Posts

    62
  • Joined

  • Last visited

Everything posted by danielbrthwt

  1. Dident think of that thanks, i have posted the revalent classes but they are quite long
  2. I am new to java programming so i am trying to consolidate what i have learnt and i am writing a bot for a game called Flood-it and i encountered a problem where a variable was be incremented when it shouldn't, i narrowed it down to a line of code that from what i could see has no connection to the variable it is changeing. im really sorry if my code is hard to understand but if you need me to explain something i will try, help would be much appreciated. what i believe to be the error is in line 72 of the board class. Somehow the line group[numOfSquares][1] = b; is affecting the priGroup varible in one of the Square class instances Here are the links to the files ( the form wouldn't let me upload them ) www.megaupload.com/?d=QD09MU4R www.megaupload.com/?d=YFH9VMV9 www.megaupload.com/?d=Y0E0MJAK www.megaupload.com/?d=2OZ3APM9 Board class public class Board { static int[] blacklist = new int[196]; static int curGroup = 0; static int isGroup = 0; static int[][] group; static int[][] reset = new int[1][2]; static int numOfSquares = 0; public static Row[] board = new Row[14]; static int up; static int down; static int left; static int right; static int col; static int gid; static int multi; public Board( String[][] allColours ) { for ( int i = 0; i < 14; i++ ) { board[i] = new Row(); } for ( int i = 0; i < allColours.length; i++ ) { board[i].setState(allColours[i]); } } public static void printBoardNum() { System.out.println("--------------------------------------------------------"); for ( int i = 0; i < board.length; i++ ) { System.out.println(board[i].printStringNum()); System.out.println("--------------------------------------------------------"); } } public static void printBoardGroupIds() { System.out.println("--------------------------------------------------------"); for ( int i = 0; i < board.length; i++ ) { System.out.println(board[i].printGroupIds()); System.out.println("--------------------------------------------------------"); } } public static void findGroups() { for ( int a = 0; a < board.length; a++ ) { for ( int b = 0; b < board.length; b++ ) { numOfSquares = 0; //int[][] startingGroup = board[0].getGroupArray(0); //startingGroup = reset; group = reset; //startingGroup = board[0].getGroupArray(0); //startingGroup = reset; group[numOfSquares][0] = a; int[][] startingGroup = board[0].getGroupArray(0); startingGroup = reset; group[numOfSquares][1] = b; startingGroup = board[0].getGroupArray(0); startingGroup = reset; numOfSquares++; //startingGroup = board[0].getGroupArray(0); //startingGroup = reset; int col = board[a].getSquareCol(B); //startingGroup = board[0].getGroupArray(0); //startingGroup = reset; blacklist[(a*13)+b] = 1; //startingGroup = board[0].getGroupArray(0); //startingGroup = reset; isGroup = findAround(a, b, col); //startingGroup = board[0].getGroupArray(0); //startingGroup = reset; if ( isGroup == 1 && board[a].getGroupId(B) == -1 ) { board[a].addToGroup(b, curGroup); //startingGroup = board[0].getGroupArray(0); //startingGroup = reset; for ( int i = 0; i < group.length; i++ ) { board[group[i][0]].setGroupArray(group[i][1], group); //startingGroup = board[0].getGroupArray(0); //startingGroup = reset; //System.out.printf(" *| %d | %d |*", group[i][0], group[i][1]); } //System.out.println(); curGroup++; numOfSquares = 0; //startingGroup = board[0].getGroupArray(0); //startingGroup = reset; } int[][] test = board[0].getGroupArray(0); System.out.println("Test ( should be 0 ) : " + test[0][1]); //for ( int i = 0; i < startingGroup.length; i++ ) //{ // System.out.println(startingGroup[i][0] + " + " + startingGroup[i][1]); //} //System.out.println(); } } } private static int findAround(int a, int b, int col) { int[] around = new int[4]; int inGroup = 0; if ( a > 0 ) around[0] = board[a-1].getSquareCol(B); else around[0] = 0; if ( a < 13 ) around[1] = board[a+1].getSquareCol(B); else around[1] = 0; if ( b > 0 ) around[2] = board[a].getSquareCol(b-1); else around[2] = 0; if ( b < 13 ) around[3] = board[a].getSquareCol(b+1); else around[3] = 0; if ( around[0] == col && blacklist[((a-1)*13)+b] != 1) { group = extendArray(group); group[numOfSquares][0] = a-1; group[numOfSquares][1] = b; numOfSquares++; blacklist[((a-1)*13)+b] = 1; board[a-1].addToGroup(b, curGroup); inGroup = 1; findAround( a-1, b, col ); } if ( around[1] == col && blacklist[((a+1)*13)+b] != 1) { group = extendArray(group); group[numOfSquares][0] = a+1; group[numOfSquares][1] = b; numOfSquares++; blacklist[((a+1)*13)+b] = 1; board[a+1].addToGroup(b, curGroup); inGroup = 1; findAround( a+1, b, col ); } if ( around[2] == col && blacklist[(a*13)+(b-1)] != 1) { group = extendArray(group); group[numOfSquares][0] = a; group[numOfSquares][1] = b-1; numOfSquares++; blacklist[(a*13)+(b-1)] = 1; board[a].addToGroup(b-1, curGroup); inGroup = 1; findAround( a, b-1, col ); } if ( around[3] == col && blacklist[(a*13)+(b+1)] != 1) { group = extendArray(group); group[numOfSquares][0] = a; group[numOfSquares][1] = b+1; numOfSquares++; blacklist[(a*13)+(b+1)] = 1; board[a].addToGroup(b+1, curGroup); inGroup = 1; findAround( a, b+1, col ); } return inGroup; } public static void scoreOptions() { int startingCol = board[0].getSquareCol(0); if ( board[0].getGroupId(0) != -1 ) { int pinkC = 0; int pinkM = 0; int purpleC = 0; int purpleM = 0; int yellowC = 0; int yellowM = 0; int redC = 0; int redM = 0; int blueC = 0; int blueM = 0; int greenC = 0; int greenM = 0; int[][] startingGroup = board[0].getGroupArray(0); for ( int i = 0; i < startingGroup.length; i++ ) { if ( startingGroup[i][0] > 0 ) { col = board[startingGroup[i][0]-1].getSquareCol(startingGroup[i][1]); gid = board[startingGroup[i][0]-1].getGroupId(startingGroup[i][1]); if ( gid != -1 ) multi = board[startingGroup[i][0]-1].getGroupArray(startingGroup[i][1]).length; else multi = 1; if ( col != startingCol ) { if ( col == 1 ) { pinkC++; pinkM += multi; } if ( col == 2 ) { purpleC++; purpleM += multi; } if ( col == 3 ) { yellowC++; yellowM += multi; } if ( col == 4 ) { redC++; redM += multi; } if ( col == 5 ) { blueC++; blueM += multi; } if ( col == 6 ) { greenC++; greenM += multi; } } } if ( startingGroup[i][0] > 13 ) { col = board[startingGroup[i][0]+1].getSquareCol(startingGroup[i][1]); gid = board[startingGroup[i][0]+1].getGroupId(startingGroup[i][1]); int multi; if ( gid != -1 ) multi = board[startingGroup[i][0]+1].getGroupArray(startingGroup[i][1]).length; else multi = 1; if ( col != startingCol ) { if ( col == 1 ) { pinkC++; pinkM += multi; } if ( col == 2 ) { purpleC++; purpleM += multi; } if ( col == 3 ) { yellowC++; yellowM += multi; } if ( col == 4 ) { redC++; redM += multi; } if ( col == 5 ) { blueC++; blueM += multi; } if ( col == 6 ) { greenC++; greenM += multi; } } } if ( startingGroup[i][1] > 0 ) { col = board[startingGroup[i][0]].getSquareCol(startingGroup[i][1]-1); gid = board[startingGroup[i][0]].getGroupId(startingGroup[i][1]-1); if ( gid != -1 ) multi = board[startingGroup[i][0]].getGroupArray(startingGroup[i][1]-1).length; else multi = 1; if ( col != startingCol ) { if ( col == 1 ) { pinkC++; pinkM += multi; } if ( col == 2 ) { purpleC++; purpleM += multi; } if ( col == 3 ) { yellowC++; yellowM += multi; } if ( col == 4 ) { redC++; redM += multi; } if ( col == 5 ) { blueC++; blueM += multi; } if ( col == 6 ) { greenC++; greenM += multi; } } } if ( startingGroup[i][0] > 0 ) { int col = board[startingGroup[i][0]].getSquareCol(startingGroup[i][1]+1); int gid = board[startingGroup[i][0]].getGroupId(startingGroup[i][1]+1); if ( gid != -1 ) multi = board[startingGroup[i][0]].getGroupArray(startingGroup[i][1]+1).length; else multi = 1; if ( col != startingCol ) { if ( col == 1 ) { pinkC++; pinkM += multi; } if ( col == 2 ) { purpleC++; purpleM += multi; } if ( col == 3 ) { yellowC++; yellowM += multi; } if ( col == 4 ) { redC++; redM += multi; } if ( col == 5 ) { blueC++; blueM += multi; } if ( col == 6 ) { greenC++; greenM += multi; } } } } } else { } } public static int[][] extendArray( int[][] array ) { int[][] newArray = new int[array.length+1][2]; for ( int i = 0; i < array.length; i++ ) { newArray[i] = array[i]; } return newArray; } public static int[][] getGroup( int a, int B) { return board[a].getGroupArray(B); } } Square Class public class Square { private String colour; private int colournum; private int groupid = -1; private int[][] priGroup; public void setState( String col ) { colour = col; if (col.equals("pink")) colournum = 1; if (col.equals("purple")) colournum = 2; if (col.equals("yellow")) colournum = 3; if (col.equals("red")) colournum = 4; if (col.equals("blue")) colournum = 5; if (col.equals("green")) colournum = 6; } public String getColour() { return colour; } public int getNum() { return colournum; } public void addToGroup( int id ) { groupid = id; } public int getGroupid() { return groupid; } public void setGroupArray( int[][] g ) { priGroup = g; } public int[][] getGroupArray() { return priGroup; } }
  3. Thanks i have been looking for a screen scraper but i havent had much luck but ill keep looking
  4. A great book is Programming Python you should have a look but it might be a bit advanced. http://www.amazon.com/Programming-Python-Mark-Lutz/dp/0596158106/ref=sr_1_1?ie=UTF8&qid=1315461740&sr=8-1
  5. I'm looking for a module that would allow me to write a program in python that can move the cursor and also left click. I'm also looking for a module that can tell the color of pixels at specified locations Can anyone help ?
  6. it seems that everyone has there own opion I sopose its just personal prefrence
  7. I was thinking of installing water cooling in my PC but some of my friends said that it was a terrible idea because they often leak and you have dismantle it when ever your moving it so i was wondering if i could get some other opinions on this
  8. maby you could buy like 1 hour of data and use cain and able to listen and capture other peoples passwords and then use other peoples accounts but it might not work depending on how secured the hotspot is plus doing that would be illegal so i wouldent recomend it
  9. you could try use the Virtual Box Webserver which means you could have 1 really good server and like 4 cheaper computers to play games on http://code.google.com/p/vboxweb/wiki/install
  10. sorry i just found that when i was searching but if you want to download it from the original site i think this is it http://www.pendrivelinux.com/yumi-multiboot-usb-creator/
  11. I found this awesome program that formats (if you want it to) and installs the ISO's for you tell me what you think Click Here to get the download
  12. No problem but yea i thought it was a really good book because it has heaps on just the programming language but it also has stuff on GUI design
  13. Thanks ill have a look on that site and it dosent matter about shipping time it takes ages to get stuff anyway
  14. The problem is that the libary around where i live dosent have any programming books
  15. i had a look at the reviews of some of his books on amazon.com they look like there good for beginners but some of the are around 100 USD which is expencive for a book on programming
  16. Yea people i know have said that that brand is really good. but i have a book called "Python programming for the absolute beginner" and that has challenges at the end of every chapter and i find them help full to consolidate what i have learnt. do the o'reilly books have something like that ?
  17. I am currently teaching my self programming useing books i have bought off amazon and i wondering is anyone had any sugestions of good books is should buy or websites that have helpfull tutorials on them
  18. i think from what you guys have been saying i think it would be worth it and power efficent to just make one really good super computer
  19. I had a look at thoes graphics cards and they look amazing but the reason why i thought that makeing a cluster would be better was that it provided you with more flexabilty because if you do 3 way SLI with the Nvida graphics cards and you wanted to upgrade (which you probley wouldent have to do i a while with those cards) you would have to replace all 3 of them which would be expencive but if you had 10 wall mounted computers in a cluster you could replace all the parts indvidually (Unless clustering requires you to have the same hardware on each computer)
  20. Chears that going to be really helpful
  21. I was looking at my wall and i thought i could wall mount a few computers, i was also thinking of somehow combineing these computer(ethernet , firewire) and turning them into one computer. if this is possable how would i do it and would i need special software or hardware ? Thanks
  22. How do you configure backtrack to work with your network ?
×
×
  • Create New...