Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Java - fix programma
Forum - Java - fix programma

Avatar
sheva7 (Normal User)
Newbie


Messaggi: 10
Iscritto: 13/01/2013

Segnala al moderatore
Postato alle 1:12
Giovedì, 17/01/2013
Ho trovato questo codice su internet ma non riesco a capire come fixarlo...
Nel caso vi fosse di aiuto è una sorta di snake multiplayer in cui non si devono mangiare le mele ma vince chi non  si scontra contro il serpente avversario o contro il muro.
Comunque sia, mi hanno detto che il codice è funzionante ma non sono riuscito a sistemarlo.
Dopo varie modifiche sono riuscito solo a far aumentare il numero degli errori per cui, vi incollo la versione base dei file che ho trovato.

grazie anticipatamente a tutti.

Allora, il codice è questo solo che non riesco a capire come fixarlo...

FILE arena.java
Codice sorgente - presumibilmente Java

  1. /**
  2.  * Arena class
  3.  *
  4.  * originally written by Elizabeth Sklar and Pablo Funes, summer 1998
  5.  *
  6.  * modified for teaching spring-2006/sklar
  7.  *
  8.  */
  9.  
  10.  
  11. import java.awt.*;
  12. import java.lang.*;
  13. import java.applet.*;
  14. import java.util.Vector;
  15. import java.net.*;
  16. import java.io.*;
  17.  
  18.  
  19. public class Arena extends Canvas implements Runnable {
  20.    
  21.     Dimension grayDimension;
  22.     Image     grayImage;
  23.     Graphics  grayGraphics;
  24.    
  25.     public Tron              tron;
  26.    
  27.     private Thread           conductor;
  28.     public  Player           player1;
  29.     public  Player           player2;
  30.     public  GPPlayer         gpplayer;
  31.     public  NNPlayer         nnplayer;
  32.     public  MyPlayer         myplayer;
  33.     public  boolean          board[][];
  34.     public  boolean          clear;
  35.     public  boolean          startAgain = false;
  36.     private int              xmax, ymax;
  37.    
  38.     public static final int  WAITING = 0;
  39.     public static final int  RUNNING = 1;
  40.     public static final int  RESTARTING = 2;
  41.     public int               state;
  42.    
  43.     public int               lastmove;
  44.     public int               gen_no;
  45.    
  46.    
  47.    
  48.     /**
  49.      * Arena constructor
  50.      *
  51.      */
  52.     public Arena( Tron t ) {
  53.         setBackground( Color.black );
  54.         player1 = null;
  55.         player2 = null;
  56.         conductor = null;
  57.         board = null;
  58.         state = WAITING;
  59.         tron = t;
  60.         gen_no = 0;
  61.     } /* end of Arena constructor */
  62.  
  63.  
  64.    
  65.     /**
  66.      * start()
  67.      *
  68.      * this method is called once, when the arena is initialized and
  69.      * its runnable thread starts
  70.      *
  71.      */
  72.     public void start() {
  73.         xmax = size().width;
  74.         ymax = size().height;
  75.         if ( board == null ) {
  76.             board = new boolean[xmax][ymax];
  77.         }
  78.         gpplayer = new GPPlayer( "gp",Color.pink,this,xmax,ymax,(byte)1,null );
  79.         nnplayer = new NNPlayer( "nn",Color.pink,this,xmax,ymax,(byte)1,null );
  80.         myplayer = new MyPlayer( "my",Color.pink,this,xmax,ymax,(byte)1 );
  81.         player2 = new HumanPlayer( "human",Color.cyan,this,xmax,ymax,(byte)2 );
  82.         if ( grayImage != null ) {
  83.             this.getGraphics().drawImage( grayImage,0,0,this );
  84.         }
  85.         if ( conductor == null ) {
  86.             conductor = new Thread( this,"Arena" );
  87.             conductor.start();
  88.         }
  89.         else {
  90.             conductor.resume();
  91.         }
  92.     } /* end of start() */
  93.  
  94.  
  95.    
  96.     /**
  97.      * stop()
  98.      *
  99.      * this method is called when the runnable thread stops
  100.      *
  101.      */
  102.     public void stop() {
  103.         conductor.suspend();
  104.     } /* end of stop() */
  105.  
  106.    
  107.    
  108.     /**
  109.      * selectPlayer1()
  110.      *
  111.      * this method is called when the user clicks on a button in the
  112.      * interface and selects a robot controller
  113.      *
  114.      */
  115.     public void selectPlayer1(
  116.                               int player,
  117.                               String filename
  118.                               ) {
  119.         if ( player == Tron.GP ) {
  120.             gpplayer.getStrategy( filename );
  121.             player1 = gpplayer;
  122.             player1.name = "GP";
  123.         }
  124.         else if ( player == Tron.NN ) {
  125.             nnplayer.readNetwork( filename );
  126.             player1 = nnplayer;
  127.             player1.name = "NN";
  128.         }
  129.         else if ( player == Tron.MY ) {
  130.             player1 = myplayer;
  131.             player1.name = "MY";
  132.         }
  133.         player1.crash = false;
  134.         player2.crash = false;
  135.         clear = true;
  136.         repaint();
  137.     } /* end of selectPlayer1() */
  138.    
  139.  
  140.    
  141.     /**
  142.      * startPlayers()
  143.      *
  144.      * this method is called when the user clicks on the "start"
  145.      * button in the interface
  146.      *
  147.      */
  148.     public void startPlayers() {
  149.         clearBoard();
  150.         player1.go( xmax/4,ymax/2 );
  151.         player2.go( 3*xmax/4,ymax/2 );
  152.         player1.score = tron.robotScore;
  153.         state = RUNNING;
  154.         lastmove = 0;
  155.     } /* end of startPlayers() */
  156.    
  157.  
  158.    
  159.     /**
  160.      * run()
  161.      *
  162.      * this is the "run" method that executes forever while the
  163.      * runnable thread is executing
  164.      *
  165.      */
  166.     public void run() {
  167.         while ( true ) {
  168.             switch ( state ) {
  169.             case RUNNING:
  170.                 player1.step();
  171.                 player2.step();
  172.                 break;
  173.             case RESTARTING:
  174.                 if ( player1.crash && player2.crash ) {
  175.                     // tie
  176.                 }
  177.                 else if ( player1.crash ) {
  178.                     // player1 crashes -> player2 wins -> result="L"
  179.                     player2.tallyWin();
  180.                 }
  181.                 else if ( player2.crash ) {
  182.                     // player2 crashes -> player1 wins -> result="W"
  183.                     player1.tallyWin();
  184.                 }
  185.                 player1.restart( player2.crash );
  186.                 player2.restart( player1.crash );
  187.                 state = WAITING;
  188.                 tron.updateScore();
  189.                 break;
  190.             case WAITING:
  191.                 if ( startAgain ) {
  192.                     startAgain = false;
  193.                     start();
  194.                     startPlayers();
  195.                 }
  196.                 break;
  197.             }
  198.             repaint();
  199.             try {
  200.                 Thread.sleep( 10 );
  201.             }
  202.             catch ( InterruptedException e ) {
  203.             }
  204.             if ( player1 != null ) { // hack hack
  205.                 player1.newPos();
  206.                 player2.newPos();
  207.             }
  208.         }
  209.     } /* end of run() */
  210.    
  211.    
  212.  
  213.     /**
  214.      * update()
  215.      *
  216.      * this method is called by the native paint() method to draw on
  217.      * this canvas
  218.      *
  219.      */
  220.     public void update( Graphics g ) {
  221.         if ( clear ) {
  222.             g.clearRect( 0,0,size().width,size().height );
  223.             clear = false;
  224.         }
  225.         if ( player1 != null ) {
  226.             player1.paint( g );
  227.         }
  228.         if ( player2 != null ) {
  229.             player2.paint( g );
  230.         }
  231.     } /* end of update() */
  232.  
  233.    
  234.    
  235.     /**
  236.      * clearBoard()
  237.      *
  238.      * this method is called after a game ends to clear out the board
  239.      *
  240.      */
  241.     public void clearBoard() {
  242.         int i, j;
  243.         for ( i=0; i<xmax; i++ )
  244.             for ( j=0; j<ymax; j++ )
  245.                 board[i][j] = false;
  246.         clear = true;
  247.     } /* end of clearBoard() */
  248.  
  249.  
  250.  
  251. } /* end of Arena class */




