Package net.sourceforge.java_stratego.stratego

Examples of net.sourceforge.java_stratego.stratego.Spot


      board.setLayout(new GridLayout(10, 10 , 0, 0));
      board.setBounds(new Rectangle(5, 5, 500, 500));
      for (int j=0;j<10;j++)
      for (int i=0;i<10;i++)
      {
        grid[i][j] = new PieceButton(this, new Spot(i, j));
        board.add(grid[i][j]);
      }
    }
    return board;
  }
View Full Code Here


      case GRID:
        x = in.readInt();
        y = in.readInt();
        color = in.readInt();
        rank = in.readInt();
        view.update(new Spot(x, y), new Piece(0, color, Rank.values()[rank]));
        return true;
      case TRAY:
        x = in.readInt();
        color = in.readInt();
        rank = in.readInt();
View Full Code Here

            throw new Exception();
         
          for (int k=0;k<board.getTraySize();k++)
            if (board.getTrayPiece(k).getColor() == Settings.topColor)
            {
              engine.aiReturnPlace(board.getTrayPiece(k), new Spot(x, y));
              break;
            }
        }
      }
      catch (IOException e)
      {
        JOptionPane.showMessageDialog(null, "File Format Error: Unexpected end of file.",
            "AI", JOptionPane.INFORMATION_MESSAGE);
      }
      catch (Exception e)
      {
        JOptionPane.showMessageDialog(null, "File Format Error: Invalid File Structure.",
            "AI", JOptionPane.INFORMATION_MESSAGE);
      }
      finally
      {
        try {
          in.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      break;
    }
   
    //double check the ai setup
    for (int i=0;i<10;i++)
    for (int j=0;j<4; j++)
    {
      Piece p = null;
      for (int k=0;k<board.getTraySize();k++)
        if (board.getTrayPiece(k).getColor() == Settings.topColor)
        {
          p = board.getTrayPiece(k);
          break;
        }

      if (p==null)
        break;
       
      engine.aiReturnPlace(p, new Spot(i, j));
    }
   
    //if the user didn't finish placing pieces just put them on
    for (int i=0;i<10;i++)
    for (int j=6;j<10;j++)
    {
      Piece p = null;
      for (int k=0;k<board.getTraySize();k++)
        if (board.getTrayPiece(k).getColor() != Settings.topColor)
        {
          p = board.getTrayPiece(k);
          break;
        }

      if (p==null)
        break;
       
      engine.aiReturnPlace(p, new Spot(i, j));
    }
   
    engine.play();
  }
View Full Code Here

    int threadc = 0;
   
    for (int i=0;i<10;i++)
    for (int j=0;j<10;j++)
    {
      Spot f = new Spot(i, j);
      Spot t = null;
      if (b.getPiece(f) == null)
        continue;
      if (b.getPiece(f).getColor() != Settings.topColor)
        continue;
       
      for (int k=0;k<4;k++)
      {
        switch (k)
        {
        case 0:
          if (i==0)
            continue;
          t = new Spot(i-1, j);
          break;
        case 1:
          if (j==0)
            continue;
          t = new Spot(i, j-1);
          break;
        case 2:
          if (i==9)
            continue;
          t = new Spot(i+1, j);
          break;
        case 3:
          if (j==9)
            continue;
          t = new Spot(i, j+1);
          break;
        }
        if (b.validMove(f, t))
        {
          tmpM = new Move(b.getPiece(f), f, t);
View Full Code Here

      value *= -3;
   
    for (int i=0;i<10;i++)
    for (int j=0;j<10;j++)
    {
      Spot f = new Spot(i, j);
      Spot t = null;
      if (b.getPiece(f) == null)
        continue;
      if (b.getPiece(f).getColor() != turn)
        continue;
       
      for (int k=0;k<4;k++)
      {
        switch (k)
        {
        case 0:
          if (j==9)
            continue;
          t = new Spot(i, j+1);
          break;
        case 1:
          if (i==9)
            continue;
          t = new Spot(i+1, j);
          break;
        case 2:
          if (i==0)
            continue;
          t = new Spot(i-1, j);
          break;
        case 3:
          if (j==0)
            continue;
          t = new Spot(i, j-1);
          break;
        }
        if (b.validMove(f, t))
        {
          hasMove = true;
View Full Code Here

      for (int i=0;i<10;i++)
      for (int j=l_limit;j<u_limit;j++)
        if (board.getPiece(i, j) == null)
          for (int k=0;k<board.getTraySize();k++)
            if (getTrayPiece(k).getColor() == color)
              setupPlacePiece(getTrayPiece(k), new Spot(i, j));
    }
 
    if (board.getTraySize() == 0)
      status = Status.PLAYING;
  }
View Full Code Here

      {
        switch (Message.values()[type])
        {
        case MOVE:
          int x1, x2, y1, y2, rank;
          Spot from, to;
          Piece p;
          x1 = in.readInt();
          y1 = in.readInt();
          x2 = in.readInt();
          y2 = in.readInt();
          rank = in.readInt();
          if (x1 < 0)
          {
            from = Board.IN_TRAY;
            p = new Piece(0, 0, Rank.values()[rank]);
          }
          else
          {
            from = new Spot(x1, y1);
            p = engine.getBoardPiece(x1, y1);
          }
          if (x2 < 0)
            to = Board.IN_TRAY;
          else
            to = new Spot(x2, y2);

          game.engine.requestMove(new Move(p, from, to), player);
          break;
        case PLAY:
          game.engine.play(player);
View Full Code Here

          y = in.read();
       
        if (x<0||x>9||y<0||y>3)
          throw new Exception();
       
        board.move(new Move(board.getTrayPiece(0), EditorBoard.IN_TRAY, new Spot(x, y)));
      }
    }
    catch (IOException e)
    {
      JOptionPane.showMessageDialog(getJFrame(), "File Format Error: Unexpected end of file.",
View Full Code Here

TOP

Related Classes of net.sourceforge.java_stratego.stratego.Spot

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.