Examples of Piece


Examples of com.barrybecker4.puzzle.redpuzzle.model.Piece

    @Override
    public List<Piece> legalMoves(PieceList position) {

        List<Piece> moves = new LinkedList<Piece>();
        for  (int i = 0; i < NUM_PIECES; i++) {
            Piece p = SHUFFLED_PIECES.get(i);
            if (!position.contains(p)) {
                int r = 0;
                // see if any of the rotations fit.
                while (!position.fits(p) && r < 4) {
                    p = p.rotate();
                    r++;
                }
                if (r < 4) {
                    moves.add(p);
                }
View Full Code Here

Examples of com.barrybecker4.puzzle.redpuzzle.model.Piece

        // allocates a little more space tha we actually use, but simpler this way.
        char[][] nubChecks = new char[7][7];

        if (board== null) return;
        for ( i = 0; i < board.size(); i++ ) {
            Piece p = board.get( i );
            int row = i / DIM;
            int col = i % DIM;
            drawPiece(g, p, col, row, nubChecks);
        }
    }
View Full Code Here

Examples of com.barrybecker4.puzzle.redpuzzle.model.Piece

        if (pieces.size() == 0)
            return pieces;

        int k = 0;
        while (!solved && k < pieces.size() ) {
            Piece p = pieces.get(k);
            int r = 0;
            // try the 4 rotations
            while (!solved && r < 4) {
                 numTries_++;
                 if ( solution_.fits(p) ) {
                    solution_ = solution_.add( p );
                    pieces = pieces.remove( p );
                    puzzlePanel.refresh(solution_, numTries_);
                    puzzlePanel.makeSound();

                    // call solvePuzzle with a simpler case (one less piece to solve)
                    pieces = solvePuzzle( puzzlePanel, pieces, k);
                    solved = pieces.size() == 0;
                }
                if (!solved) {
                    p = p.rotate();
                }
                r++;
            }
            k++;
        }

        if (!solved && solution_.size() > 0) {
            // backtrack.
            Piece p = solution_.getLast();
            solution_ = solution_.removeLast();
            // put it back where we took it from,
            // so our list of unplaced pieces does not get out of order.
            pieces = pieces.add(i, p);
        }
View Full Code Here

Examples of com.ir.objects.Piece

      printError(1);
      return;
    }
   
    // Create a knight chess piece
    Piece knight = new Knight(startSquare);
   
    // Setup our A* Search, and begin searching
    AStarSearch aStar = new AStarSearch(startSquare, endSquare, knight);
    Path p = aStar.Search();
   
View Full Code Here

Examples of com.music.model.persistent.Piece

    private Map<String, Deque<WebSocketMessage<?>>> messages = new ConcurrentHashMap<>();

    @Before
    public void init() {
        MockitoAnnotations.initMocks(this);
        piece = new Piece();
        piece.setId(1L);
        piece.setTempo(60);
        piece.setMetreNumerator(4);
        piece.setMetreDenominator(8);
        piece.setMainInstrument(1);
View Full Code Here

Examples of com.music.model.persistent.Piece

    }

    @Test
    public void derivedMetreTest() {
        Game game = new Game("1", null);
        Piece piece = new Piece();
        piece.setMetreNumerator(4);
        piece.setMetreDenominator(4);
        Assert.assertFalse(game.isNotDerivedMetre(piece, new int[] {8, 8}));
        Assert.assertTrue(game.isNotDerivedMetre(piece, new int[] {4, 8}));

        piece.setMetreNumerator(8);
        piece.setMetreDenominator(8);
        Assert.assertFalse(game.isNotDerivedMetre(piece, new int[] {4, 4}));
        Assert.assertTrue(game.isNotDerivedMetre(piece, new int[] {2, 4}));

        piece.setMetreNumerator(2);
        piece.setMetreDenominator(4);
        Assert.assertFalse(game.isNotDerivedMetre(piece, new int[] {4, 8}));
        Assert.assertFalse(game.isNotDerivedMetre(piece, new int[] {2, 4}));
        Assert.assertTrue(game.isNotDerivedMetre(piece, new int[] {4, 4}));

    }
View Full Code Here

Examples of com.music.model.persistent.Piece

                prefs.setTempo(Tempo.ANY);
                pieces = pieceDao.getByPreferences(prefs);
            }
        }

        Piece piece = pieces.get(random.nextInt(pieces.size()));
        meta.setPiece(piece);
        return meta;
    }
View Full Code Here

Examples of com.music.model.persistent.Piece

    }

    @RequestMapping("/track/{id}")
    public String getTrack(@PathVariable long id, Model model) {
        model.addAttribute("pieceId", id);
        Piece piece = pieceService.getPiece(id);
        if (piece != null) {
            model.addAttribute("title", piece.getTitle());
            model.addAttribute("likes", piece.getLikes());
            return "track";
        } else {
            logger.warn("No track with id=" + id + " found");
            return "redirect:/";
        }
View Full Code Here

Examples of com.music.model.persistent.Piece

            midi = baos.toByteArray();
            mp3 = generator.toMp3(midi);
        } catch (Exception e) {
            throw new IllegalStateException(e);
        }
        Piece piece = savePiece(ctx, mp3, midi);

        return piece.getId();
    }
View Full Code Here

Examples of com.music.model.persistent.Piece

            PieceEvaluation evaluation = new PieceEvaluation();
            evaluation.setDateTime(new DateTime());
            if (userId != null) {
                evaluation.setUser(dao.getById(User.class, userId));
            }
            Piece piece = dao.getById(Piece.class, pieceId);
            evaluation.setPiece(piece);
            evaluation.setPositive(positive);
            evaluation.setIp(ip);
            dao.persist(evaluation);

            // not exact due to race condition - a job should count likes every
            // X minutes
            if (positive) {
                piece.setLikes(piece.getLikes() + 1);
            } else {
                piece.setLikes(piece.getLikes() - 1);
            }
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.