file HumanPlayer.java
Codice sorgente - presumibilmente Java

  1. import java.awt.*;
  2. import java.lang.*;
  3. import java.applet.*;
  4.  
  5. public class HumanPlayer extends Player {
  6.  
  7.  
  8.     public HumanPlayer( String n, Color c, Arena a, int x, int y, byte number ) {
  9.         name = n;
  10.         color = c;
  11.         arena = a;
  12.         x_max = x;
  13.         y_max = y;
  14.         score = 0;
  15.         player_no = number;
  16.  
  17.     } // end of HumanPlayer constructor
  18.    
  19.  
  20.     // human player's d is controlled by interrupt-driven keyboard
  21.     // handler; doesn't have to implement whereDoIGo
  22.    
  23.    
  24.     public void go( int x,int y ) {
  25.         super.go(x,y); // do everything the original GO does, plus custom inits
  26.         didsomething = false;
  27.     } // end of go()
  28.  
  29.  
  30.  
  31. } /* end of HumanPlayer class */




file MyPlayer.java
Codice sorgente - presumibilmente Java

  1. import java.awt.*;
  2. import java.lang.*;
  3. import java.applet.*;
  4. import java.util.Random;
  5.  
  6.  
  7.  
  8. public class MyPlayer extends Player {
  9.  
  10.  
  11.     public boolean didsomething = false;
  12.     public Random random;
  13.  
  14.  
  15.     /**
  16.      * MyPlayer constructor
  17.      *
  18.      * you probably don't need to modify this method!
  19.      *
  20.      */
  21.     public MyPlayer( String n, Color c, Arena a, int x, int y, byte number ) {
  22.         name  = n;
  23.         color = c;
  24.         arena = a;
  25.         x_max = x;
  26.         y_max = y;
  27.         player_no = number;
  28.         random = new Random();
  29.     } /* end of MyPlayer constructor */
  30.  
  31.  
  32.  
  33.     /**
  34.      * whereDoIGo
  35.      *
  36.      * this is the method you need to modify.
  37.      * you need to decide where your robot should go at each time step
  38.      * (this method is called each time the robot can make a move).
  39.      *
  40.      * there are constants defined in Tron.java for each of the four
  41.      * possible directions that the robot can go:
  42.      *  public static final int NORTH = 2;
  43.      *  public static final int EAST  = 1;
  44.      *  public static final int SOUTH = 0;
  45.      *  public static final int WEST  = 3;
  46.      *
  47.      * this method has to return one of those values.
  48.      * it is up to you to decide, based on the state of the board and
  49.      * everything you have learned about AI, which of these four values to
  50.      * return each time this method is called.
  51.      *
  52.      */
  53.     public int whereDoIGo() {
  54.         // move randomly
  55.         //return( Math.abs( random.nextInt() % 4 ));
  56.         // "tit for tat" player (copy human)
  57.         return( arena.player2.d );
  58.  
  59.     } /* end of whereDoIGo() */
  60.  
  61.    
  62. } /* end of MYPlayer class */



