Package com.sgfj

Examples of com.sgfj.SGFPoint


                        zoomW = zoomH = Math.max(bsz / 2 + 2, Math.min(bsz, 9));
                        if (mode.showCursor || game.lastMove < 0) {
                            zoomX = cursorX;
                            zoomY = cursorY;
                        } else {
                            SGFPoint p = game.board.xy(game.lastMove);
                            zoomX = p.x;
                            zoomY = p.y;
                        }
                        zoomX -= zoomW / 2;
                        zoomY -= zoomH / 2;
View Full Code Here


                        zoomW = zoomH = Math.max(bsz / 2 + 2, Math.min(bsz, 9));
                        if (mode.showCursor || game.lastMove < 0) {
                            zoomX = cursorX;
                            zoomY = cursorY;
                        } else {
                            SGFPoint p = game.board.xy(game.lastMove);
                            zoomX = p.x;
                            zoomY = p.y;
                        }
                        zoomX -= zoomW / 2;
                        zoomY -= zoomH / 2;
View Full Code Here

            DocumentedGame game = new DocumentedGame(ni.current());
            //System.out.print(game.board.toString());
            assertEquals(wCaptures, game.whiteCaptures);
            assertEquals(bCaptures, game.blackCaptures);
            for (int pos = 0; pos < result.length; pos++) {
                SGFPoint p = game.board.xy(pos);
                assertEquals("" + p.x + "," + p.y + ":", result[pos], game.board.get(pos));
            }
        } catch (SGFInvalidDataRequestException e) {
            e.printStackTrace();
            fail("Unexpected!");
View Full Code Here

            assertNull(i.prevVariant(false));
            assertNull(i.nextVariant(false));

            i.next(true);
            move = (SGFPointProperty) i.current().getProperty(SGFPropertyName.W);
            assertEquals(new SGFPointProperty(SGFPropertyName.W, new SGFPoint(4, 3)), move);
            assertFalse(i.current().hasProperty(SGFPropertyName.B));
            assertSame(tree, i.prev(false));
            assertNull(i.prevVariant(false));
            assertNull(i.nextVariant(false));

            i.next(true);
            move = (SGFPointProperty) i.current().getProperty(SGFPropertyName.B);
            assertEquals(move, new SGFPointProperty(SGFPropertyName.B, new SGFPoint(4, 2)));
            assertFalse(i.current().hasProperty(SGFPropertyName.W));
            //assertSame(p.getParent(), tree);
            assertNull(null, i.next(false));
            assertNull(null, i.prevVariant(false));
            //assertNotSame(p.getNext(), null);

            i.nextVariant(true);
            move = (SGFPointProperty) i.current().getProperty(SGFPropertyName.B);
            assertEquals(new SGFPointProperty(SGFPropertyName.B, new SGFPoint(4, 6)), move);
            assertFalse(i.current().hasProperty(SGFPropertyName.W));
            //assertSame(p.getParent(), tree);
            //assertSame(p.next(), null);
            assertNull(i.nextVariant(false));
            //assertNotSame(p.getNext(), null);
View Full Code Here

    }

    public void testGetProperty2() {
        try {
            SGFNode node = new SGFNode();
            SGFPointProperty pprop = new SGFPointProperty(SGFPropertyName.W, new SGFPoint(1, 2));
            node.addPropertyNoCheck(pprop);
            assertEquals(pprop, node.getProperty(SGFPropertyName.W));

            SGFIntProperty iprop = new SGFIntProperty(SGFPropertyName.SZ, 19);
            node.addPropertyNoCheck(iprop);
View Full Code Here

import junit.framework.TestCase;

public class SGFLabelPropertyTest extends TestCase {

    public void testGetText() {
        SGFPoint p = new SGFPoint(0, 0);
        char[] l = {'A'};
        SGFLabelProperty prop = new SGFLabelProperty(SGFPropertyName.LB, p, l);
        assertEquals(new String(l), prop.getText());
        assertEquals(p, prop.getPoint());
    }
View Full Code Here

                        zoomW = zoomH = Math.max(bsz / 2 + 2, Math.min(bsz, 9));
                        if (mode.showCursor || game.lastMove < 0) {
                            zoomX = cursorX;
                            zoomY = cursorY;
                        } else {
                            SGFPoint p = game.board.xy(game.lastMove);
                            zoomX = p.x;
                            zoomY = p.y;
                        }
                        zoomX -= zoomW / 2;
                        zoomY -= zoomH / 2;
View Full Code Here

     * @throws GameException Illegal move.
     */
    protected void play(int pos, byte color, boolean allowIllegal) throws GameException {
        if (!allowIllegal) {
            if (board.get(pos) != Board.NONE) {
                SGFPoint p = board.xy(pos);
                throw new GameOverStoneException("Stone " + board.get(pos) + " already at " + p.x + "," + p.y);
            }
            if (pos == koMove)
                throw new GameKoMoveException();
            if (color != colorToPlay)
                throw new GameWrongHandException("Expected: " + colorToPlay + ", got: " + color);
            //System.out.println("Move expected: " + colorToPlay + ", got: " + color);
        }

        advance();

        set(pos, color);

        Group deadGroup = new Group(board.maxPos());
        byte otherColor = Board.other(color);

        // collect dead stones
        board.clearBits(Board.M_DEAD);
        collectDead(board.n(pos), otherColor, deadGroup);
        collectDead(board.e(pos), otherColor, deadGroup);
        collectDead(board.s(pos), otherColor, deadGroup);
        collectDead(board.w(pos), otherColor, deadGroup);

        if (deadGroup.size == 0) {
            // no deaders, check if suicide
            board.getGroup(pos, deadGroup);
            if (deadGroup.liberties == 0) {
                if (!allowIllegal) {
                    set(pos, Board.NONE);
                    history.pop();
                    SGFPoint p = board.xy(pos);
                    throw new GameSuicideMoveException(p.x + "," + p.y);
                } // else we remove suicidal group
            } else
                deadGroup.size = 0;
        }
View Full Code Here

                String lastMovePos;
                if (lastMove < 0)
                    lastMovePos = "Pass";
                else {
                    char[] ca = { 'A' };
                    SGFPoint p = board.xy(lastMove);
                    ca[0] += p.x;
                    if (ca[0] >= 'I') // I is skipped
                        ca[0]++;
                    lastMovePos = new String(ca) + Integer.toString(board.size() - p.y);
                }
View Full Code Here

                    case '2':
                        colorToPlay = Board.WHITE;
                        break;
                    }
                } else if (prop.name() == SGFPropertyName.AW) {
                    SGFPoint p = prop.getPoint();
                    int pos = board.pos(p);
                    set(pos, Board.WHITE);
                } else if (prop.name() == SGFPropertyName.AB) {
                    SGFPoint p = prop.getPoint();
                    int pos = board.pos(p);
                    set(pos, Board.BLACK);
                } else if (prop.name() == SGFPropertyName.AE) {
                    SGFPoint p = prop.getPoint();
                    int pos = board.pos(p);
                    set(pos, Board.NONE);
                }
            } catch (SGFInvalidDataRequestException e1) {
                // DO NOTHING
View Full Code Here

TOP

Related Classes of com.sgfj.SGFPoint

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.