file Player.java
Codice sorgente - presumibilmente Java

  1. import java.awt.*;
  2. import java.lang.*;
  3. import java.applet.*;
  4.  
  5.  
  6.  
  7. public class Player {
  8.  
  9.     public String       name;
  10.     public Color        color;
  11.     public Arena        arena;
  12.     public byte         player_no;
  13.  
  14.     public boolean didsomething  = false;
  15.  
  16.     public int          x_max;
  17.     public int          y_max;
  18.     public static final int NORTH = 2;
  19.     public static final int EAST  = 1;
  20.     public static final int SOUTH = 0;
  21.     public static final int WEST  = 3;
  22.  
  23.     public static final int CRASH_DELTA = 10;
  24.  
  25.     // previous position in each dimension
  26.     public int          x0, y0;
  27.     // current position in each dimension
  28.     public int          x1, y1;
  29.     // direction of movement
  30.     public int          d;
  31.     // last direction of movement
  32.     public int          old_d;
  33.     public boolean      crash;
  34.     public int          score;
  35.  
  36.  
  37.  
  38.     /**
  39.      * Player constructor
  40.      *
  41.      */
  42.     public Player() {
  43.     } // end of default Player constructor
  44.  
  45.  
  46.  
  47.    
  48.     public void start() {
  49.         // default start method is empty
  50.     } // end of start()
  51.  
  52.  
  53.  
  54.    
  55.     public void stop()  {
  56.         // default stop method is empty
  57.     } // end of stop()
  58.  
  59.  
  60.  
  61.    
  62.     public void restart( boolean theOtherGuyCrashed ) {
  63.         // default restart method is empty
  64.     } // end of restart()
  65.  
  66.  
  67.  
  68.    
  69.     public int whereDoIGo() {
  70.         // default player is constant
  71.         return d;
  72.     } // end of whereDoIGo()
  73.  
  74.  
  75.  
  76.    
  77.     public void go( int x,int y ) {
  78.         x0 = x;
  79.         y0 = y;
  80.         x1 = x0;
  81.         y1 = y0;
  82.         old_d = d = SOUTH;
  83.         crash = false;
  84.         arena.board[x0][y0] = true;
  85.     }
  86.  
  87.  
  88.  
  89.  
  90.     public void step() {
  91.         if (( d = whereDoIGo()) != old_d ) {
  92.             old_d = d;
  93.         }
  94.         crash = markBoard( d );
  95.         if ( crash )
  96.             arena.state = arena.RESTARTING;
  97.     }
  98.  
  99.  
  100.  
  101.    
  102.     public void paint( Graphics g ) {
  103.         if ( crash ) {
  104.             g.setColor( Color.red );
  105.             g.drawLine( x1-CRASH_DELTA,y1-CRASH_DELTA,
  106.                         x1+CRASH_DELTA,y1+CRASH_DELTA );
  107.             g.drawLine( x1,y1-CRASH_DELTA,x1,y1+CRASH_DELTA );
  108.             g.drawLine( x1+CRASH_DELTA,y1-CRASH_DELTA,
  109.                         x1-CRASH_DELTA,y1+CRASH_DELTA );
  110.             g.drawLine( x1-CRASH_DELTA,y1,x1+CRASH_DELTA,y1 );
  111.         }
  112.         else {
  113.             g.setColor( color );
  114.             g.drawLine( x0,y0,x1,y1 );
  115.         }
  116.     }
  117.  
  118.  
  119.    
  120.    
  121.     public void newPos() {
  122.         x0 = x1;
  123.         y0 = y1;
  124.         paint( arena.getGraphics() );
  125.     }  
  126.  
  127.  
  128.    
  129.    
  130.     public boolean markBoard( int direction ) {
  131.         boolean r = false;
  132.         int i;
  133.         switch ( direction ) {
  134.         case SOUTH:
  135.             y1++;
  136.             if ( y1 >= y_max ) {
  137.                 y1 = 0;
  138.                 y0 = y1;
  139.             }
  140.             if ( r = arena.board[x1][y1] ) {
  141.                 break;
  142.             }
  143.             arena.board[x1][y1] = true;
  144.             break;
  145.         case NORTH:
  146.             y1--;
  147.             if ( y1 < 0 ) {
  148.                 y1 = y_max - 1;
  149.                 y0 = y1;
  150.             }
  151.             if ( r = arena.board[x1][y1] ) {
  152.                 break;
  153.             }
  154.             arena.board[x1][y1] = true;
  155.             break;
  156.         case EAST:
  157.             x1++;
  158.             if ( x1 >= x_max ) {
  159.                 x1 = 0;
  160.                 x0 = x1;
  161.             }
  162.             if ( r = arena.board[x1][y1] ) {
  163.                 break;
  164.             }
  165.             arena.board[x1][y1] = true;
  166.             break;
  167.         case WEST:
  168.             x1--;
  169.             if ( x1 < 0 ) {
  170.                 x1 = x_max - 1;
  171.                 x0 = x1;
  172.             }
  173.             if ( r = arena.board[x1][y1] ) {
  174.                 break;
  175.             }
  176.             arena.board[x1][y1] = true;
  177.             break;
  178.         default:
  179.             System.out.println( "UH-OH!" );
  180.             break;
  181.         }
  182.         return( r );
  183.     }
  184.  
  185.  
  186.    
  187.     public void tallyWin() {
  188.         score++;
  189.     }
  190.  
  191.  
  192.  
  193. } /* end of Player class */




file Tron.java
Codice sorgente - presumibilmente Java

  1. import java.awt.*;
  2. import java.lang.*;
  3. import java.applet.*;
  4. import java.util.*;
  5.  
  6.  
  7. public class Tron extends Frame {
  8.    
  9.     public static final int NORTH = 2;
  10.     public static final int EAST  = 1;
  11.     public static final int SOUTH = 0;
  12.     public static final int WEST  = 3;
  13.    
  14.     public String idParam;
  15.     public Arena  arena;
  16.     public Label  statusLabel;
  17.     public Button startButton;
  18.     public Button quitButton;
  19.     public Button pickGPButton;
  20.     public Button pickNNButton;
  21.     public Button pickMyButton;
  22.     public static Random random;
  23.  
  24.     public static String  gpfile = "gp.2220000";
  25.     public static String  nnfile = "nn.700";
  26.    
  27.     public static final int NONE  = -1;
  28.     public static final int HUMAN = 0;
  29.     public static final int GP    = 1;
  30.     public static final int NN    = 2;
  31.     public static final int MY    = 3;
  32.     public static int player1;
  33.     public static int player2;
  34.  
  35.    
  36.     public int robotScore, humanScore;
  37.  
  38.  
  39.  
  40.     /**
  41.      * main()
  42.      *
  43.      */
  44.     public static void main( String args[] ) {
  45.        
  46.         Tron tron = new Tron();
  47.         tron.setTitle( "Tron" );
  48.        
  49.         tron.player1 = NONE;
  50.         tron.player2 = HUMAN;
  51.  
  52.         tron.robotScore = 0;
  53.         tron.humanScore = 0;
  54.        
  55.         tron.arena = new Arena( tron );
  56.         tron.arena.resize( 256,256 );
  57.  
  58.         GridBagLayout layout = new GridBagLayout();
  59.         GridBagConstraints c = new GridBagConstraints();
  60.        
  61.         tron.setLayout( layout );
  62.        
  63.         c.gridx = 0;
  64.         c.gridy = 0;
  65.         c.gridwidth = 4;
  66.         layout.setConstraints( tron.arena,c );
  67.         tron.add( tron.arena );
  68.        
  69.         c.gridwidth = 1;
  70.         c.weightx   = 1;
  71.         c.anchor    = GridBagConstraints.CENTER;
  72.  
  73.         tron.pickGPButton = new Button( "GP robot" );
  74.         c.gridx = 0;
  75.         c.gridy = 1;
  76.         layout.setConstraints( tron.pickGPButton,c );
  77.         tron.add( tron.pickGPButton );
  78.        
  79.         tron.pickNNButton = new Button( "NN robot" );
  80.         c.gridx = 1;
  81.         c.gridy = 1;
  82.         layout.setConstraints( tron.pickNNButton,c );
  83.         tron.add( tron.pickNNButton );
  84.        
  85.         tron.pickMyButton = new Button( "My robot" );
  86.         c.gridx = 2;
  87.         c.gridy = 1;
  88.         layout.setConstraints( tron.pickMyButton,c );
  89.         tron.add( tron.pickMyButton );
  90.        
  91.         tron.startButton = new Button( "start" );
  92.         c.gridx = 3;
  93.         c.gridy = 1;
  94.         layout.setConstraints( tron.startButton,c );
  95.         tron.add( tron.startButton );
  96.         tron.startButton.disable();
  97.        
  98.         tron.quitButton = new Button( "quit" );
  99.         c.gridx = 4;
  100.         c.gridy = 1;
  101.         layout.setConstraints( tron.quitButton,c );
  102.         tron.add( tron.quitButton );
  103.        
  104.         tron.statusLabel = new
  105.             Label( "select robot opponent, then press 'start'         " );
  106.         c.gridx = 0;
  107.         c.gridy = 2;
  108.         c.gridwidth = 5;
  109.         layout.setConstraints( tron.statusLabel,c );
  110.         tron.add( tron.statusLabel );
  111.        
  112.         tron.pack();
  113.         tron.show();
  114.         tron.arena.start();
  115.  
  116.     } /* end of main() */
  117.  
  118.    
  119.    
  120.     /**
  121.      * updateScore()
  122.      *
  123.      */
  124.     public void updateScore() {
  125.         robotScore = arena.player1.score;
  126.         humanScore = arena.player2.score;
  127.         statusLabel.setText( "robot: [" + robotScore + "]  "+
  128.                              "human: [" + humanScore + "]" );
  129.     } /* end of updateScore() */
  130.  
  131.  
  132.    
  133.     /**
  134.      * start()
  135.      *
  136.      */
  137.     public void start() {
  138.         arena.start();
  139.     } /* end of start() */
  140.  
  141.    
  142.    
  143.     /**
  144.      * stop()
  145.      *
  146.      */
  147.     public void stop() {
  148.         arena.stop();
  149.     } /* end of stop() */
  150.  
  151.    
  152.    
  153.     /**
  154.      * destroy()
  155.      *
  156.      */
  157.     public void destroy() {
  158.     } /* end of destroy() */
  159.  
  160.    
  161.    
  162.     /**
  163.      * handleEvent()
  164.      *
  165.      */
  166.     public boolean handleEvent( Event evt ) {
  167.         if ( evt.id == Event.WINDOW_DESTROY ) {
  168.             System.exit( 1 );
  169.             return true;
  170.         }
  171.         return super.handleEvent( evt );
  172.     } /* end of handleEvent() */
  173.  
  174.    
  175.    
  176.     /**
  177.      * action()
  178.      *
  179.      */
  180.     public boolean action( Event evt,Object arg ) {
  181.         if ( arg.equals( "quit" )) {
  182.             System.exit( 1 );
  183.             return true;
  184.         }
  185.         else if ( arg.equals( "start" )) {
  186.             arena.startAgain = true;
  187.             return true;
  188.         }
  189.         else if ( arg.equals( "GP robot" )) {
  190.             statusLabel.setText( "robot will be controlled by GP" );
  191.             player1 = GP;
  192.             arena.selectPlayer1( player1,gpfile );
  193.             startButton.enable();
  194.             return true;
  195.         }
  196.         else if ( arg.equals( "NN robot" )) {
  197.             statusLabel.setText( "robot will be controlled by NN" );
  198.             player1 = NN;
  199.             arena.selectPlayer1( player1,nnfile );
  200.             startButton.enable();
  201.             return true;
  202.         }
  203.         else if ( arg.equals( "My robot" )) {
  204.             statusLabel.setText( "robot will be controlled by my code" );
  205.             player1 = MY;
  206.             arena.selectPlayer1( player1,nnfile );
  207.             startButton.enable();
  208.             return true;
  209.         }
  210.         return false;
  211.     } /* end of action() */
  212.    
  213.  
  214.    
  215.     /**
  216.      * keyDown()
  217.      *
  218.      */
  219.     public boolean keyDown( Event e,int key ) {
  220.         if ( player2 == HUMAN ) {
  221.             switch ( key ) {
  222.             case Event.UP:
  223.             case (int) '8':
  224.             case (int) 'w':
  225.                 arena.player2.d = NORTH;
  226.                 arena.player2.didsomething = true;
  227.                 break;
  228.             case Event.DOWN:
  229.             case (int) '2':
  230.             case (int) 'z':
  231.                 arena.player2.d = SOUTH;
  232.                 arena.player2.didsomething = true;
  233.                 break;
  234.             case Event.LEFT:
  235.             case (int) '4':
  236.             case (int) 'a':
  237.                 arena.player2.d = WEST;
  238.                 arena.player2.didsomething = true;
  239.                 break;
  240.             case Event.RIGHT:
  241.             case (int) '6':
  242.             case (int) 's':
  243.                 arena.player2.d = EAST;
  244.                 arena.player2.didsomething = true;
  245.                 break;
  246.             }
  247.             return true;
  248.         }
  249.         else {
  250.             return false;
  251.         }
  252.     } /* end of keyDown() */
  253.  
  254.    
  255.    
  256. } /* end of Tron class */


Ultima modifica effettuata da sheva7 il 17/01/2013 alle 11:55
PM Quote
Avatar
lorenzo (Normal User)
Guru


Messaggi: 1178
Iscritto: 15/04/2008

Segnala al moderatore
Postato alle 21:04
Giovedì, 17/01/2013
scusa la mia ignoranza...ma cosa ci dovrebbe essere da fixare?
Non penserai mica che uno si possa mettere ad analizzare tutto quel codice per capire cosa non va vero??

Almeno dicci cosa non funziona!

PM Quote
Avatar
sheva7 (Normal User)
Newbie


Messaggi: 10
Iscritto: 13/01/2013

Segnala al moderatore
Postato alle 17:42
Venerdì, 18/01/2013
Ok..
Intanto, Eclipse mi segnala errori per ogni istanza di gpplayer e nnplayer su Arena.java

PM Quote
Avatar
Tw1st3r_Ev0 (Normal User)
Newbie


Messaggi: 10
Iscritto: 18/01/2013

Segnala al moderatore
Postato alle 22:05
Domenica, 20/01/2013
Devi importare l'intero progetto con tutti i sorgenti del gioco altrimenti ti da errori a cavolo. Se lo hai già fatto allora prova a risolvere gli errori delle istanze perchè penso saranno quelli che ti fanno generare errori a cascata. ;)

PM Quote
Avatar
sheva7 (Normal User)
Newbie


Messaggi: 10
Iscritto: 13/01/2013

Segnala al moderatore
Postato alle 1:24
Lunedì, 21/01/2013
dopo aver importato tutto, mi da questi errori:

Exception in thread "main" java.lang.Error: Unresolved compilation problems:
    GPPlayer cannot be resolved to a type
    NNPlayer cannot be resolved to a type
    GPPlayer cannot be resolved to a type
    GPPlayer cannot be resolved to a type
    NNPlayer cannot be resolved to a type
    NNPlayer cannot be resolved to a type
    GPPlayer cannot be resolved to a type
    GPPlayer cannot be resolved to a type
    NNPlayer cannot be resolved to a type
    NNPlayer cannot be resolved to a type

    at Arena.<init>(Arena.java:30)
    at Tron.main(Tron.java:55)

PM Quote
Avatar
Tw1st3r_Ev0 (Normal User)
Newbie


Messaggi: 10
Iscritto: 18/01/2013

Segnala al moderatore
Postato alle 12:44
Lunedì, 21/01/2013
Non saprei dirti nel dettaglio il motivo di questi errori, forse sono dovuti al fatto che non hai importato per bene i sorgenti su un progetto perchè se dici che il codice per intero risulta esatto, allora non dovrebbe darti ulteriori errori (massimo qualche warning banale)! Prova a creare un nuovo progetto e poi cominci a trasferire per bene secondo come dovrebbero essere strutturati, tutti i sorgenti :)
Per esperienze personali, questi errori su eclipse li risolvevo cosi quando scaricavo sorgenti sul web, in caso se hai un altro IDE come NetBeans prova a fare la stessa procedura. :k:

PM Quote
Avatar
sheva7 (Normal User)
Newbie


Messaggi: 10
Iscritto: 13/01/2013

Segnala al moderatore
Postato alle 19:19
Martedì, 22/01/2013
i sorgenti li ho importati tutti ma a quanto pare il codice ha dei problemi..
Eclipse mi ha detto che sono questi:

GPPlayer cannot be resolved to a type
NNPlayer cannot be resolved to a type

ma non riesco a capire cosa c'è che non va :d

PM Quote
Avatar
Tw1st3r_Ev0 (Normal User)
Newbie


Messaggi: 10
Iscritto: 18/01/2013

Segnala al moderatore
Postato alle 18:54
Mercoledì, 23/01/2013
Un mio consiglio è, a sto punto, di cercare un altro sorgente dello stesso gioco ma magari già strutturato sotto forma di file progetto. O sennò vedi se ne trovi qualcun'altro senza errori.
Comunque non è una cosa mai accaduta su sorgenti presi dal web, la maggior parte li fanno apposta per non essere modificati facilmente, infatti basta anche solo sfasare una variabile per far "incazzare" il compilatore che ti segnala una decina o ventina di errori. xD
Prova ad aspettare che risponda qualcuno piu esperto di me in Java, essendo da poco approdato in questo linguaggio particolarmente complicato, alcune cose le devo ancora imparare. :yup:

PM Quote
Avatar
sheva7 (Normal User)
Newbie


Messaggi: 10
Iscritto: 13/01/2013

Segnala al moderatore
Postato alle 15:29
Lunedì, 28/01/2013
Il gioco è TRON peccato che non riesco a trovarne una versione migliore su internet :(
Se qualcuno mi riuscisse ad aiutare a risolvere quegli errori, poi posso iniziare a sistemarlo...

PM Quote