pescetti-0.5/0000775000175000017500000000000011306704703011651 5ustar mjj29mjj29pescetti-0.5/Makefile0000644000175000017500000001032510765746034013323 0ustar mjj29mjj29JAVA?=java JAVAC?=javac JAVADOC?=javadoc JAR?=jar JCFLAGS?=-source 1.5 -Xlint:all MSGFMT?=msgfmt PREFIX?=/usr/local JARDIR?=$(PREFIX)/share/java DOCDIR?=$(PREFIX)/share/doc/pescetti/ MANDIR?=$(PREFIX)/share/man/man1/ SHAREDIR?=$(PREFIX)/share/pescetti/ BINDIR?=$(PREFIX)/bin/ DEBUG?=disable CLASSPATH=classes:/usr/share/java/debug-$(DEBUG).jar:/usr/share/java/itext.jar VERSION=$(shell sed -n '1s/^Version \([0-9.]*\):$$/\1/p' changelog) SRC=$(shell find cx -name '*.java') all: pescetti-$(VERSION).jar dup2dds-$(VERSION).jar bin/dup2dds pescetti.1 bin/pescetti dealing-howto.pdf .bin: mkdir -p bin touch .bin .testbin: mkdir -p testbin touch .testbin classes: .classes .classes: $(SRC) translations/*.po mkdir -p classes $(JAVAC) $(JCFLAGS) -cp $(CLASSPATH):classes -d classes $(SRC) (cd translations; for i in *.po; do $(MSGFMT) --java2 -r pescetti_localized -d ../classes -l $${i%.po} $$i; done) $(MSGFMT) --java2 -r pescetti_localized -d classes translations/en_GB.po touch .classes clean: rm -rf classes bin testbin pescetti-$(VERSION) rm -f .classes .bin .testbin *.tar.gz *.jar pescetti.1 *Manifest.txt *.dvi *.pdf *.ps *.log *.aux pescetti-$(VERSION).jar: PescettiManifest.txt .classes (cd classes; $(JAR) cfm ../$@ ../$< `find cx -name '*.class' -and -not -name 'dup2dds.class'` *localized*class) dup2dds-$(VERSION).jar: DupManifest.txt .classes (cd classes; $(JAR) cfm ../$@ ../$< cx/ath/matthew/pescetti/dup2dds.class) pescetti-$(VERSION).tar.gz: Makefile cx README INSTALL COPYING changelog pescetti.sh pescetti.sgml Manifest.txt.in dealing-howto.tex translations dup2dds.sh dup2dds.1 pbn2dds pbn2dds.1 mkdir -p pescetti-$(VERSION) cp -a $^ pescetti-$(VERSION) tar zcf $@ pescetti-$(VERSION) itext.jar: ln -sf /usr/share/java/itext.jar . debug-$(DEBUG).jar: ln -sf /usr/share/java/debug-$(DEBUG).jar . bin/%: %.sh .bin sed 's,\%JARPATH\%,$(JARDIR),;s,\%VERSION\%,$(VERSION),;s,\%DEBUG\%,$(DEBUG),;s,\%JAVA\%,$(JAVA),' < $< > $@ testbin/%: %.sh .testbin dup2dds-$(VERSION).jar pescetti-$(VERSION).jar debug-$(DEBUG).jar itext.jar sed 's,\%JARPATH\%,.,;s,\%VERSION\%,$(VERSION),;s,\%DEBUG\%,$(DEBUG),;s,\%JAVA\%,$(JAVA),' < $< > $@ chmod 755 $@ %.pdf: %.tex pdflatex $^ %.1: %.sgml docbook-to-man $< > $@ DupManifest.txt: Manifest.txt.in echo Main-Class: cx.ath.matthew.pescetti.dup2dds > $@ echo Class-Path: $(SHAREDIR)/pescetti.jar >> $@ cat $< >> $@ echo "Implementation-Version: $(VERSION)" >> $@ PescettiManifest.txt: Manifest.txt.in echo Main-Class: cx.ath.matthew.pescetti.pescetti > $@ ifeq ($(DEBUG),enable) echo Class-Path: $(JARDIR)/debug-$(DEBUG).jar $(JARDIR)/itext.jar >> $@ else echo Class-Path: $(JARDIR)/itext.jar >> $@ endif cat $< >> $@ echo "Implementation-Version: $(VERSION)" >> $@ translations/en_GB.po: $(SRC) echo "#java-format" > $@ sed -n '/_(/s/.*_("\([^"]*\)").*/\1/p' $^ | sort -u | sed 's/\(.*\)/msgid "\1"\nmsgstr "\1"/' >> $@ install: pescetti.1 dup2dds.1 pbn2dds.1 bin/dup2dds bin/pescetti pescetti-$(VERSION).jar dup2dds-$(VERSION).jar changelog COPYING INSTALL README dealing-howto.pdf install -d $(DESTDIR)$(BINDIR) install bin/pescetti $(DESTDIR)$(BINDIR) install bin/dup2dds $(DESTDIR)$(BINDIR) install pbn2dds $(DESTDIR)$(BINDIR) install -d $(DESTDIR)$(MANDIR) install -m 644 pescetti.1 dup2dds.1 $(DESTDIR)$(MANDIR) install -d $(DESTDIR)$(SHAREDIR) install -m 644 pescetti-$(VERSION).jar $(DESTDIR)$(SHAREDIR) install -m 644 dup2dds-$(VERSION).jar $(DESTDIR)$(SHAREDIR) ln -sf pescetti-$(VERSION).jar $(DESTDIR)$(SHAREDIR)/pescetti.jar ln -sf dup2dds-$(VERSION).jar $(DESTDIR)$(SHAREDIR)/dup2dds.jar install -d $(DESTDIR)$(DOCDIR) install -m 644 changelog COPYING INSTALL README dealing-howto.pdf $(DESTDIR)$(DOCDIR) uninstall: rm -f $(DESTDIR)$(BINDIR)/pescetti $(DESTDIR)$(BINDIR)/pbn2dds rm -f $(DESTDIR)$(SHAREDIR)/pescetti-$(VERSION).jar $(DESTDIR)$(SHAREDIR)/pescetti.jar rm -f $(DESTDIR)$(SHAREDIR)/dup2dds-$(VERSION).jar $(DESTDIR)$(SHAREDIR)/dup2dds.jar rm -f $(DESTDIR)$(MANDIR)/pescetti.1 rm -f $(DESTDIR)$(MANDIR)/dup2dds.1 rm -f $(DESTDIR)$(DOCDIR)/changelog $(DESTDIR)$(DOCDIR)/COPYING $(DESTDIR)$(DOCDIR)/INSTALL $(DESTDIR)$(DOCDIR)/README $(DESTDIR)$(DOCDIR)/dealing-howto.pdf -rmdir $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR) $(DESTDIR)$(SHAREDIR) $(DESTDIR)$(DOCDIR) pescetti-0.5/cx/0000775000175000017500000000000010702537254012267 5ustar mjj29mjj29pescetti-0.5/cx/ath/0000775000175000017500000000000010702537254013043 5ustar mjj29mjj29pescetti-0.5/cx/ath/matthew/0000775000175000017500000000000010702537254014514 5ustar mjj29mjj29pescetti-0.5/cx/ath/matthew/pescetti/0000775000175000017500000000000011303202176016322 5ustar mjj29mjj29pescetti-0.5/cx/ath/matthew/pescetti/.Constants.java.swp0000600000175000017500000003000010705201050022001 0ustar mjj29mjj29b0VIM 7.0Goy-mjj29adonis~mjj29/scm/bridgedeal/cx/ath/matthew/pescetti/Constants.java 3210#"! Utp/adX/]v) E % " ~ S & ~ T +  n f[ZX}} public static final int WEST = 3; public static final int SOUTH = 2; public static final int EAST = 1; public static final int NORTH = 0; public static final char[] CARD = { '!', '!', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A' }; public static final char[] SUIT = { '!', 'S', 'H', 'D', 'C', 'N' }; public static final String[] PLAYER = { "North", "East", "South", "West" }; {CLUBS | ACE, CLUBS | KING, CLUBS | QUEEN, CLUBS | JACK, CLUBS | TEN, CLUBS | 9, CLUBS | 8, CLUBS | 7, CLUBS | 6, CLUBS | 5, CLUBS | 4, CLUBS | 3, CLUBS | 2}}; {DIAMONDS | ACE, DIAMONDS | KING, DIAMONDS | QUEEN, DIAMONDS | JACK, DIAMONDS | TEN, DIAMONDS | 9, DIAMONDS | 8, DIAMONDS | 7, DIAMONDS | 6, DIAMONDS | 5, DIAMONDS | 4, DIAMONDS | 3, DIAMONDS | 2}, {HEARTS | ACE, HEARTS | KING, HEARTS | QUEEN, HEARTS | JACK, HEARTS | TEN, HEARTS | 9, HEARTS | 8, HEARTS | 7, HEARTS | 6, HEARTS | 5, HEARTS | 4, HEARTS | 3, HEARTS | 2}, {SPADES | ACE, SPADES | KING, SPADES | QUEEN, SPADES | JACK, SPADES | TEN, SPADES | 9, SPADES | 8, SPADES | 7, SPADES | 6, SPADES | 5, SPADES | 4, SPADES | 3, SPADES | 2}, public static final byte[][] INITIAL_HAND = { public static final byte ACE = 0x0E; public static final byte KING = 0x0D; public static final byte QUEEN = 0x0C; public static final byte JACK = 0x0B; public static final byte TEN = 0x0A; public static final byte NOTRUMPS = 0x50; public static final byte CLUBS = 0x40; public static final byte DIAMONDS = 0x30; public static final byte HEARTS = 0x20; public static final byte SPADES = 0x10;{public interface Constantspackage cx.ath.matthew.pescetti; */ * * To Contact me, please email src@matthew.ath.cx * * Boston, MA 02111-1307, USA. * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * copy of the GNU General Public License along with this program; if not, * GNU General Public License for more details. You should have received a * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * it will be useful, but WITHOUT ANY WARRANTY; without even the implied * the Free Software Foundation. This program is distributed in the hope that * under the terms of the GNU General Public License Version 2 as published by * This program is free software; you can redistribute it and/or modify it * * Copyright (C) 2007 Matthew Johnson * * Pescetti Pseudo-Duplimate Generator/* pescetti-0.5/cx/ath/matthew/pescetti/.HTMLPrinter.java.swp0000644000175000017500000005000010705201156022156 0ustar mjj29mjj29b0VIM 7.0YGo*mjj29adonis~mjj29/scm/bridgedeal/cx/ath/matthew/pescetti/HTMLPrinter.javautf-8 3210#"! Utp!8nad 9 !]v) E % " H F * i 9 1  l K + x O f1qL!~yxV:sIR3lT* } } else if ("pdf".equals(format)) { out.println(""); } else if ("html".equals(format)) { out.println(); if ("txt".equals(format)) { { public void close() } } } else if ("pdf".equals(format)) { out.println("

"); } out.println("
"); if (19 == k % 20) out.print("     "); if (3 == k % 4) out.print(perm[k]+1); for (int k = 0; k < 52; k++) { out.print("

"); out.println("

Board "+num+"

"); } else if ("html".equals(format)) { out.println(); out.println(); } } out.print(" "); out.println(); if (23 == k % 24) { out.print(' '); if (3 == k % 4) out.print(perm[k]+1); for (int k = 0; k < 52; k++) { out.print(" "); out.println("Board "+num+":"); if ("txt".equals(format)) { if (Debug.debug) Debug.print(Debug.INFO, "Printing permutation for board "+num+" to "+out+" format "+format); { public void printPermutation(int num, byte[] perm) } } out.println(); out.println(" HCP: "+count(hand[SOUTH])); } out.println(printablehand[i]); out.print(" "); for (int i = 12; i < 16; i++) { out.println(" "+PLAYER[SOUTH]); out.println(); out.println("HCP: "+count(hand[EAST])); out.print(' '); for (int j = 0; j < (11-hcp.length()); j++) out.print("HCP: "+hcp); String hcp = ""+count(hand[WEST]); } out.println(printablehand[i+4]); out.print(' '); for (int j = 0; j < (16-printablehand[i].length()); j++) out.print(printablehand[i]); for (int i = 4; i < 8; i++) { out.println(PLAYER[W out.println("< ou out.println("

"+header+"

"); out.println(" out.p out.println("

"+h out.println("

"+he out.println("

"+h out.println("

"+ out.println("

"+header+"

"); out.println("<h1>"+hea out.println("<body><h1>"+header+"</h1>");� out.println("<html><head><title>"+header+""); out.println(""); this.out = out; { public HTMLPrinter(PrintStream out, String header) private PrintStream out;{public class HTMLPrinter extends Printer implements Constantsimport java.io.PrintStream;import cx.ath.matthew.debug.Debug;package cx.ath.matthew.pescetti; */ * * To Contact me, please email src@matthew.ath.cx * * Boston, MA 02111-1307, USA. * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * copy of the GNU General Public License along with this program; if not, * GNU General Public License for more details. You should have received a * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * it will be useful, but WITHOUT ANY WARRANTY; without even the implied * the Free Software Foundation. This program is distributed in the hope that * under the terms of the GNU General Public License Version 2 as published by * This program is free software; you can redistribute it and/or modify it * * Copyright (C) 2007 Matthew Johnson * * Pescetti Pseudo-Duplimate Generator/* ad K5\G1 T ? * %  1  } } out.pri} } out.p} } out.print(s); { } }}}}}}}}}}}}}}}} } }} } out.print(s); { public void print(String s) } out.println("
"); out.print(s); { public void println(String s) } out.println(); out.println(); for (int i = 19; i >= 15; i--) out.print(" "+tricks[i]+(tricks[i] < 10 ? " ":"")); out.print("W"); out.println(); for (int i = 14; i >= 10; i--) out.print(" "+tricks[i]+(tricks[i] < 10 ? " ":"")); out.print("E"); out.println(); for (int i = 9; i >= 5; i--) out.print(" "+tricks[i]+(tricks[i] < 10 ? " ":"")); out.print("S"); out.println(); for (int i = 4; i >= 0; i--) out.print(" "+tricks[i]+(tricks[i] < 10 ? " ":"")); out.print("N"); out.println(" "+SUIT[CLUBS>>4]+" "+SUIT[DIAMONDS>>4]+" "+SUIT[HEARTS>>4]+" "+SUIT[SPADES>>4]+" "+SUIT[NOTRUMPS>>4]); { public void printTricks(byte[] tricks) }ad 8gYJ=bM f < 4 t _ 0  j e d . ) n D (   y t\QC"_D } } else if ("p } } else if ("pdf".equals(format)) { } } else if ( } } else } } else if ("pdf".equ } } else if ("pdf".equals(fo } } else if ("p } } else if ("pdf".equals(fo } } else if ("pdf".equ } } else if ("pd } } else if ("pdf". } } else if ("pdf".e } } else if ("pdf" } } else if ("pdf".eq } } } } else if } } else if } } else if ("pdf".equals(form } } else if ("pdf".equals(for } } } else if ("pdf".equals(format)) { out.println(""); } } else if ("pdf".equ } } else if } } else if out.close(); } } else i ou ou out.close(); out.print out.close(); out.println(""); { public void close() } out.println("

"); } out.println("
"); if (19 == k % 20) out.print("     "); if (3 == k % 4) out.print(perm[k]+1); for (int k = 0; k < 52; k++) { out.print("

"); out.println("

Board "+num+"

"); { public void printPermutation(int num, byte[] perm) } out.println(); out.println(" HCP: "+count(hand[SOUTH])); } out.println(printablehand[i]); out.print(" "); for (int i = 12; i < 16; i++) { out.println(" "+PLAYER[SOUTH]); out.println(); out.println("HCP: "+count(hand[EAST])); out.print(' '); for (int j = 0; j < (11-hcp.length()); j++) out.print("HCP: "+hcp); String hcp = ""+count(hand[WEST]); } out.println(printablehand[i+4]); out.print(' '); for (int j = 0; j < (16-printablehand[i].length()); j++) out.print(printablehand[i]); for (int i = 4; i < 8; i++) { out.println(PLAYER[WEST]+" "+PLAYER[EAST]); out.println(); out.println(" HCP: "+count(hand[NORTH])); } out.println(printablehand[i]); out.print(" "); for (int i = 0; i < 4; i++) { out.println(" "+PLAYER[NORTH]); // 2 // 3 1 // 0 out.println("Board "+num+": "); String[] printablehand = getHandPrintables(hand); { public void printHand(int num, byte[][] hand) }pescetti-0.5/cx/ath/matthew/pescetti/.Printer.java.swp0000644000175000017500000004000010705201106021463 0ustar mjj29mjj29b0VIM 7.0CGo*mjj29adonis~mjj29/scm/bridgedeal/cx/ath/matthew/pescetti/Printer.javautf-8 3210#"! UtpOnad0O]v) E % " V T P  J V (   * # j=~)E=)$rS|d)wgUDlQ;6 } } else if ("pd } } else if ("pdf".equals(format)) { } } else i } } else if ("p } } else if ("pdf".equals(format)) { } } else if ( } } } else if ("pdf".equals(format)) { } } else if ("pdf".equ } } else if ("pdf".equals(for } } e } } el } } } } else if ("pdf".equals(format)) { } } else if ("pdf".equals(f } } else if ("pdf".equal } } else if ("pdf".equals(forma } } } else if ("pdf".equals(format)) { o } } else if } } else if ("pdf".equals(format)) { out.prin } } else if ("pdf".equals(f } } else if ("pdf".equals(for } } else if ("pdf".equals(format)) { out.println } } else if ("pdf". } } else i public abstract void close(); public abstract void printPermutation(int num, byte[] perm); public abstract void printHand(int num, byte[][] hand); } return total; } if (Debug.debug) Debug.print(Debug.DEBUG,"total="+total); } case JACK: total++; case QUEEN: total++; case KING: total++; case ACE: total++; switch (b) { if (Debug.debug) Debug.print(Debug.DEBUG,"a = "+a+" b = "+b+" / "+CARD[b]); int b = a & 0x0f; for (byte a: hand) { int total = 0; { public static int count(byte[] hand) } return out; doPlayerPrintable(out, 12, hand[SOUTH]); doPlayerPrintable(out, 8, hand[EAST]); doPlayerPrintable(out, 4, hand[WEST]); doPlayerPrintable(out, 0, hand[NORTH]); String[] out = new String[16]; { public String[] getHandPrintables(byte[][] hand) */ * Returns a 16 element array of North Spades, North Hearts, ... West Spades, ... East, ... South Spades, ... South Clubs. /** } out[i] = SUIT[i-k+1]+" "+(null==out[i]?"":out[i]); for (int i = k; i < k+4; i++) } } lastsuit = (byte) (hand[i] >> 4); j += (hand[i] >> 4) - lastsuit; if (i < 13) { } i++; out[j] = CARD[hand[i] & 0x0f] + (null==out[j]?"":out[j]); if (Debug.debug) Debug.print(Debug.DEBUG, j+" "+(hand[i] & 0x0f)); while (i < 13 && lastsuit == (hand[i] >> 4)) { for (int i = 0; i < 13 ; ) { int k = j; byte lastsuit = SPADES >> 4; Arrays.sort(hand); { public void doPlayerPrintable(String[] out, int j /* offs */, byte[] hand) {public abstract class Printer implements Constantsimport cx.ath.matthew.debug.Debug;import java.util.Arrays;package cx.ath.matthew.pescetti; */ * * To Contact me, please email src@matthew.ath.cx * * Boston, MA 02111-1307, USA. * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * copy of the GNU General Public License along with this program; if not, * GNU General Public License for more details. You should have received a * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * it will be useful, but WITHOUT ANY WARRANTY; without even the implied * the Free Software Foundation. This program is distributed in the hope that * under the terms of the GNU General Public License Version 2 as published by * This program is free software; you can redistribute it and/or modify it * * Copyright (C) 2007 Matthew Johnson * * Pescetti Pseudo-Duplimate Generator/* adEuxvu)k m } } }} } } } out.print} } } out.println(); out.println(); for (int i = 19; i >= 15; i--) out.print(" "+tricks[i]+(tr} } } } } } out.println(); out.println(); for (int i = 19; } } } } } } } } } out.println(); out.println(); for (int i = 19; } } } } } } } } } out.println(); out.println(); for (int i = 19; i } } } } } } } } } out.println(); out.println(); f} public abstract void print(String s); public abstract void println(String s); public abstract void printTricks(byte[] tricks);pescetti-0.5/cx/ath/matthew/pescetti/.TextPrinter.java.swp0000600000175000017500000005000010705200735022330 0ustar mjj29mjj29b0VIM 7.0Go *mjj29adonis~mjj29/scm/bridgedeal/cx/ath/matthew/pescetti/TextPrinter.java 3210#"! UtpFlad ]v) E % "  D , U 6 | ` /  la% )z^?m= vW2' eM#b];d out.println(); out.print('-'); for (int i = 0; i < header.length(); i++) out.println(header); if ("txt".equals(format)) { { public static void initformat(PrintStream out, String format, String header) } out.close(); } } else if ("pdf".equals(format)) { out.println(""); } else if ("html".equals(format)) { out.println(); if ("txt".equals(format)) { { public static void closeformat(PrintStream out, String format) } } } else if ("pdf".equals(format)) { out.println("

"); } out.println("
"); if (19 == k % 20) out.print("     "); if (3 == k % 4) out.print(perm[k]+1); for (int k = 0; k < 52; k++) { out.print("

"); out.println("

Board "+num+"

"); } else if ("html".equals(format)) { out.println(); out.println(); } } out.print(" "); out.println(); if (23 == k % 24) { out.print(' '); if (3 == k % 4) out.print(perm[k]+1); for (int k = 0; k < 52; k++) { out.print(" "); out.println("Board "+num+":"); if ("txt".equals(format)) { if (Debug.debug) Debug.print(Debug.INFO, "Printing permutation for board "+num+" to "+out+" format "+format); { public static void printPermutation(PrintStream out, int num, byte[] perm, String format) } } out.println(); out.println(" HCP: "+count(hand[SOUTH])); } out.println(printablehand[i]); out.print(" "); for (int i = 12; i < 16; i++) { out.println(" "+PLAYER[SOUTH]); out.println(); out.println("HCP: "+count(hand[EAST])); out.print(' '); for (int j = 0; j < (11-hcp.length()); j++) out.print("HCP: "+hcp); String hcp = ""+count(hand[WEST]); } out.println(printablehand[i+4]); out.print(' '); for (int j = 0; j < (16-printablehand[i].length()); j++) out.print(printablehand[i]); for (int i = 4; i < 8; i++) { out.println(PLAYER[WEST]+" "+PLAYER[EAST]); out.println(); out.println(" HCP: "+count(hand[NORTH])); } out.println(printablehand[i]); out.print(" "); for (int i = 0; i < 4; i++) { out.println(" "+PLAYER[NORTH]); // 2 // 3 1 // 0 out.println("Board "+num+import java.io.PrintStream;import cx.ath.matthew.debug.Debug;package cx.ath.matthew.pescetti; */ * * To Contact me, please email src@matthew.ath.cx * * Boston, MA 02111-1307, USA. * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * copy of the GNU General Public License along with this program; if not, * GNU General Public License for more details. You should have received a * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * it will be useful, but WITHOUT ANY WARRANTY; without even the implied * the Free Software Foundation. This program is distributed in the hope that * under the terms of the GNU General Public License Version 2 as published by * This program is free software; you can redistribute it and/or modify it * * Copyright (C) 2007 Matthew Johnson * * Pescetti Pseudo-Duplimate Generator/* ad" Q;bM7 Z E 0 +  } } out.println(); } } out.println(); } } out.println(); out.println(); } } out.println(); out } } out.println(); }}} } out.print(s); { public void print(String s) } out.println(s); { public void println(String s) } out.println(); out.println(); for (int i = 19; i >= 15; i--) out.print(" "+tricks[i]+(tricks[i] < 10 ? " ":"")); out.print("W"); out.println(); for (int i = 14; i >= 10; i--) out.print(" "+tricks[i]+(tricks[i] < 10 ? " ":"")); out.print("E"); out.println(); for (int i = 9; i >= 5; i--) out.print(" "+tricks[i]+(tricks[i] < 10 ? " ":"")); out.print("S"); out.println(); for (int i = 4; i >= 0; i--) out.print(" "+tricks[i]+(tricks[i] < 10 ? " ":"")); out.print("N"); out.println(" "+SUIT[CLUBS>>4]+" "+SUIT[DIAMONDS>>4]+" "+SUIT[HEARTS>>4]+" "+SUIT[SPADES>>4]+" "+SUIT[NOTRUMPS>>4]); { public void printTricks(byte[] tricks)ad6jFniS8gA3$ | t < ' \ @   | N 9 Y D ? >   i M 0  pkjiU,vT,|xmDx\ if ("txt".equals(forma if ( if ("txt".equals(forma if ("txt".equals(format) } out.close(); } } out.close(); } } e } out.close(); } } } out.close(); } } } } out.close(); out } out.close(); out.println } out.close(); out.println(); } out.close(); out.println(); { } out.close(); out.print } out.close(); out } out.close(); } out.close(); out.println(); } out.close(); } out.close(); out.pr } } out.close(); } out.close(); out.printl } } out.close(); out } } out.close(); out.println(); { public void close() } out.p } out.close(); out.println(); { public void close() } out.println(); out.println(); } } out.print(" "); out.println(); if (23 == k % 24) { out.print(' '); if (3 == k % 4) out.print(perm[k]+1); for (int k = 0; k < 52; k++) { out.print(" "); out.println("Board "+num+":"); { public void printPermutation(int num, byte[] perm) } out.println(); out.println(" HCP: "+count(hand[SOUTH])); } out.println(printablehand[i]); out.print(" "); for (int i = 12; i < 16; i++) { out.println(" "+PLAYER[SOUTH]); out.println(); out.println("HCP: "+count(hand[EAST])); out.print(' '); for (int j = 0; j < (11-hcp.length()); j++) out.print("HCP: "+hcp); String hcp = ""+count(hand[WEST]); } out.println(printablehand[i+4]); out.print(' '); for (int j = 0; j < (16-printablehand[i].length()); j++) out.print(printablehand[i]); for (int i = 4; i < 8; i++) { out.println(PLAYER[WEST]+" "+PLAYER[EAST]); out.println(); out.println(" HCP: "+count(hand[NORTH])); } out.println(printablehand[i]); out.print(" "); for (int i = 0; i < 4; i++) { out.println(" "+PLAYER[NORTH]); // 2 // 3 1 // 0 out.println("Board "+num+": "); String[] printablehand = getHandPrintables(hand); { public void printHand(int num, byte[][] hand) } out.println(); out.print('-'); for (int i = 0; i < header.length(); i++) out.println(header); this.out = out; { public TextPrinter(PrintStream out, String header) private PrintStream out;{public class TextPrinter extends Printer implements Constantspescetti-0.5/cx/ath/matthew/pescetti/.pescetti.java.swp0000644000175000017500000013000010705201207021662 0ustar mjj29mjj29b0VIM 7.0Go*mjj29adonis~mjj29/scm/bridgedeal/cx/ath/matthew/pescetti/pescetti.javautf-8 3210#"! Utp B.Z k8 \b3f adB]v) E % " ~ _ J * p W = $ # w r q j / W R &  qX4sMBl;oB /** } return perm; sw /** } return perm; swa /** } return perm; swap( /** } return perm; sw /** } return perm; swap( /** } return perm; /** } return perm; s /** } return perm; sw /** } return perm; s /** } return perm; /** } return perm; swap(perm /** } return perm; swap(perm, k, Math.abs(rand[k]) % 52); for (byte k = 0; k < 52; k++) perm[k] = i; for (byte j = 0; j < 13; j++, /** } return perm; swap(perm, k, Math.abs(rand[k]) % 52); for (byte k = 0; k < 52; k++) perm[k] = i; for (byte j = 0; j < 13; j++, /** } return perm; swap(perm, k, Math.abs(rand[k]) % 52); for (byte k = 0; k < 52; k++) perm[k] = i; for (byte j = 0; j < 13; j++, k++) for (byte i = /** } return perm; swap(perm, k, Math.abs(rand[k]) % 52); for (byte k = 0; k < 52; k++) perm[k] = i; for (byte j = 0; /** } return perm; swap(perm, k, Math.abs(rand[k]) % 52); /** } return perm; swap(perm, k, Math.abs(rand[k]) /** } return perm; swap(perm, k, Math.abs(rand[k]) % 52); for (byte k = 0; k < 52; k++) /** } return perm; /** } return perm; /** } retur /** } return perm; swap(perm, k, /** } return perm; swap(perm, k, Math.abs(rand[k]) % 52); for (byte k = 0; k < 52; k++) perm[k] = i; for (byte j = 0; j < 13; j++, k++) for (byte i = 0, k = 0; i < 4; i++) sr.nextBytes(rand); byte[] rand = new byte[52]; byte[] perm = new byte[52]; SecureRandom sr = new SecureRandom(); { public static byte[] generatePermutation() */ * chosen item in the list 0....51. * for each item in the list 0....51 swap it with a randomly * Start with 11111.....22222....33333...444444..., then * Generates a random permutaion using Knuth's Shuffle. /** } perm[b] = t; perm[a] = perm[b]; byte t = perm[a]; { public static void swap(byte[] perm, int a, int b){public class pescetti implements Constantsimport java.util.Vector;import java.util.HashMap;import java.util.Arrays;import java.security.SecureRandom;import java.io.PrintStream;import java.io.IOException;import java.io.InputStreamReader;import java.io.InputStream;import java.io.FileOutputStream;import java.io.FileInputStream;import java.io.File;import java.io.BufferedReader;import java.io.BufferedInputStream;import cx.ath.matthew.debug.Debug;package cx.ath.matthew.pescetti; */ * * To Contact me, please email src@matthew.ath.cx * * Boston, MA 02111-1307, USA. * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * copy of the GNU General Public License along with this program; if not, * GNU General Public License for more details. You should have received a * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * it will be useful, but WITHOUT ANY WARRANTY; without even the implied * the Free Software Foundation. This program is distributed in the hope that * under the terms of the GNU General Public License Version 2 as published by * This program is free software; you can redistribute it and/or modify it * * Copyright (C) 2007 Matthew Johnson * * Pescetti Pseudo-Duplimate Generator/* ad|3NC x O  z G  r j i , p ? &  x \ Q I H  FIB| "f1TyX } } } } System.exit(1); syntax(); System.err.println("Failed to save permutations"); if (Debug.debug) Debug.print(Debug.ERR, e); } catch (Exception e) { closeformat(permfile2, options.get("--format")); closeformat(permfile1, options.get("--format")); } printPermutation(permfile2, i+1, perm2, options.get("--format")); printPermutation(permfile1, i+1, perm1, options.get("--format")); byte[] perm2 = getPermutation(intermediate, boards[i]); byte[][] intermediate = permute(INITIAL_HAND, perm1); byte[] perm1 = generatePermutation(); for (int i = 0; i < count; i++) { int count = boards.length; initformat(permfile2, options.get("--format"), options.get("--title")+" - Permutation 2"); initformat(permfile1, options.get("--format"), options.get("--title")+" - Perm permprint2 = new HTMLPrinter(permfile2, options.get("--title")+" - Permutation 2"); permprint1 = new HTMLPrinter(permfile1, options.get("--title")+" - Permutation 1"); } else if ("html".equals(options.get("--format"))) { permprint2 = new TextPrinter(permfile2, options.get("--title")+" - Permutation 2"); permprint1 = new TextPrinter(permfile1, options.get("--title")+" - Permutation 1"); if ("txt".equals(options.get("--format"))) { Printer permprint2 = null; Printer permprint1 = null; PrintStream permfile2 = new PrintStream(new FileOutputStream(prefix+".perm2."+ options.get("--format"))); PrintStream permfile1 = new PrintStream(new FileOutputStream(prefix+".perm1."+ options.get("--format"))); try { String prefix = options.get("--permutations"); if (null != options.get("--permutations") && null != boards) { } } System.exit(1); syntax(); System.err.println("Failed to save permutations"); if (Debug.debug) Debug.print(Debug.ERR, e); } catch (Exception e) { out.close(); ddsexport(out, boards[i], false); for (int i = 1; i < boards.length; i++) PrintStream out = new PrintStream(new FileOutputStream(file)); try { String file = options.get("--save"); if (null != options.get("--save") && null != boards) { } System.exit(1); syntax(); System.out.println("Must specify either --generate --load or --demo"); } else { print.close(); ddsexport(System.out, resulthand, true); ddsexport(System.out, resulthand, false); print.println("These can go into a file to be run with dds -deal=1 -tricks file.txt and dds -deal=2 -tricks file.txt"); print.printTricks(tricks); byte[] tricks = ddanalyse(resulthand); print.printHand(1, resulthand); print.println("You should now have these hands hand 1 = north, hand 2 = east, hand 3 = south, hand 4 = west"); print.printPermutation(1, perm2); print.println("Second Deal:"); print.println("Now, put hand 1 on top of hand 2, both on top of hand 3 and everything on top of hand 4"); print.printPermutation(1, perm1); print.println("First Deal:"); byte[] perm2 = getPermutation(intermediatehand, resulthand); byte[][] intermediatehand = permute(INITIAL_HAND, perm1); byte[] perm1 = generatePermutation(); byte[][] resulthand = permute(INITIAL_HAND, initperm);ad .d_4tsSNME ^ 4    m T 3 . - & s J  q f F %  { ` E 0 +  Q%]%PONM7[VG<kDNI } return total; } if (Debug.debug) Debug.print(Debug. } return total; } } return total; } return total } return total; } } return total; } return total; } } return total; } return total } return total; } return total; } if (Debug.debug) Deb } return total; } } return total; } if (Deb } return total; } if (Debug.debug) Debug.print(Debug.DEBUG,"total="+total); } } return total; } if (Deb } return total; } return total; } } return total; } } return total; } } return total; } } } return total; } if (Debug.debug) Debug.print(Debu } return total; } return total; } } return total; } return total; } if ( } return total; } if (Debug.debug) Debug.prin } return total; } if (Debug.debug) D } } re } return total; } } return total; } } return total; } return } return total; } return total; } } } return tot } return total; } return total; } return total; } if (Debug.debug) Debug.print(Debug.DEBUG,"t } return tota } return total; } return total; } } return total; } } return total; } } } return total; } if (Debug.debug) Debug.pr } } return to } } return perm; perm[k] = find(hand2, hand1[i][j]); for (int j = 0; j < 13; j++, k++) for (int i = 0, k = 0; i < 4; i++) byte[] perm = new byte[52]; { public static byte[] getPermutation(byte[][] hand1, byte[][] hand2) */ * Takes 2 hands and returns the permutation between them. /** } return 0; // never happens return i; if (hands[i][j] == card) for (int j = 0; j < 13; j++) for (byte i = 0; i < 4; i++) { public static byte find(byte[][] hands, byte card) } return newhands; newhands[i][k] = hands[i][j]; for (int j = 0, k = 12; j < 13; j++, k--) for (int i = 0; i < 4; i++) byte[][] newhands = new byte[4][13]; { public static byte[][] reverse(byte[][] hands) */ * Reverses the contents of each hand /** } return reverse(newhands); newhands[permutation[k]][nhi[permutation[k]]++] = hands[i][j]; for (int j = 0; j < 13; j++, k++) for (int i = 0, k = 0; i < 4; i++) byte[] nhi = new byte[4]; byte[][] newhands = new byte[4][13]; { public static byte[][] permute(byte[][] hands, byte[] permutation) */ * Takes a set of hands and a permutation and generates the permuted hands.adk \U kj^5 b J . f a N F  J  E @ 8  u Y 7  i Q F 8  |T9{v \3gF~U.c?i1, int p=3; // start at west int s=1; byte[][] hand = new byte[4][13]; / int p=3; // start at west int s=1; byt int p=3; // start at west int p=3; // start at west int int p=3; // int p=3; // int p=3; / int p=3; // start at west int s=1; int p=3; // start at west i int p=3; // start at west int p=3; // start at west int s int p int p=3; // start at west int s=1; byte[] int p=3; // start int p=3; // start at west int s=1; byte[][] hand int p=3; // start at west i int p=3; // start at west int int p=3; // start at west int s=1; byte[][] hand = int p=3; // start at west int p=3; // start at west int s=1 int p int p=3; // start at west int s= int p=3; // start at west int p=3; // start at west int s=1; int p=3; // start at w int p=3; // start at west int s=1; int p=3; // start int p=3; // start at west int s=1; int p=3; // start at west int int p=3; // start at west int p=3; // start at west int s int p int p=3; // start at west int s=1; byte[][ int p=3; // start in int p=3; // start at west int s=1; byte[][] hand = new byte[4][13]; //start int p=3; // start at west int s=1; byte[][] hand = new byte[4][13]; //start afresh Vector hands = new Vector(); { public static byte[][][] ddsimport(InputStream in) throws IOException */ * A64.8732.543.Q98 T8.96.AKT.A76432 Q2.AQJT54.Q82.JT KJ9753.K.J976.K5 * W N E S = 3 0 1 2 * import from format used by dds double dummy solver. /**ad]bYCfC  o 4  ~ l +  m 7   v &  I H ) q({N/ aK/$#a'g\3] else { print = new HTMLPrinter(System.out, options.get("--title" else if ("html".equa print = new TextPrinter(System.out, options.get Printer print = new TextPrinter(System.out, "Pescetti PseudoDuplimate - Demo mode"); } else if (null != options.get("--demo")) { print.close(); print.printHand(i+1, boards[i]); for (int i = 0; i < count; i++) } System.exit(1); System.err.println("Invalid format "+options.get("--format")); else { print = new HTMLPrinter(System.out, options.get("--title")); else if ("html".equals(options.get("--format"))) print = new TextPrinter(System.out, options.get("--title")); if ("txt".equals(options.get("--format"))) Printer print = null; int count = boards.length; } System.exit(1); syntax(); System.err.println("Failed to load boards"); if (Debug.debug) Debug.print(Debug.ERR, e); } catch (Exception e) { in.close(); boards = ddsimport(in); InputStream in = new BufferedInputStream(new FileInputStream(options.get("--load"))); try { } else if (null != options.get("--load")) { print.close(); } print.printTricks(tricks); byte[] tricks = ddanalyse(boards[i]); print.printHand(i+1, boards[i]); for (int i = 0; i < count; i++) { } System.exit(1); System.err.println("Invalid format "+options.get("--format")); else { print = new HTMLPrinter(System.out, options.get("--title")); else if ("html".equals(options.get("--format"))) print = new TextPrinter(System.out, options.get("--title")); if ("txt".equals(options.get("--format"))) Printer print = null; boards[i] = permute(INITIAL_HAND, generatePermutation()); for (int i = 0; i < count; i++) boards = new byte[count][][]; } System.exit(1); syntax(); System.err.println("Failed to parse number of boards to generate"); if (Debug.debug) Debug.print(Debug.ERR, e); } catch (Exception e) { count = Integer.parseInt(options.get("--generate")); try { int count = 0; } else if (null != options.get("--generate")) { System.exit(0); syntax(); if (null != options.get("--help")) { byte[][][] boards = null; } } System.exit(1); syntax(); System.out.println("Error: unknown option "+opt[0]); } else { options.put(opt[0], opt[1]); else options.put(opt[0], "true"); if (opt.length == 1) if (options.containsKey(opt[0])) { if (Debug.debug) Debug.print(Arrays.asList(opt)); String[] opt = args[i].split("="); for (int i = 0; i < args.length; i++) { options.put("--title", "PseudoDuplimate"); options.put("--format", "txt"); options.put("--save", null); options.put("--demo", null); options.put("--permutations", null); options.put("--load", null); options.put("--generate", null); options.put("--help", null); HashMap options = new HashMap(); // read options Debug.setThrowableTraces(true); { public static void main(String[] args) } return out; } } } ;ad,PPE) byte[] initperm = generatePermutation(); print.println("S byte[] initperm = g by byte[] initperm = generatePermutation(); print.println("Sort AS, KS, QS, ..... AH, KH, QH. .... AD, ... AC, ... 2C (so that the first card delt is the AS)");ad;k_I3sJ e /    i ,  i S =  x C -  q Y  |+&lS*}T;idKto*cRMA File temp = File.createTempFile("pescetti", ".tmp"); try { { public static byte[] ddanalyse(byte[][] hand) } System.out.println(" Formats: txt html pdf"); System.out.println(" Options: --help --generate=N --load= --permutations= --demo --save=boards.txt --format= --title=");� System.out.println("Syntax: pescetti [options]");� System.out.println("Pescetti Pseudo-Duplimate Generator - version "+version);� .getImplementationVersion();� String version = Package.getPackage("cx.ath.matthew.pescetti")� {� static void syntax()� � }� }� if (s < 4) out.print('.');� out.print(CARD[hand[i++] & 0x0f]);� while (i < 13 && s == (hand[i] >> 4))� for (int s = 1, i = 0; s <= 4; s++) {� int suit = SPADES;� {� public static void ddsprinthand(PrintStream out, byte[] hand)� }� }� out.println();� ddsprinthand(out, hands[WEST]);� out.print(' ');� ddsprinthand(out, hands[SOUTH]);� out.print(' ');� ddsprinthand(out, hands[EAST]);� out.print(' ');� ddsprinthand(out, hands[NORTH]);� } else {� out.println();� ddsprinthand(out, hands[SOUTH]);� out.print(' ');� ddsprinthand(out, hands[EAST]);� out.print(' ');� ddsprinthand(out, hands[NORTH]);� out.print(' ');� ddsprinthand(out, hands[WEST]);� if (!rotate) {� for (int i = 0; i < 4; i++) Arrays.sort(hands[i]);� {� public static void ddsexport(PrintStream out, byte[][] hands, boolean rotate)� */� *� * dds only solves for N-S, so we have to output two lines, one of them rotated for E-W (rotation printed if rotate is true)� *� * A64.8732.543.Q98 T8.96.AKT.A76432 Q2.AQJT54.Q82.JT KJ9753.K.J976.K5� * W N E S = 3 0 1 2� * Export to format used by dds double dummy solver.� /**� }� return hands.toArray(new byte[0][][]);� }� i++; // next card in hand� }� default:� break;� hand[p][i] = (byte) (ACE + (s << 4));� case 'A':� break;� hand[p][i] = (byte) (KING + (s << 4));� case 'K':� break;� hand[p][i] = (byte) (QUEEN + (s << 4));� case 'Q':� break;� hand[p][i] = (byte) (JACK + (s << 4));� case 'J':� break;� hand[p][i] = (byte) (TEN + (s << 4));� case 'T':� break;� hand[p][i] = (byte) (c - '1' + 1 + (s << 4));� case '9':� case '8':� case '7':� case '6':� case '5':� case '4':� case '3':� case '2':� break;� hand = new byte[4][13]; //start afresh� hands.add(hand);� p=3;� i=-1;� s=1; // reset suits, cards in hand and player� case '\n':� break;� i=-1; // start cards in hand again� s=1; // start suits again� p = (p + 1) % 4; // next player� case ' ':� break;� i--; // oops, didn't actually want to increment this� s++; // next suit� case '.':� switch (c) {� if (Debug.debug) Debug.print(Debug.DEBUG, "Read c="+((char)c)+" s="+s+" p="+p+" i="+i);� while (0 < (c = in.read())) {� int c;� int i=0;�ad��K��������\���������y��S��.����W��A�� ��r �� �� �� �� �� �� ��Y ��$ �� �� �� �� �� �� �� �� ��f ��J ��. ��! �� �� �� �� �� �� ��L ��2 �� �� �� �� �� �� ��; �� �� ����������w��[��?��#������������Z��>��"����������������j��+������}��D��������`��I��,������������|��Y��;������������������������������ // // s // skip everything else� default:� break;� suit=-1;� state=READEW;� case ':':� break;� read = false;� case ' ':� break;� offs++;� n = -1;� }� out[15 + suit] = (byte) n;� // west gets n tricks in suit� else if (READEW == state && 2 == offs)� out[10 + suit] = (byte) n;� // east gets n tricks in suit� else if (READEW == state && 0 == offs)� out[5 + suit] = (byte) n;� // south gets n tricks in suit� else if (READNS == state && 3 == offs)� out[0 + suit] = (byte) n;� // north gets n tricks in suit� if (READNS == state && 1 == offs)� if (Debug.debug) Debug.print(Debug.DEBUG, "state="+state+" c="+((char)c)+" n="+n+" offs="+offs+" suit="+suit);� if (read) {� if (n < 0) n = c-'a'+10;� case 'd':� case 'c':� case 'b':� case 'a':� if (n < 0) n = c-'A'+10;� case 'D':� case 'C':� case 'B':� case 'A':� if (n < 0) n = c-'0';� case '9':� case '8':� case '7':� case '6':� case '5':� case '4':� case '3':� case '2':� case '1':� case '0':� case '=': suit++; offs=0; if (suit < 5) read = true; break;� switch (c) {� case READEW:� case READNS:� break;� if (':' == c) state = READNS;� case START:� switch (state) {� if (Debug.debug) Debug.print(Debug.DEBUG, ""+(char) c);� while (0 < (c = in.read())) {� boolean read = false;� int n = -1;� int offs = 0;� int suit = -1;� int state = START;� int c;� final int READEW = 3;� final int READNS = 2;� final int START = 1;� byte[] out = new byte[20];� {� public static byte[] parseDD(InputStream in) throws IOException�� }� return null;� }� System.exit(1);� System.err.println("Failed to DD analyse");� if (Debug.debug) Debug.print(Debug.ERR, e);� } catch (Exception e) {� return tricks;� temp2.delete();� temp.delete();� byte[] tricks = parseDD(in);� BufferedInputStream in = new BufferedInputStream(new FileInputStream(temp2));� p.waitFor();� p = Runtime.getRuntime().exec(new String[] { "/bin/sh", "-c", "/usr/games/dds -deal=2 -tricks "+temp.getCanonicalPath()+" | /usr/bin/tail -n2 >> " +temp2.getCanonicalPath()});� p.waitFor();� Process p = Runtime.getRuntime().exec(new String[] { "/bin/sh", "-c", "/usr/games/dds -deal=1 -tricks "+temp.getCanonicalPath()+" | /usr/bin/tail -n2 > " +temp2.getCanonicalPath() });� fos.close();� ddsexport(fos, hand, true);� ddsexport(fos, hand, false);� File temp2 = File.createTempFile("pescetti", ".tmp");� PrintStream fos = new PrintStream(new FileOutputStream(temp));�ad��@ �� ����������������~��p��I��������Z��"�� �� �� �� ��{ ��C �� �� �� �� �� �� �� ��p ��2 �� ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������}� }� }� }� System.exit(1);� syntax();� System}� }� }� }� System.exit(1);� syntax();� System.err.prin}� }� }� }� System.exit(1);� syntax}� }� }� }� }� }� }� System.exit(1);� }� }� }� }� System.exit(1);� }�}� }� }� }� }� }� }� System.exit(1);� syntax();� System.err.println("Failed to save permutations");� if (Debug.debug) Debug.print(Debug.ERR, e);� } catch (Exception e) {� permprint2.close();� permprint1.close();� }� permprint2.printPermutation(i+1, perm2);� permprint1.printPermutation(i+1, perm1);� byte[] perm2 = getPermutation(intermediate, boards[i]);� byte[][] intermediate = permute(INITIAL_HAND, perm1);� byte[] perm1 = generatePermutation();� for (int i = 0; i < count; i++) {� int count = boards.length;� }� System.exit(1);� System.err.println("Invalid format "+options.get("--format"));� } else {�pescetti-0.5/cx/ath/matthew/pescetti/Constants.java�������������������������������������������������0000664�0001750�0001750�00000007425�11300051563�021150� 0����������������������������������������������������������������������������������������������������ustar �mjj29���������������������������mjj29������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * Pescetti Pseudo-Duplimate Generator * * Copyright (C) 2007 Matthew Johnson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License Version 2 as published by * the Free Software Foundation. This program is distributed in the hope that * it will be useful, but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. You should have received a * copy of the GNU General Public License along with this program; if not, * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * To Contact me, please email src@matthew.ath.cx * */ package cx.ath.matthew.pescetti; public interface Constants { public static final byte SPADES = 0x10; public static final byte HEARTS = 0x20; public static final byte DIAMONDS = 0x30; public static final byte CLUBS = 0x40; public static final byte NOTRUMPS = 0x50; public static final byte TEN = 0x0A; public static final byte JACK = 0x0B; public static final byte QUEEN = 0x0C; public static final byte KING = 0x0D; public static final byte ACE = 0x0E; public static final byte[] INITIAL_SPADES = {SPADES | ACE, SPADES | KING, SPADES | QUEEN, SPADES | JACK, SPADES | TEN, SPADES | 9, SPADES | 8, SPADES | 7, SPADES | 6, SPADES | 5, SPADES | 4, SPADES | 3, SPADES | 2}; public static final byte[] INITIAL_HEARTS = {HEARTS | ACE, HEARTS | KING, HEARTS | QUEEN, HEARTS | JACK, HEARTS | TEN, HEARTS | 9, HEARTS | 8, HEARTS | 7, HEARTS | 6, HEARTS | 5, HEARTS | 4, HEARTS | 3, HEARTS | 2}; public static final byte[] INITIAL_DIAMONDS = {DIAMONDS | ACE, DIAMONDS | KING, DIAMONDS | QUEEN, DIAMONDS | JACK, DIAMONDS | TEN, DIAMONDS | 9, DIAMONDS | 8, DIAMONDS | 7, DIAMONDS | 6, DIAMONDS | 5, DIAMONDS | 4, DIAMONDS | 3, DIAMONDS | 2}; public static final byte[] INITIAL_CLUBS = {CLUBS | ACE, CLUBS | KING, CLUBS | QUEEN, CLUBS | JACK, CLUBS | TEN, CLUBS | 9, CLUBS | 8, CLUBS | 7, CLUBS | 6, CLUBS | 5, CLUBS | 4, CLUBS | 3, CLUBS | 2}; public static final byte[][] INITIAL_HAND = { INITIAL_SPADES, INITIAL_HEARTS, INITIAL_DIAMONDS, INITIAL_CLUBS }; public static final String[] PLAYER = { "North", "East", "South", "West" }; public static final char[] SUIT = { '!', '♠', '♡', '♢', '♣', 'N' }; public static final char[] SHORTSUIT = { '!', 'S', 'H', 'D', 'C', 'N' }; public static final char[] DINGSUIT = { '!', (char) 171, (char) 170, (char) 169, (char) 168, 'N' }; public static final String[] LONGSUIT = { "!", "Spades", "Hearts", "Diamonds", "Clubs", "No Trumps" }; public static final char[] CARD = { '!', '!', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A' }; public static final int NORTH = 0; public static final int EAST = 1; public static final int SOUTH = 2; public static final int WEST = 3; public static final int STAT_NSGAMES = 0; public static final int STAT_EWGAMES = 1; public static final int STAT_NSSLAMS = 2; public static final int STAT_EWSLAMS = 3; public static final int STAT_NPOINTS = 4; public static final int STAT_SPOINTS = 5; public static final int STAT_EPOINTS = 6; public static final int STAT_WPOINTS = 7; public static final int STAT_4333 = 8; public static final int STAT_BAL = 9; public static final int STAT_6PLUS = 10; public static final int STAT_7PLUS = 11; public static final int STAT_8PLUS = 12; public static final int STAT_BACON = 13; public static final int STAT_SEMIBAL = 14; public static final int STAT_55 = 15; public static final int STAT_VOID = 16; public static final int STAT_4441 = 17; public static final int STAT_MAX = 18; } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������pescetti-0.5/cx/ath/matthew/pescetti/Gettext.java���������������������������������������������������0000644�0001750�0001750�00000002053�10765746034�020630� 0����������������������������������������������������������������������������������������������������ustar �mjj29���������������������������mjj29������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * Pescetti Pseudo-Duplimate Generator * * Copyright (C) 2007 Matthew Johnson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License Version 2 as published by * the Free Software Foundation. This program is distributed in the hope that * it will be useful, but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. You should have received a * copy of the GNU General Public License along with this program; if not, * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * To Contact me, please email src@matthew.ath.cx * */ package cx.ath.matthew.pescetti; import java.util.ResourceBundle; public class Gettext { private static ResourceBundle myResources = ResourceBundle.getBundle("pescetti_localized"); public static String _(String s) { return myResources.getString(s); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������pescetti-0.5/cx/ath/matthew/pescetti/dup2dds.java���������������������������������������������������0000644�0001750�0001750�00000010223�10765746034�020547� 0����������������������������������������������������������������������������������������������������ustar �mjj29���������������������������mjj29������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * Pescetti Pseudo-Duplimate Generator * * Copyright (C) 2007 Matthew Johnson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License Version 2 as published by * the Free Software Foundation. This program is distributed in the hope that * it will be useful, but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. You should have received a * copy of the GNU General Public License along with this program; if not, * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * To Contact me, please email src@matthew.ath.cx * */ package cx.ath.matthew.pescetti; import cx.ath.matthew.debug.Debug; import static cx.ath.matthew.pescetti.Gettext._; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.IOException; import java.io.PrintStream; public enum dup2dds { start_row, north, south, east, west; public static void syntax() { System.out.println(_("Usage: dup2dds <dupfile>")); } public static String getState(dup2dds state) { switch (state) { case start_row: return "start_row"; case north: return "north"; case south: return "south"; case east: return "east"; case west: return "west"; } return null; } public static void main(String[] args) { if (1 != args.length) { syntax(); System.exit(1); } try { File input = new File(args[0]); File output = new File(input.getCanonicalPath().replaceAll("\\.[^\\.]*$",".dds")); if (Debug.debug) Debug.print(Debug.INFO, "Converting "+input+" to "+output); InputStream is = new FileInputStream(input); PrintStream os = new PrintStream(new FileOutputStream(output)); dup2dds state = start_row; int c; StringBuffer deal = null; StringBuffer deal2 = null; while (-1 != (c = is.read())) { if (Debug.debug) Debug.print(Debug.DEBUG, "State: "+getState(state)); if (Debug.debug) Debug.print(Debug.DEBUG, "c: "+((char) c)); switch (state) { case start_row: if (c == '') { state = north; deal = new StringBuffer(); deal2 = new StringBuffer(); } break; case north: if (c == '' || c == '' || c == '') deal.append('.'); else if (c == '') { deal.append(' '); state = east; } else deal.append((char) c); break; case south: if (c == '' || c == '' || c == '') deal.append('.'); else if (c == '') { deal.append(' '); state = west; } else deal.append((char) c); break; case east: if (c == '' || c == '' || c == '') deal.append('.'); else if (c == '') { deal.append(' '); state = south; } else deal.append((char) c); break; case west: if (c == '' || c == '' || c == '') deal2.append('.'); else if (c == 'Y') { os.println(deal2.toString()+' '+deal.toString()); state = start_row; } else deal2.append((char) c); break; } } is.close(); os.close(); } catch (IOException IOe) { if (Debug.debug) Debug.print(IOe); System.err.println(_("Error occurred while converting files: "+IOe.getMessage())); System.exit(1); } } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������pescetti-0.5/cx/ath/matthew/pescetti/BoardChecker.java����������������������������������������������0000644�0001750�0001750�00000003666�11115747364�021530� 0����������������������������������������������������������������������������������������������������ustar �mjj29���������������������������mjj29������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * Pescetti Pseudo-Duplimate Generator * * Copyright (C) 2007 Matthew Johnson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License Version 2 as published by * the Free Software Foundation. This program is distributed in the hope that * it will be useful, but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. You should have received a * copy of the GNU General Public License along with this program; if not, * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * To Contact me, please email src@matthew.ath.cx * */ package cx.ath.matthew.pescetti; import cx.ath.matthew.debug.Debug; import static cx.ath.matthew.pescetti.pescetti.count; import static cx.ath.matthew.pescetti.pescetti.length; import static cx.ath.matthew.pescetti.pescetti.contains; import java.util.HashMap; import java.util.Random; /* * Takes a set of criteria for a board and a board * and checks whether it matches. */ public class BoardChecker { private HashMap<Criteria, Double> criteria; private Random r; public BoardChecker(HashMap<Criteria, Double> criteria) { this.criteria = criteria; this.r = new Random(); } public boolean check(byte[][] board) { if (Debug.debug) Debug.print(Debug.DEBUG, "Checking "+board +" against "+criteria.size()+" criteria"); double cw = ((double) r.nextInt(1073741824)) / 1073741824.0; for (Criteria c: criteria.keySet()) { if (Debug.debug) Debug.print(Debug.DEBUG, "Checking "+board +" against "+c+" returns "+c.match(board)); if (c.match(board) && criteria.get(c) > cw) { if (Debug.debug) Debug.print(Debug.INFO, "Board matches "+c); return true; } } return false; } } ��������������������������������������������������������������������������pescetti-0.5/cx/ath/matthew/pescetti/Criteria.java��������������������������������������������������0000644�0001750�0001750�00000041624�11115747364�020752� 0����������������������������������������������������������������������������������������������������ustar �mjj29���������������������������mjj29������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * Pescetti Pseudo-Duplimate Generator * * Copyright (C) 2007 Matthew Johnson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License Version 2 as published by * the Free Software Foundation. This program is distributed in the hope that * it will be useful, but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. You should have received a * copy of the GNU General Public License along with this program; if not, * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * To Contact me, please email src@matthew.ath.cx * */ package cx.ath.matthew.pescetti; import cx.ath.matthew.debug.Debug; import static cx.ath.matthew.pescetti.pescetti.count; import static cx.ath.matthew.pescetti.pescetti.length; import static cx.ath.matthew.pescetti.pescetti.bacon; import java.util.HashMap; import java.util.Random; class WeirdShape extends Criteria { private double[] probabilities = new double[] { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 }; private Random r = new Random(); private boolean check(int n, double w) { return w < probabilities[n]; } private void frob(int n) { for (int i = 0; i < probabilities.length; i++) if (i == n) probabilities[i] -= 0.17; else probabilities[i] += 0.04; } public boolean match(byte[][] board) { double cw = ((double) r.nextInt(1073741824)) / 1073741824.0; if (check(0, cw)) for (int p = 0; p < 4; p++) for (int s = 0; s < 4; s++) if (length(board[p], s) >= 8) { if (Debug.debug) Debug.print(Debug.INFO, "8 card suit"); frob(0); return true; } if (check(1, cw)) for (int s = 0; s < 4; s++) { if (length(board[NORTH], s) + length(board[SOUTH], s) >= 12) { if (Debug.debug) Debug.print(Debug.INFO, "12 card fit"); frob(1); return true; } if (length(board[WEST], s) + length(board[EAST], s) >= 12) { if (Debug.debug) Debug.print(Debug.INFO, "12 card fit"); frob(1); return true; } } if (check(2, cw)) for (int p = 0; p < 4; p++) for (int s1 = 0; s1 < 4; s1++) for (int s2 = s1+1; s2 < 4; s2++) if (length(board[p], s1) <= 1 && length(board[p], s2) <= 1) { if (Debug.debug) Debug.print(Debug.INFO, "double splinter"); frob(2); return true; } if (check(3, cw)) { boolean ns11 = false; boolean ew11 = false; for (int s1 = 0; s1 < 4; s1++) { if ((length(board[NORTH], s1) + length(board[SOUTH], s1)) >= 11) ns11=true; if ((length(board[EAST], s1) + length(board[WEST], s1)) >= 11) ew11=true; } if (ns11 && ew11) { if (Debug.debug) Debug.print(Debug.INFO, "11 card fit both ways"); frob(3); return true; } } if (check(4, cw)) for (int s1 = 0; s1 < 4; s1++) for (int s2 = s1+1; s2 < 4; s2++) { if (length(board[WEST], s1) + length(board[EAST], s1) + length(board[WEST], s2) + length(board[EAST], s2) >= 19) { if (Debug.debug) Debug.print(Debug.INFO, "19 card double fit"); frob(4); return true; } if (length(board[NORTH], s1) + length(board[SOUTH], s1) + length(board[NORTH], s2) + length(board[SOUTH], s2) >= 19) { if (Debug.debug) Debug.print(Debug.INFO, "19 card double fit"); frob(4); return true; } } if (check(5, cw)) for (int s = 0; s < 4; s++) { if (length(board[NORTH], s) >= 4 && length(board[NORTH], s) <= 6 && length(board[SOUTH], s) == 0) { if (Debug.debug) Debug.print(Debug.INFO, "bad split"); frob(5); return true; } if (length(board[SOUTH], s) >= 4 && length(board[SOUTH], s) <= 6 && length(board[NORTH], s) == 0) { if (Debug.debug) Debug.print(Debug.INFO, "bad split"); frob(5); return true; } if (length(board[EAST], s) >= 4 && length(board[EAST], s) <= 6 && length(board[WEST], s) == 0) { if (Debug.debug) Debug.print(Debug.INFO, "bad split"); frob(5); return true; } if (length(board[WEST], s) >= 4 && length(board[WEST], s) <= 6 && length(board[EAST], s) == 0) { if (Debug.debug) Debug.print(Debug.INFO, "bad split"); frob(5); return true; } } return false; } } class Bacon extends Criteria { public boolean match(byte[][] board) { for (byte[] hand: board) if (bacon(hand)) return true; return false; } } class Unbalanced extends Criteria { public boolean match(byte[][] board) { for (byte[] hand: board) if (balanced(hand)) return false; return true; } } class WeakNT extends Criteria { public boolean match(byte[][] board) { for (byte[] hand: board) if (balanced(hand) && count(hand) >= 12 && count(hand) <= 14) return true; return false; } } class StrongNT extends Criteria { public boolean match(byte[][] board) { for (byte[] hand: board) if (balanced(hand) && count(hand) >= 15 && count(hand) <= 17) return true; return false; } } class TwoNT extends Criteria { public boolean match(byte[][] board) { for (byte[] hand: board) if (semibalanced(hand) && count(hand) >= 20 && count(hand) <= 22) return true; return false; } } class WeakTwo extends Criteria { public boolean match(byte[][] board) { for (byte[] hand: board) if ((length(hand, SPADES) == 6 || length(hand, HEARTS) == 6) && count(hand) >= 6 && count(hand) <= 10) return true; return false; } } class StrongTwo extends Criteria { public boolean match(byte[][] board) { for (byte[] hand: board) if ((length(hand, SPADES) >= 6 || length(hand, HEARTS) >= 6 || length(hand, DIAMONDS) >= 6) && count(hand) >= 18 && count(hand) <= 22) return true; return false; } } class Three extends Criteria { public boolean match(byte[][] board) { for (byte[] hand: board) if (longest(hand) >= 7 && count(hand) >= 6 && count(hand) <= 10) return true; return false; } } class TwoClubs extends Criteria { public boolean match(byte[][] board) { for (byte[] hand: board) if (count(hand) >= 23) return true; return false; } } class FFFOne extends Criteria { public boolean match(byte[][] board) { for (byte[] hand: board) if (shortest(hand) == 1 && longest(hand) == 4) return true; return false; } } class SingleSuited extends Criteria { public boolean match(byte[][] board) { for (byte[] hand: board) { int six = 0; for (int s = 0; s < 4; s++) if (length(hand, s) >= 6) six++; if (six == 1) return true; } return false; } } class TwoSuited extends Criteria { public boolean match(byte[][] board) { for (byte[] hand: board) { int five = 0; for (int s = 0; s < 4; s++) if (length(hand, s) >= 5) five++; if (five >= 2) return true; } return false; } } class PartScore extends Criteria { public boolean match(byte[][] board) { if (combinedcount(board[NORTH], board[SOUTH]) >= 17 && combinedcount(board[NORTH], board[SOUTH]) <= 23 && fit(board[NORTH], board[SOUTH]) >= 8) return true; if (combinedcount(board[EAST], board[WEST]) >= 17 && combinedcount(board[EAST], board[WEST]) <= 23 && fit(board[EAST], board[WEST]) >= 8) return true; return false; } } class Game extends Criteria { public boolean match(byte[][] board) { if (combinedcount(board[NORTH], board[SOUTH]) >= 26 && fit(board[NORTH], board[SOUTH]) >= 8) return true; if (combinedcount(board[EAST], board[WEST]) >= 26 && fit(board[EAST], board[WEST]) >= 8) return true; return false; } } class GrandSlam extends Criteria { public boolean match(byte[][] board) { if (combinedcount(board[NORTH], board[SOUTH]) >= 37 && fit(board[NORTH], board[SOUTH]) >= 9) return true; if (combinedcount(board[EAST], board[WEST]) >= 37 && fit(board[EAST], board[WEST]) >= 9) return true; return false; } } class Slam extends Criteria { public boolean match(byte[][] board) { if (combinedcount(board[NORTH], board[SOUTH]) >= 33 && fit(board[NORTH], board[SOUTH]) >= 9) return true; if (combinedcount(board[EAST], board[WEST]) >= 33 && fit(board[EAST], board[WEST]) >= 9) return true; return false; } } class GameInvite extends Criteria { public boolean match(byte[][] board) { if (combinedcount(board[NORTH], board[SOUTH]) >= 23 && combinedcount(board[NORTH], board[SOUTH]) <= 27 && fit(board[NORTH], board[SOUTH]) >= 8) return true; if (combinedcount(board[EAST], board[WEST]) >= 23 && combinedcount(board[EAST], board[WEST]) <= 27 && fit(board[EAST], board[WEST]) >= 8) return true; return false; } } class SlamInvite extends Criteria { public boolean match(byte[][] board) { if (combinedcount(board[NORTH], board[SOUTH]) >= 30 && combinedcount(board[NORTH], board[SOUTH]) <= 33 && fit(board[NORTH], board[SOUTH]) >= 8) return true; if (combinedcount(board[EAST], board[WEST]) >= 30 && combinedcount(board[EAST], board[WEST]) <= 33 && fit(board[EAST], board[WEST]) >= 8) return true; return false; } } class JumpShift extends Criteria { public boolean match(byte[][] board) { if (opener(board[NORTH]) && count(board[SOUTH]) >= 16 && longest(board[SOUTH]) >= 5) { for (int s = 0; s < 4; s++) if (length(board[NORTH], s) >= 4 && length(board[SOUTH], s) >= 4) return false; return true; } if (opener(board[SOUTH]) && count(board[NORTH]) >= 16 && longest(board[NORTH]) >= 5) { for (int s = 0; s < 4; s++) if (length(board[NORTH], s) >= 4 && length(board[SOUTH], s) >= 4) return false; return true; } if (opener(board[EAST]) && count(board[WEST]) >= 16 && longest(board[WEST]) >= 5) { for (int s = 0; s < 4; s++) if (length(board[WEST], s) >= 4 && length(board[EAST], s) >= 4) return false; return true; } if (opener(board[WEST]) && count(board[EAST]) >= 16 && longest(board[EAST]) >= 5) { for (int s = 0; s < 4; s++) if (length(board[WEST], s) >= 4 && length(board[EAST], s) >= 4) return false; return true; } return false; } } class JumpFit extends Criteria { public boolean match(byte[][] board) { if (opener(board[NORTH]) && count(board[SOUTH]) >= 12) { for (int s = 0; s < 4; s++) if (length(board[NORTH], s) >= 4 && length(board[SOUTH], s) >= 4) return true; return false; } if (opener(board[EAST]) && count(board[WEST]) >= 12) { for (int s = 0; s < 4; s++) if (length(board[EAST], s) >= 4 && length(board[WEST], s) >= 4) return true; return false; } return false; } } class Splinter extends Criteria { public boolean match(byte[][] board) { if (opener(board[NORTH]) && count(board[SOUTH]) >= 16 && shortest(board[SOUTH]) < 2) { for (int s = 0; s < 4; s++) if (length(board[NORTH], s) >= 4 && length(board[SOUTH], s) >= 4) return true; return false; } if (opener(board[SOUTH]) && count(board[NORTH]) >= 16 && shortest(board[NORTH]) < 2) { for (int s = 0; s < 4; s++) if (length(board[NORTH], s) >= 4 && length(board[SOUTH], s) >= 4) return true; return false; } if (opener(board[EAST]) && count(board[WEST]) >= 16 && shortest(board[WEST]) < 2) { for (int s = 0; s < 4; s++) if (length(board[EAST], s) >= 4 && length(board[WEST], s) >= 4) return true; return false; } if (opener(board[WEST]) && count(board[EAST]) >= 16 && shortest(board[EAST]) < 2) { for (int s = 0; s < 4; s++) if (length(board[EAST], s) >= 4 && length(board[WEST], s) >= 4) return true; return false; } return false; } } public abstract class Criteria implements Constants { public static HashMap<Criteria, Double> parseCriteria(String criteria) throws CriteriaException { String[] clist = criteria.split(" "); HashMap<Criteria, Double> cs = new HashMap<Criteria, Double>(); int i = 0; for (String d: clist) { if (Debug.debug) Debug.print(Debug.DEBUG, "new criteria: "+d); String[] ds = d.split(":"); String c = ds[0].toLowerCase(); double p = 1.0; if (ds.length > 1) p = Double.parseDouble(ds[1]); if (c.equals("unbalanced")) cs.put(new Unbalanced(), p); else if (c.equals("weaknt")) cs.put(new WeakNT(), p); else if (c.equals("strongnt")) cs.put(new StrongNT(), p); else if (c.equals("twont")) cs.put(new TwoNT(), p); else if (c.equals("weaktwo")) cs.put(new WeakTwo(), p); else if (c.equals("strongtwo")) cs.put(new StrongTwo(), p); else if (c.equals("three")) cs.put(new Three(), p); else if (c.equals("twoclubs")) cs.put(new TwoClubs(), p); else if (c.equals("4441")) cs.put(new FFFOne(), p); else if (c.equals("singlesuit")) cs.put(new SingleSuited(), p); else if (c.equals("twosuits")) cs.put(new TwoSuited(), p); else if (c.equals("partscore")) cs.put(new PartScore(), p); else if (c.equals("game")) cs.put(new Game(), p); else if (c.equals("slam")) cs.put(new Slam(), p); else if (c.equals("grand")) cs.put(new GrandSlam(), p); else if (c.equals("game-invite")) cs.put(new GameInvite(), p); else if (c.equals("slam-invite")) cs.put(new SlamInvite(), p); else if (c.equals("jumpshift")) cs.put(new JumpShift(), p); else if (c.equals("jumpfit")) cs.put(new JumpFit(), p); else if (c.equals("splinter")) cs.put(new Splinter(), p); else if (c.equals("bacon")) cs.put(new Bacon(), p); else if (c.equals("weird")) cs.put(new WeirdShape(), p); else throw new CriteriaException("Unknown criteria: "+c); } return cs; } public abstract boolean match(byte[][] board); public boolean opener(byte[] hand) { return 12 <= count(hand); } @SuppressWarnings("fallthrough") public boolean semibalanced(byte[] hand) { int xton = 0; for (int s = 0; s < 4; s++) { switch (length(hand, s)) { case 2: if (xton == 2) return false; else xton++; case 1: case 0: return false; } } return true; } @SuppressWarnings("fallthrough") public boolean balanced(byte[] hand) { boolean xton = false; for (int s = 0; s < 4; s++) { switch (length(hand, s)) { case 2: if (xton) return false; else xton = true; case 1: case 0: return false; } } return true; } public int shortest(byte[] hand) { int shortest = 14; for (int s = 0; s < 4; s++) if (length(hand, s) < shortest) shortest = length(hand, s); return shortest; } public int longest(byte[] hand) { int longest = 0; for (int s = 0; s < 4; s++) if (length(hand, s) > longest) longest = length(hand, s); return longest; } public int fit(byte[] hand1, byte[] hand2) { int fit = 0; for (int s = 0; s < 4; s++) { int sum = length(hand1, s) + length(hand2, s); if (sum > fit) fit = sum; } return fit; } public int combinedcount(byte[] hand1, byte[] hand2) { return count(hand1)+count(hand2); } } ������������������������������������������������������������������������������������������������������������pescetti-0.5/cx/ath/matthew/pescetti/CriteriaException.java�����������������������������������������0000644�0001750�0001750�00000001727�11115747364�022631� 0����������������������������������������������������������������������������������������������������ustar �mjj29���������������������������mjj29������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * Pescetti Pseudo-Duplimate Generator * * Copyright (C) 2007 Matthew Johnson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License Version 2 as published by * the Free Software Foundation. This program is distributed in the hope that * it will be useful, but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. You should have received a * copy of the GNU General Public License along with this program; if not, * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * To Contact me, please email src@matthew.ath.cx * */ package cx.ath.matthew.pescetti; @SuppressWarnings("serial") public class CriteriaException extends Exception { public CriteriaException(String message) { super(message); } } �����������������������������������������pescetti-0.5/cx/ath/matthew/pescetti/HTMLPrinter.java�����������������������������������������������0000644�0001750�0001750�00000044113�11115747364�021314� 0����������������������������������������������������������������������������������������������������ustar �mjj29���������������������������mjj29������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * Pescetti Pseudo-Duplimate Generator * * Copyright (C) 2007 Matthew Johnson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License Version 2 as published by * the Free Software Foundation. This program is distributed in the hope that * it will be useful, but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. You should have received a * copy of the GNU General Public License along with this program; if not, * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * To Contact me, please email src@matthew.ath.cx * */ package cx.ath.matthew.pescetti; import cx.ath.matthew.debug.Debug; import java.io.PrintStream; import java.text.DecimalFormat; public class HTMLPrinter extends Printer implements Constants { private PrintStream out; private boolean infulltable = false; private boolean inrow = false; private boolean incell = false; private boolean inback = false; private int cellcount = 0; private int rowcount = 0; private int permcount = 0; private static final int MAXCELLS = 4; public HTMLPrinter(PrintStream out, String header) { this.out = out; out.println("<!DOCTYPE HTML SYSTEM>"); out.println("<html><head><title>"+header+""); out.println(""); out.println(""); out.println(""); out.println("

"+header+"

"); } private void startcell() { cellcount++; incell=true; out.println(""); } private void startrow(int maxrows) { cellcount=0; inrow=true; rowcount++; if ( 0 == (rowcount % maxrows)) out.println(""); else out.println(""); } private void startfulltable() { infulltable=true; out.println(""); } private void stopcell() { out.println(""); incell=false; } private void stopfulltable() { infulltable=false; out.println("
"); } private void stoprow() { inrow=false; out.println(""); } public void printHand(int num, byte[][] hand) { if (!infulltable) startfulltable(); if (!inrow) startrow(6); if (incell) stopcell(); if (cellcount == MAXCELLS) { stoprow(); startrow(6); } startcell(); String[] printablehand = getHandPrintables(hand); out.print("

"); out.print(num); out.println("

"); out.print("
"); out.print("Dlr: "); switch (num % 4) { case 1: out.print(PLAYER[NORTH]); break; case 2: out.print(PLAYER[EAST]); break; case 3: out.print(PLAYER[SOUTH]); break; case 0: out.print(PLAYER[WEST]); break; } out.println("
"); out.print("Vuln: "); switch (num % 16) { // ALL case 4: case 7: case 10: case 13: out.print("ALL"); break; // N-S case 2: case 5: case 12: case 15: out.print("N-S"); break; // E-W case 3: case 6: case 9: case 0: out.print("E-W"); break; // NONE default: out.print("NONE"); } out.print("
"); // 0 // 3 1 // 2 out.println(""); // NORTH; out.println(""); // WEST out.println(""); // EAST out.println(""); // SOUTH out.println(""); out.println("
"); out.println("
    "); for (int i = 0; i < 4; i++) { out.print("
  • "); out.print(printablehand[i]); out.println("
  • "); } out.println("
"); out.println("
"); out.println("
    "); for (int i = 4; i < 8; i++) { out.print("
  • "); out.print(printablehand[i]); out.println("
  • "); } out.println("
"); out.println("
"); out.println("
    "); for (int i = 8; i < 12; i++) { out.print("
  • "); out.print(printablehand[i]); out.println("
  • "); } out.println("
"); out.println("
"); out.println("
    "); for (int i = 12; i < 16; i++) { out.print("
  • "); out.print(printablehand[i]); out.println("
  • "); } out.println("
"); out.println("
"); } public void printCurtains(int num, byte[][] hand) { if (!infulltable) startfulltable(); if (incell) stopcell(); if (inrow) stoprow(); inback=false; startrow(6); startcell(); String[] printablehand = getHandPrintables(hand); out.println("

Board "+num+" "+PLAYER[NORTH]+"

"); out.println("
    "); for (int i = 0; i < 4; i++) { out.print("
  • "); out.print(printablehand[i]); out.println("
  • "); } out.println("
"); stopcell(); startcell(); out.println("

Board "+num+" "+PLAYER[EAST]+"

"); out.println("
    "); for (int i = 8; i < 12; i++) { out.print("
  • "); out.print(printablehand[i]); out.println("
  • "); } out.println("
"); stopcell(); startcell(); out.println("

Board "+num+" "+PLAYER[SOUTH]+"

"); out.println("
    "); for (int i = 12; i < 16; i++) { out.print("
  • "); out.print(printablehand[i]); out.println("
  • "); } out.println("
"); stopcell(); startcell(); out.println("

Board "+num+" "+PLAYER[WEST]+"

"); out.println("
    "); for (int i = 4; i < 8; i++) { out.print("
  • "); out.print(printablehand[i]); out.println("
  • "); } out.println("
"); stopcell(); } public void printCurtainBack(int num) { if (!infulltable) startfulltable(); if (incell) stopcell(); if (inrow) stoprow(); if (!inback) { out.println(""); rowcount=0; } inback=true; startrow(6); startcell(); out.println("

Board "+num+" "+PLAYER[WEST]+"

"); stopcell(); startcell(); out.println("

Board "+num+" "+PLAYER[SOUTH]+"

"); stopcell(); startcell(); out.println("

Board "+num+" "+PLAYER[EAST]+"

"); stopcell(); startcell(); out.println("

Board "+num+" "+PLAYER[NORTH]+"

"); stopcell(); } public void printPermutation1(int boardnum, byte[][] perm) { // TODO } public void printPermutation(int permnum, int boardnum, byte[] perm, byte[] initperm) { if (incell) stopcell(); if (inrow) stoprow(); if (infulltable) stopfulltable(); out.println("

Board "+boardnum+" permutation "+permnum+"

"); if (null != initperm) { out.println("

Order the suits: "); for (int i = 0; i < 4; i++) { out.print(""); out.print(LONGSUIT[initperm[i] >> 4]); out.print(""); if (i < 3) out.print(", "); } out.println("

"); } permcount++; if (0 == (permcount % 8)) out.print("

"); else out.print("

"); for (int k = 0; k < 52; k++) { out.print(perm[k]+1); if (3 == k % 4) out.print("     "); if (19 == k % 20) out.println("
"); } out.println("

"); } public void close() { if (incell) stopcell(); if (inrow) stoprow(); if (infulltable) stopfulltable(); out.println(""); out.close(); } public void printStats(double[] stats) { DecimalFormat df = new DecimalFormat("##.##"); if (incell) stopcell(); if (inrow) stoprow(); if (infulltable) stopfulltable(); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.println("
North avg points: "); out.print(df.format(stats[STAT_NPOINTS])); out.println("South avg points: "); out.print(df.format(stats[STAT_SPOINTS])); out.println("East avg points: "); out.print(df.format(stats[STAT_EPOINTS])); out.println("West avg points: "); out.print(df.format(stats[STAT_WPOINTS])); out.println("
North-South Games: "); out.print((int)stats[STAT_NSGAMES]); out.println("East-West Games: "); out.print((int)stats[STAT_EWGAMES]); out.println("North-South Slams: "); out.print((int)stats[STAT_NSSLAMS]); out.println("East-West Slams: "); out.print((int)stats[STAT_EWSLAMS]); out.println("
# 4333 Hands: "); out.print((int) stats[STAT_4333]); out.println("# Balanced Hands: "); out.print((int) stats[STAT_BAL]); out.println("# Semi-Balanced Hands: "); out.print((int) stats[STAT_SEMIBAL]); out.println("# 4441 Hands: "); out.print((int) stats[STAT_4441]); out.println("
# 5-5 Hands: "); out.print((int) stats[STAT_55]); out.println("# 6+ Suits: "); out.print((int)stats[STAT_6PLUS]); out.println("# 7+ Suits: "); out.print((int)stats[STAT_7PLUS]); out.println("# 8+ Suits: "); out.print((int)stats[STAT_8PLUS]); out.println("
# Voids: "); out.print((int)stats[STAT_VOID]); out.println("# Bacon Hands: "); out.print((int)stats[STAT_BACON]); out.println("
"); } public void printPoints(byte[] points) { if (!infulltable) startfulltable(); if (!inrow) startrow(6); if (!incell) startcell(); out.println(""); out.print(""); out.print(""); out.println(""); out.print(""); out.print(""); out.print(""); out.println(""); out.print(""); out.print(""); out.println(""); out.println("
"); out.print(points[NORTH]); out.print("
"); out.print(points[WEST]); out.print(""); out.print(points[EAST]); out.print("
"); out.print(points[SOUTH]); out.print("
"); } public void printTricks(byte[] tricks) { if (!infulltable) startfulltable(); if (!inrow) startrow(6); if (!incell) startcell(); out.println(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.println(""); out.print(""); out.print(""); for (int i = 4; i >= 0; i--) { out.print(""); } out.println(""); out.print(""); for (int i = 9; i >= 5; i--) { out.print(""); } out.println(""); out.print(""); for (int i = 14; i >= 10; i--) { out.print(""); } out.println(""); out.print(""); for (int i = 19; i >= 15; i--) { out.print(""); } out.println(""); out.println("
"); out.print(SUIT[CLUBS>>4]); out.print(""); out.print(SUIT[DIAMONDS>>4]); out.print(""); out.print(SUIT[HEARTS>>4]); out.print(""); out.print(SUIT[SPADES>>4]); out.print(""); out.print(SUIT[NOTRUMPS>>4]); out.print("
N"); out.print(tricks[i]); out.print("
S"); out.print(tricks[i]); out.print("
E"); out.print(tricks[i]); out.print("
W"); out.print(tricks[i]); out.print("
"); } public void println(String s) { out.print(s); out.println("
"); } public void print(String s) { out.print(s); } } pescetti-0.5/cx/ath/matthew/pescetti/TextPrinter.java0000644000175000017500000001640011115747364021472 0ustar mjj29mjj29/* * Pescetti Pseudo-Duplimate Generator * * Copyright (C) 2007 Matthew Johnson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License Version 2 as published by * the Free Software Foundation. This program is distributed in the hope that * it will be useful, but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. You should have received a * copy of the GNU General Public License along with this program; if not, * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * To Contact me, please email src@matthew.ath.cx * */ package cx.ath.matthew.pescetti; import cx.ath.matthew.debug.Debug; import java.io.PrintStream; import java.text.DecimalFormat; public class TextPrinter extends Printer implements Constants { private PrintStream out; public TextPrinter(PrintStream out, String header) { this.out = out; out.println(header); for (int i = 0; i < header.length(); i++) out.print('-'); out.println(); } public void printHand(int num, byte[][] hand) { String[] printablehand = getHandPrintables(hand); out.println("Board "+num+": "); // 0 // 3 1 // 2 out.println(" "+PLAYER[NORTH]); for (int i = 0; i < 4; i++) { out.print(" "); out.println(printablehand[i]); } out.println(" HCP: "+count(hand[NORTH])); out.println(); out.println(PLAYER[WEST]+" "+PLAYER[EAST]); for (int i = 4; i < 8; i++) { out.print(printablehand[i]); for (int j = 0; j < (16-printablehand[i].length()); j++) out.print(' '); out.println(printablehand[i+4]); } String hcp = ""+count(hand[WEST]); out.print("HCP: "+hcp); for (int j = 0; j < (11-hcp.length()); j++) out.print(' '); out.println("HCP: "+count(hand[EAST])); out.println(); out.println(" "+PLAYER[SOUTH]); for (int i = 12; i < 16; i++) { out.print(" "); out.println(printablehand[i]); } out.println(" HCP: "+count(hand[SOUTH])); out.println(); } public void printCurtains(int num, byte[][] hand) { String[] printablehand = getHandPrintables(hand); out.println("Board "+num+" "+PLAYER[NORTH]+": "); for (int i = 0; i < 4; i++) { out.print(" "); out.println(printablehand[i]); } out.println(); out.println("---------------------------------"); out.println(); out.println("Board "+num+" "+PLAYER[EAST]+": "); for (int i = 8; i < 12; i++) { out.print(" "); out.println(printablehand[i]); } out.println(); out.println("---------------------------------"); out.println(); out.println("Board "+num+" "+PLAYER[SOUTH]+": "); for (int i = 12; i < 16; i++) { out.print(" "); out.println(printablehand[i]); } out.println(); out.println("---------------------------------"); out.println(); out.println("Board "+num+" "+PLAYER[WEST]+": "); for (int i = 4; i < 8; i++) { out.print(" "); out.println(printablehand[i]); } out.println(); out.println("---------------------------------"); out.println(); } public void printCurtainBack(int num) { return; // do nothing } public void printPermutation1(int boardnum, byte[][] perm) { out.println("Board "+boardnum+" permutation 1:"); out.println("Deal this number into each pile:"); out.println(); for (byte i: perm[0]) { out.print(i); out.print(' '); } out.println(); out.println(); out.println("Pick the piles up in this order:"); out.println(); for (byte i: perm[1]) { out.print(i); out.print(' '); } out.println(); out.println(); } public void printPermutation(int permnum, int boardnum, byte[] perm, byte[] initperm) { out.println("Board "+boardnum+" permutation "+permnum+":"); if (null != initperm) { out.print("Order the suits: "); for (int i = 0; i < 4; i++) { out.print(LONGSUIT[initperm[i] >> 4]); out.print(' '); } out.println(); } out.print(" "); for (int k = 0; k < 52; k++) { out.print(perm[k]+1); if (3 == k % 4) out.print(' '); if (23 == k % 24) { out.println(); out.print(" "); } } out.println(); out.println(); } public void close() { out.println(); out.close(); } public void printPoints(byte[] points) {} public void printTricks(byte[] tricks) { out.println(" "+SUIT[CLUBS>>4]+" "+SUIT[DIAMONDS>>4]+" "+SUIT[HEARTS>>4]+" "+SUIT[SPADES>>4]+" "+SUIT[NOTRUMPS>>4]); out.print("N"); for (int i = 4; i >= 0; i--) out.print(" "+tricks[i]+(tricks[i] < 10 ? " ":"")); out.println(); out.print("S"); for (int i = 9; i >= 5; i--) out.print(" "+tricks[i]+(tricks[i] < 10 ? " ":"")); out.println(); out.print("E"); for (int i = 14; i >= 10; i--) out.print(" "+tricks[i]+(tricks[i] < 10 ? " ":"")); out.println(); out.print("W"); for (int i = 19; i >= 15; i--) out.print(" "+tricks[i]+(tricks[i] < 10 ? " ":"")); out.println(); out.println(); } public void println(String s) { out.println(s); } public void print(String s) { out.print(s); } public void printStats(double[] stats) { DecimalFormat df = new DecimalFormat("##.##"); out.print("North avg points: "); out.println(df.format(stats[STAT_NPOINTS])); out.print("South avg points: "); out.println(df.format(stats[STAT_SPOINTS])); out.print("East avg points: "); out.println(df.format(stats[STAT_EPOINTS])); out.print("West avg points: "); out.println(df.format(stats[STAT_WPOINTS])); out.print("North-South Games: "); out.println((int)stats[STAT_NSGAMES]); out.print("East-West Games: "); out.println((int)stats[STAT_EWGAMES]); out.print("North-South Slams: "); out.println((int)stats[STAT_NSSLAMS]); out.print("East-West Slams: "); out.println((int)stats[STAT_EWSLAMS]); out.print("# 4333 Hands: "); out.println((int) stats[STAT_4333]); out.print("# Balanced Hands: "); out.println((int) stats[STAT_BAL]); out.print("# Semi-Balanced Hands: "); out.println((int) stats[STAT_SEMIBAL]); out.print("# 4441 Hands: "); out.println((int) stats[STAT_4441]); out.print("# 5-5 Hands: "); out.println((int) stats[STAT_55]); out.print("# 6+ Suits: "); out.println((int)stats[STAT_6PLUS]); out.print("# 7+ Suits: "); out.println((int)stats[STAT_7PLUS]); out.print("# 8+ Suits: "); out.println((int)stats[STAT_8PLUS]); out.print("# Voids: "); out.println((int) stats[STAT_VOID]); out.print("# Bacons: "); out.println((int) stats[STAT_BACON]); } } pescetti-0.5/cx/ath/matthew/pescetti/.PDFPrinter.java.swp0000644000175000017500000011000011300052302022005 0ustar mjj29mjj29b0VIM 7.1SKdmjj29qadesh/mnt/tmp/mjj29/scm/bridgedeal/cx/ath/matthew/pescetti/PDFPrinter.javautf-8 3210#"! UtpURD6|M%Vad c ]v) E % " ~ \ >  c v L 0 \ B  e A   ON6_WD*lXC.iU@${S/tH w[ZL#$ out.println(""); // EAST out.println(""); out.println(""); } out.println(""); out.print(printablehand[i]); out.print("
  • "); for (int i = 4; i < 8; i++) { out.println("
      "); out.println(""); // WEST out.println(""); out.println("
    "); } out.println("
  • "); out.print(printablehand[i]); out.print("
  • "); for (int i = 0; i < 4; i++) { out.println("
      "); out.println(""); // NORTH; out.println(""); // 2 // 3 1 // 0 } vuln="NONE"; default: // NONE break; vuln="E-W"; case 0: case 9: case 6: case 3: // E-W break; vuln="N-S"; case 15: case 12: case 5: case 2: // N-S break; vuln="ALL"; case 13: case 10: case 7: case 4: // ALL switch (num % 16) { String vuln; } case 0: dealer = PLAYER[WEST]; break; case 3: dealer = PLAYER[SOUTH]; break; case 2: dealer = PLAYER[EAST]; break; case 1: dealer = PLAYER[NORTH]; break; switch (num % 4) { String dealer=""; String[] printablehand = getHandPrintables(hand); doc.add(numc); numc.setLeft(tlx+10); numc.setTop(tly+10); numc.add(num); Cell numc = new Cell(); doc.add(box); box.setBorderColor(Color.BLACK); box.setBorder(Rectangle.BOX); /*Rectangle box = new Rectangle(tlx, tly+HEIGHT, tlx+WIDTH, tly); { public void printHand(int num, byte[][] hand) } } if (Debug.debug) Debug.print(De); } catch (DocumentException De) { document.open(); document.addTitle(header); PdfWriter.getInstance(doc, out); this.doc = new PdfDocument(); this.out = out; try { { public PDFPrinter(PrintStream out, String header) private PdfDocument doc; private static finalimport com.lowagie.text.pdf.draw.LineSeparator;import com.lowagie.text.pdf.PdfWriter;import com.lowagie.text.Table;import com.lowagie.text.Phrase;import com.lowagie.text.Paragraph;import com.lowagie.text.PageSize;import com.lowagie.text.Font;import com.lowagie.text.Document;import com.lowagie.text.DocumentException;import com.lowagie.text.Cell;package cx.ath.matthew.pescetti; */ * * To Contact me, please email src@matthew.ath.cx * * Boston, MA 02111-1307, USA. * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * copy of the GNU General Public License along with this program; if not, * GNU General Public License for more details. You should have received a * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * it will be useful, but WITHOUT ANY WARRANTY; without even the implied * the Free Software Foundation. This program is distributed in the hope that * under the terms of the GNU General Public License Version 2 as published by * This program is free software; you can redistribute it and/or modify it * * Copyright (C) 2007 Matthew Johnson * * Pescetti Pseudo-Duplimate Generator/* adTVWA<yH2- h 7 !  W &  j b ] 3 .  t \ D "  x -  z/~38#:%ld_>9#xu} } out.pri} }} } out.print(s); { public void print(String s) } out.println("
      ");*/ /* out.print(s); { public void println(String s) } } if (Debug.debug) Debug.print(De); } catch (DocumentException De) { handstruct.addCell(r, 2, 0); r.setVerticalAlignment(Cell.ALIGN_MIDDLE); Cell r = new Cell(table); table.addCell(c); c = new Cell(new Phrase("", new Font(Font.HELVETICA, 6, Font.NORMAL))); table.addCell(c); c.setHorizontalAlignment(Cell.ALIGN_CENTER); c = new Cell(new Phrase(""+points[SOUTH], new Font(Font.HELVETICA, 6, Font.NORMAL))); table.addCell(c); c = new Cell(new Phrase("", new Font(Font.HELVETICA, 6, Font.NORMAL))); table.addCell(c); c.setHorizontalAlignment(Cell.ALIGN_LEFT); c = new Cell(new Phrase(""+points[EAST], new Font(Font.HELVETICA, 6, Font.NORMAL))); table.addCell(c); c = new Cell(new Phrase("", new Font(Font.HELVETICA, 6, Font.NORMAL))); table.addCell(c); c.setHorizontalAlignment(Cell.ALIGN_RIGHT); c = new Cell(new Phrase(""+points[WEST], new Font(Font.HELVETICA, 6, Font.NORMAL))); table.addCell(c); c = new Cell(new Phrase("", new Font(Font.HELVETICA, 6, Font.NORMAL))); table.addCell(c); c.setHorizontalAlignment(Cell.ALIGN_CENTER); c = new Cell(new Phrase(""+points[NORTH], new Font(Font.HELVETICA, 6, Font.NORMAL))); table.addCell(c); c = new Cell(new Phrase("", new Font(Font.HELVETICA, 6, Font.NORMAL))); table.addCell(c); c.setColspan(3); c = new Cell(new Phrase(" ", new Font(Font.HELVETICA, 6, Font.NORMAL))); table.endHeaders(); table.setDefaultLayout(c); c.setBorderColor(Color.WHITE); Cell c = new Cell(); table.setPadding(0); table.setBorderColor(Color.WHITE); Table table = new Table(3); try { if (!incell) startcell();*/ if (!inrow) startrow(6); /*if (!infulltable) startfulltable(); { public void printPoints(byte[] points) } } if (Debug.debug) Debug.print(De); } catch (DocumentException De) { handstruct.addCell(r, 2, 2); r.setWidth("100"); Cell r = new Cell(table); } table.addCell(c); c.setHorizontalAlignment(Cell.ALIGN_CENTER); c = new Cell(new Phrase(""+tricks[i], new Font(Font.HELVETICA, 5, Font.NORMAL))); for (int i = 19; i >= 15; i--) { table.addCell(new Phrase("W", new Font(Font.HELVETICA, 5, Font.BOLD))); } table.addCell(c); c.setHorizontalAlignment(Cell.ALIGN_CENTER); c = new Cell(new Phrase(""+tricks[i], new Font(Font.HELVETICA, 5, Font.NORMAL))); for (int i = 14; i >= 10; i--) { table.addCell(new Phrase("E", new Font(Font.HELVETICA, 5, Font.BOLD))); } table.addCell(c); c.setHorizontalAlignment(Cell.ALIGN_CENTER); c = new Cell(new Phrase(""+tricks[i], new Font(Font.HELVETICA, 5, Font.NORMAL))); for (int i = 9; i >= 5; i--) { table.addCell(new Phrase("S", new Font(Font.HELVETICA, 5, Font.BOLD))); } table.addCell(c); c.setHorizontalAlignment(Cell.ALIGN_CENTER); c = new Cell(new Phrase(""+tricks[i], new Font(Font.HELVETICA, 5, Font.NORMAL))); for (int i = 4; i >= 0; i--) {ad 6]mWB'  o i  p X A + & p M "    j L D  f @ $ ;  X-tI-qT1Z1UP$iH.iG- out.print(SUIT[NOTRUMPS>>4]); out.print(""); out.print(SUIT[SPADES>>4]); out.print(""); out.print(SUIT[HEARTS>>4]); out.print(""); out.print(SUIT[DIAMONDS>>4]); out.print(""); out.print(SUIT[CLUBS>>4]); out.print(""); out.print(""); out.println("
      "); out.print(""); out.print(""); out.print(""); out.print(""); out.print("
      "); if (!incell) startcell(); if (!inrow) startrow(); /*if (!infulltable) startfulltable(); { public void printTricks(byte[] tricks) } out.println("
      ");*/ out.println(""); out.print((int)stats[STAT_8PLUS]); out.print("# 8+ suits: "); out.println(""); out.print((int)stats[STAT_7PLUS]); out.print("# 7+ suits: "); out.println(""); out.print((int)stats[STAT_6PLUS]); out.print("# 6+ suits: "); out.println("%"); out.print(stats[STAT_BAL]); out.print("Balanced: "); out.println("%"); out.print(stats[STAT_4333]); out.print("4333: "); out.println(""); out.print((int)stats[STAT_EWSLAMS]); out.print("East-West Slams: "); out.println(""); out.print((int)stats[STAT_NSSLAMS]); out.print("North-South Slams: "); out.println(""); out.print((int)stats[STAT_EWGAMES]); out.print("East-West Games: "); out.println(""); out.print((int)stats[STAT_NSGAMES]); out.print("North-South Games: "); out.println("< out.println(" o o out.println("");*/ out.println("");* out.println("");*/ out.println(" out.print out.println("");*/ if ( doc.add(struct); if (infulltable) stopfulltable(); try { if (inrow) stoprow();*/ /*if (incell) stopcell(); { public void close() } infulltable = false; if (incell) stopcell(); { public void stopfulltable() throws DocumentException } } if (Debug.debug) Debug.print(De); } catch (DocumentException De) { if (2 == permnum && 0 == boardnum % 2) newpage(); struct.addCell(c); c.setColspan(4); c = new Cell(new Phrase(sb.toString(), new Font(Font.HELVETICA, 14, Font.NORMAL))); } sb.append("\n"); if (19 == k % 20) sb.append(" "); if (3 == k % 4) sb.append(""+(perm[k]+1)); for (int k = 0; k < 52; k++) { sb = new StringBuilder(); } struct.addCell(c); c.setColspan(4); c = new Cell(new Phrase(sb.toString(), new Font(Font.HELVETICA, 10, Font.BOLD))); } sb.append(", "); if (i < 3) sb.append(LONGSUIT[initperm[i] >> 4]); for (int i = 0; i < 4; i++) { sb.append("Order the suits: "); sb = new StringBuilder(); if (null != initperm) { StringBuilder sb; struct.addCell(c); c.setColspan(4); Cell c = new Cell(new Phrase("Board "+boardnum+" permutation "+permnum, new Font(Font.HELVETICA, 12, Font.BOLD))); try { { public void printPermutation(int permnum, int boardnum, byte[] perm, byte[] initperm) public void printPermutation1(int num, byte[][] perm){} public void printCurtainBack(int num){} public void printCurtains(int num, byte[][] hand){} }adeMZUM`IH)   c L K [ k S = < # <PqY9"!CcK549T) zutJEw^=# w^<"  out.print(SUIT[NOTRUMPS>>4]); out.print(""); out.print(""); out.print(SUIT[SPADES>>4]); out.print(""); out.print(""); out.print(SUIT[HEARTS> c = new Cell(table); table.addCell(new Phrase("# Bacon hands: "+(int)stats[STAT_BACON], new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("# Voids: "+(int)stats[STAT_VOID], new Font(Font.HELVETICA, 10, Font.NORMAL))); table.endHeaders(); table.setDefaultLayout(def); table.setPadding(2); table.setBorderColor(Color.WHITE); table = new Table(1); struct.addCell(c); c = new Cell(table); table.addCell(new Phrase("# 8+ suits: "+(int)stats[STAT_8PLUS], new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("# 7+ suits: "+(int)stats[STAT_7PLUS], new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("# 6+ suits: "+(int)stats[STAT_6PLUS], new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("# 5-5 hands: "+(int)stats[STAT_55], new Font(Font.HELVETICA, 10, Font.NORMAL))); table.endHeaders(); table.setDefaultLayout(def); table.setPadding(2); table.setBorderColor(Color.WHITE); table = new Table(1); struct.addCell(c); c = new Cell(table); table.addCell(new Phrase("# 4441 hands: "+(int)stats[STAT_4441], new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("# Semi-bal hands: "+(int)stats[STAT_SEMIBAL], new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("# Balanced hands: "+(int)stats[STAT_BAL], new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("# 4333 hands: "+(int)stats[STAT_4333], new Font(Font.HELVETICA, 10, Font.NORMAL))); table.endHeaders(); table.setDefaultLayout(def); table.setPadding(2); table.setBorderColor(Color.WHITE); table = new Table(1); struct.addCell(c); c = new Cell(table); table.addCell(new Phrase("East-West slams: "+(int)stats[STAT_NSSLAMS], new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("North-South slams: "+(int)stats[STAT_NSSLAMS], new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("East-West games: "+(int)stats[STAT_NSGAMES], new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("North-South games: "+(int)stats[STAT_NSGAMES], new Font(Font.HELVETICA, 10, Font.NORMAL))); table.endHeaders(); table.setDefaultLayout(def); table.setPadding(2); table.setBorderColor(Color.WHITE); table = new Table(1); struct.addCell(c); Cell c = new Cell(table); table.addCell(new Phrase("West avg points: "+df.format(stats[STAT_WPOINTS]), new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("East avg points: "+df.format(stats[STAT_EPOINTS]), new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("South avg points: "+df.format(stats[STAT_SPOINTS]), new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("North avg points: "+df.format(stats[STAT_NPOINTS]), new Font(Font.HELVETICA, 10, Font.NORMAL))); if (infulltable) stopfulltable(); /* if (inrow) stoprow();*/ table.endHeaders(); table.setDefaultLayout(def); table.setPadding(2); table.setBorderColor(Color.WHITE); Table table = new Table(1); def.setBorderColor(Color.WHITE); Cell def = new Cell(); DecimalFormat df = new DecimalFormat("##.##"); try { { public void printStats(double[] stats) } } if (Debug.debug) Debug.print(De); } catch (DocumentException De) { out.close(); doc.close();adUmQ10eG t [  y [ I (  v O $   a D 3   | R O -   ~^G&zZ?/lL.c;vug>lKJ;qRJ.  out.println(""); out.println("
    "); } out.println("
  • "); out.print(printablehand[i]); out.print("
  • "); for (int i = 12; i < 16; i++) { out.println("
      "); out.println(""); // SOUTH out.println(""); out.println("
    "); } out.println("
  • "); out.print(printablehand[i]); out.print("
  • "); for (int i = 8; i < 12; i++) { out.println("
      "); out.println(""); // EAST out.println(""); out.println("
    "); } out.println("
  • "); out.print(printablehand[i]); out.print("
  • "); for (int i = 4; i < 8; i++) { out.println("
      "); out.println(""); // WEST out.println(""); out.println("
    "); } out.prin vuln.append("Dlr: "); StringBuilder vuln = new StringBuilder(); handstruct.addCell(c, 0, 0); c.setHorizontalAlignment(Cell.ALIGN_CENTER); Cell c = new Cell(new Phrase(""+num, new Font(Font.HELVETICA, 12, Font.BOLD))); String[] printablehand = getHandPrintables(hand, SHORTSUIT); startcell(); if (incell) stopcell(); if (!inrow) startrow(6);*/ /*if (!infulltable) startfulltable(); try { { public void printHand(int num, byte[][] hand) } cellcount++; incell = true; handstruct.setDefaultLayout(c); c.setBorderColor(Color.WHITE); Cell c = new Cell(); handstruct.setBorderWidth(1); handstruct.setBorderColor(new Color(0, 0, 0)); handstruct.setWidth(100); handstruct = new Table(3,3); { void startcell() throws DocumentException } incell = false; struct.insertTable(handstruct); { void stopcell() throws DocumentException } struct.setDefaultLayout(c); c.setBorderColor(Color.BLACK); Cell c = new Cell(); struct.setBorderColor(Color.WHITE); struct.setWidth(100); struct = new Table(MAXCELLS); doc.add(head); head.setSpacingAfter(-20); Paragraph head = new Paragraph(header, new Font(Font.HELVETICA, 16, Font.BOLD)); doc.add(struct); if (infulltable) stopfulltable(); { void newpage() throws DocumentException } } if (Debug.debug) Debug.print(De); } catch (DocumentException De) { this.header = header; struct.setDefaultLayout(c); c.setBorderColor(Color.BLACK); Cell c = new Cell(); struct.setBorderColor(Color.WHITE); struct.setWidth(100); struct = new Table(MAXCELLS); doc.add(head); head.setSpacingAfter(-20); Paragraph head = new Paragraph(header, new Font(Font.HELVETICA, 16, Font.BOLD)); doc.open(); doc.addTitle(header); PdfWriter.getInstance(doc, out); this.doc = new Document(PageSize.A4, 20,20,20,10); this.out = out; try { { public PDFPrinter(PrintStream out, String header) private String header; private Table handstruct; private Table struct; private Document doc; private static final int MAXCELLS = 4; private int cellcount = 0; private boolean incell = false; /*private boolean inrow = false;*/ private boolean infulltable = true; private PrintStream out;{public class PDFPrinter extends Printer implements Constantsimport java.text.DecimalFormat;import java.io.PrintStream;import java.awt.Color; import cx.ath.matthew.debug.Debug;ad P %fa5xV8 ] H A  l W P Y w T 1  t H ,  ` ?  gA`D out.print(SUIT[NOTR out.print(SUIT[NOTRUMP out.print(SUIT[NOTRUMPS>>4]); out.print(SUIT[NOTRUMPS out.print(SUIT[NOTRUMPS>>4]); out.p out.print(SUIT[NOTRUMPS>>4]); out.print(SUIT[NOTRUMP out.print(SUIT[NOTRUMPS>>4]); o out.print(SUIT[NOTRUMPS>>4]); out.print(SUIT[NOTRUMP out.print(SUIT[NOTRUMPS>>4]); out.print(SUIT[NOTRUMPS>>4]); out.print(SUIT[NOTRUMP out.print(SUIT[NOTRUMPS>>4]); out.print(SUIT[NOTRUMPS>>4]); out.print(SUIT[NOTRUMPS>>4] out.print(SUIT[NOTRUMPS>>4]); out.pr out.print(SUIT[NOTRUMPS>>4]); o out.print(SUIT[NOTRUMP out.print(SUIT[NOTRUMPS>>4]); out.print(SUIT[NOTRUMPS>>4]); o out.print(SUIT[NOTRUMP table.addCell(new Phrase("N", new Font(Font.HELVETICA, 5, Font.BOLD))); table.endHeaders(); table.addCell(c); c.setHorizontalAlignment(Cell.ALIGN_CENTER); c = new Cell(new Phrase(""+DINGSUIT[NOTRUMPS>>4], new Font(Font.HELVETICA, 6, Font.BOLD))); table.addCell(c); c.setHorizontalAlignment(Cell.ALIGN_CENTER); c = new Cell(new Phrase(""+DINGSUIT[SPADES>>4], new Font(Font.ZAPFDINGBATS, 6, Font.BOLD))); table.addCell(c); c.setHorizontalAlignment(Cell.ALIGN_CENTER); c = new Cell(new Phrase(""+DINGSUIT[HEARTS>>4], new Font(Font.ZAPFDINGBATS, 6, Font.BOLD))); table.addCell(c); c.setHorizontalAlignment(Cell.ALIGN_CENTER); c = new Cell(new Phrase(""+DINGSUIT[DIAMONDS>>4], new Font(Font.ZAPFDINGBATS, 6, Font.BOLD))); table.addCell(c); c.setHorizontalAlignment(Cell.ALIGN_CENTER); c = new Cell(new Phrase(""+DINGSUIT[CLUBS>>4], new Font(Font.ZAPFDINGBATS, 6, Font.BOLD))); table.addCell(new Phrase("", new Font(Font.HELVETICA, 6, Font.NORMAL))); table.setDefaultLayout(c); c.setBorderColor(Color.WHITE); Cell c = new Cell(); table.setPadding(0); table.setBorderColor(Color.WHITE); Table table = new Table(6); try { if (!incell) startcell();*/ if (!inrow) startrow(); /*if (!infulltable) startfulltable(); { public void printTricks(byte[] tricks) } } if (Debug.debug) Debug.print(De); } catch (DocumentException De) { struct.addCell(c);adoR^0+~reX?3' + *   k f n P *  b 9 8 - I  id solV92 V8F1 out.println("< out.println(""); } if (Debug.debug) } if (Debug.deb } } if (Debug.debug) Debug. } if (Debug.debug) Debug.prin } if (Debug.debug) Debug.pri } if (Debug.debug) } if (Debug.debug) } if (Debug.debug) Debug.prin } if (Debug.debug) D } if (Debug.debug) Debug.print(De } } if (Debug.debug) Debug } } if (Debu } if (Debug.debug) Debug.print(De); } catch (DocumentException De) { handstruct.addCell(c, 2, 1); c.setHorizontalAlignment(Cell.ALIGN_LEFT); c = new Cell(new Phrase(handstr.toString(), new Font(Font.HELVETICA, 7, Font.NORMAL))); } handstr.append("\n"); handstr.append(printablehand[i]); for (int i = 12; i < 16; i++) { handstr = new StringBuilder(); // SOUTH handstruct.addCell(c, 1, 2); c.setHorizontalAlignment(Cell.ALIGN_LEFT); c = new Cell(new Phrase(handstr.toString(), new Font(Font.HELVETICA, 7, Font.NORMAL))); } handstr.append("\n"); handstr.append(printablehand[i]); for (int i = 8; i < 12; i++) { handstr = new StringBuilder(); // EAST handstruct.addCell(new Cell(), 1, 1); handstruct.addCell(c, 1, 0); c.setHorizontalAlignment(Cell.ALIGN_LEFT); c = new Cell(new Phrase(handstr.toString(), new Font(Font.HELVETICA, 7, Font.NORMAL))); } handstr.append("\n"); handstr.append(printablehand[i]); handstr.append(" "); for (int i = 4; i < 8; i++) { handstr = new StringBuilder(); // WEST handstruct.addCell(c, 0, 1); c.setHorizontalAlignment(Cell.ALIGN_LEFT); c = new Cell(new Phrase(handstr.toString(), new Font(Font.HELVETICA, 7, Font.NORMAL))); } handstr.append("\n"); handstr.append(printablehand[i]); for (int i = 0; i < 4; i++) { StringBuilder handstr = new StringBuilder(); // NORTH; // 2 // 3 1 // 0 handstruct.addCell(new Cell(new Phrase(vuln.toString(), new Font(Font.HELVETICA, 8, Font.NORMAL))), 0, 2); } vuln.append("NONE"); default: // NONE break; vuln.append("E-W"); case 0: case 9: case 6: case 3: // E-W break; vuln.append("N-S"); case 15: case 12: case 5: case 2: // N-S break; vuln.append("ALL"); case 13: case 10: case 7: case 4: // ALL switch (num % 16) { vuln.append("\nVuln: "); } case 0: vuln.append(PLAYER[WEST]); break; case 3: vuln.append(PLAYER[SOUTH]); break; case 2: vuln.append(PLAYER[EAST]); break; case 1: vuln.append(PLAYER[NORTH]); break; switch (num % 4) {pescetti-0.5/cx/ath/matthew/pescetti/.pescetti.java.swo0000644000175000017500000021000011277773667021715 0ustar mjj29mjj29b0VIM 7.1Jcmjj29qadesh/mnt/tmp/mjj29/scm/bridgedeal/cx/ath/matthew/pescetti/pescetti.javautf-8 3210#"! Utpw x a j\ x i>QZROYtXOqadw]v) E % " ~ _ J * p W = & \ & ! u \ - vhJ.)(!{^=)rH#kI$UTwrR/snmf6/ public static byte[][] cutDeck(byte[][] deck, int cutpoint) */ * Returns a deck cut to the given position. /** } return (s << 4) | c; if (Debug.debug) Debug.print(Debug.DEBUG, "Cut point: suit="+s+", card="+c); c += 2; s += 1; if (c < 0) c = -c; if (s < 0) s = -s; int c = sr.nextInt() % KING; int s = sr.nextInt() % 4; { public static int getCutPoint() */ * Generates a random card to cut to. /** } return new byte[][] { res, res2 }; if (Debug.debug) Debug.print(Debug.DEBUG, "Pickup: "+Arrays.toString(res2)); swap(res2, k, Math.abs(rand[k]) % 10); for (byte k = 0; k < 10; k++) sr.nextBytes(rand); byte[] rand = new byte[10]; // knuth shuffle res2[i] = (byte) (i+1); for (byte i = 0; i < 10; i++) byte[] res2 = new byte[10]; // pickup order if (Debug.debug) Debug.print(Debug.DEBUG, "First perm: "+Arrays.toString(res)); } rem -= res[i]; res[i] = (byte) (bottom + rand); if (rand < 0) rand = -rand; int rand = sr.nextInt() % range; int range = top - bottom + 1; int bottom = Math.max(3, rem - 8*(10-(i+1))); int top = Math.min(8, rem - 3*(10-(i+1))); for (int i = 0; i < 10; i++) { int rem = 52; byte[] res = new byte[10]; // number in each pile { public static byte[][] generatePermutation1() */ * Result is 10 random numbers between 3 and 8 which sum to 52. * Generates a part 1 permutation. /** } } else { return ""; } return b.toString(); } b.append(' '); b.append(SUIT[deck[i][j] >> 4]); b.append(CARD[deck[i][j] & 0x0f]); for (int j = 0; j < deck[i].length; j++) { for (int i = 0; i < deck.length; i++) if (Debug.debug) { StringBuffer b = new StringBuffer(); { public static String formatDeck(byte[][] deck) } perm[b] = t; perm[a] = perm[b]; byte t = perm[a]; { public static void swap(byte[] perm, int a, int b) private static SecureRandom sr = new SecureRandom();{public class pescetti implements Constantsimport static cx.ath.matthew.pescetti.Gettext._;import java.util.Vector;import java.util.Random;import java.util.List;import java.util.HashMap;import java.util.Arrays;import java.security.SecureRandom;import java.io.PrintStream;import java.io.IOException;import java.io.InputStreamReader;import java.io.InputStream;import java.io.FileOutputStream;import java.io.FileInputStream;import java.io.File;import java.io.BufferedReader;import java.io.BufferedInputStream;import cx.ath.matthew.debug.Debug;package cx.ath.matthew.pescetti; */ * * To Contact me, please email src@matthew.ath.cx * * Boston, MA 02111-1307, USA. * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * copy of the GNU General Public License along with this program; if not, * GNU General Public License for more details. You should have received a * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * it will be useful, but WITHOUT ANY WARRANTY; without even the implied * the Free Software Foundation. This program is distributed in the hope that * under the terms of the GNU General Public License Version 2 as published by * This program is free software; you can redistribute it and/or modify it * * Copyright (C) 2007 Matthew Johnson * * Pescetti Pseudo-Duplimate Generator/* ad*Z~va\ZY} } print.close(); } print.printStats(stats); double[] stats = getStats(boards, tricks); if (null != options.get("--stats")) {adiOyU#a, S '  f  4 _  } a C  ,'RD D(E7f1ni { public static boolean contains(byte[] hand, int card) } } System.exit(1); syntax(); System.err.println(_("Failed to save curtaincards: ")+e.getMessage()); if (Debug.debug) Debug.print(Debug.ERR, e); } catch (Exception e) { curtainprint.close(); } i = j; } curtainprint.printCurtainBack(j+1); for (j = i; j < i+6 && j < count; j++) { } curtainprint.printCurtains(j+1, boards[j]); for (j = i; j < i+6 && j < count; j++) { int j; while (i < count) { int i = 0; int count = boards.length; } System.exit(1); System.err.println(_("Invalid format ")+options.get("--format")); else { curtainprint = new PDFPrinter(curtainfile, options.get("--title")+" - "+_("Curtain Cards")); else if ("pdf".equals(options.get("--format"))) curtainprint = new HTMLPrinter(curtainfile, options.get("--title")+" - "+_("Curtain Cards")); else if ("html".equals(options.get("--format"))) curtainprint = new TextPrinter(curtainfile, options.get("--title")+" - "+_("Curtain Cards")); if ("txt".equals(options.get("--format"))) Printer curtainprint = null; PrintStream curtainfile = new PrintStream(new FileOutputStream((String) options.get("--curtains"))); try { { public static void curtains(HashMap/* */ options, byte[][][] boards) } } System.exit(1); syntax(); System.err.println(_("Failed to save permutations: ")+e.getMessage()); if (Debug.debug) Debug.print(Debug.ERR, e); } catch (Exception e) { permprint.close(); } } permprint.printPermutation(2, j+1, perms[j][2], null); for (int j = i; j < count; j++) permprint.printPermutation(1, j+1, perms[j][1], perms[j][0]); for (int j = i; j < count; j++) } else { permprint.printPermutation(2, i+2, perms[i+1][2], null); permprint.printPermutation(2, i+1, perms[i+0][2], null); permprint.printPermutation(1, i+4, perms[i+3][1], perms[i+3][0]); permprint.printPermutation(1, i+3, perms[i+2][1], perms[i+2][0]); permprint.printPermutation(2, i+4, perms[i+3][2], null); permprint.printPermutation(2, i+3, perms[i+2][2], null); permprint.printPermutation(1, i+2, perms[i+1][1], perms[i+1][0]); permprint.printPermutation(1, i+1, perms[i+0][1], perms[i+0][0]); if (i+3 < count) { for (int i = 0; i < count; i+=4) { // print them, interleaving perm1 with perm2 for a later board } perms[i][2] = getPermutation(intermediate, boards[i]); byte[][] intermediate = permute(initial, perms[i][1]); perms[i][1] = generatePermutation(true); byte[][] initial = generateInitialHand(perms[i][0]); perms[i][0] = generateInitialPermutation(); for (int i = 0; i < count; i++) { // generate them all byte[][][] perms = new byte[count][3][]; int count = boards.length; } System.exit(1); System.err.println(_("Invalid format ")+options.get("--format")); } else {ad ZV h =  L k  9 O  rBq!~QU9. VHwBzy { public static boolean contains(byte[] hand, int card) } } System.exit(1); syntax(); System.err.println(_("Failed to save curtaincards: ")+e.getMessage()); if (Debug.debug) Debug.print(Debug.ERR, e); } catch (Exception e) { curtainprint.close(); } i = j; } curtainprint.printCurtainBack(j+1); for (j = i; j < i+6 && j < count; j++) { } curtainprint.printCurtains(j+1, boards[j]); for (j = i; j < i+6 && j < count; j++) { int j; while (i < count) { int i = 0; int count = boards.length; } System.exit(1); System.err.println(_("Invalid format ")+options.get("--format")); else { curtainprint = new HTMLPrinter(curtainfile, options.get("--title")+" - Curtain Cards"); else if ("html".equals(options.get("--format"))) curtainprint = new TextPrinter(curtainfile, options.get("--title")+" - Curtain Cards"); if ("txt".equals(options.get("--format"))) Printer curtainprint = null; PrintStream curtainfile = new PrintStream(new FileOutputStream((String) options.get("--curtains"))); try { { public static void curtains(HashMap/* */ options, byte[][][] boards) } } System.exit(1); syntax(); System.err.println(_("Failed to save permutations: ")+e.getMessage()); if (Debug.debug) Debug.print(Debug.ERR, e); } catch (Exception e) { permprint.close(); } } permprint.printPermutation(2, j+1, perms[j][2], null); for (int j = i; j < count; j++) permprint.printPermutation(1, j+1, perms[j][1], perms[j][0]); for (int j = i; j < count; j++) } else { permprint.printPermutation(2, i+2, perms[i+1][2], null); permprint.printPermutation(2, i+1, perms[i+0][2], null); permprint.printPermutation(1, i+4, perms[i+3][1], perms[i+3][0]); permprint.printPermutation(1, i+3, perms[i+2][1], perms[i+2][0]); permprint.printPermutation(2, i+4, perms[i+3][2], null); permprint.printPermutation(2, i+3, perms[i+2][2], null); permprint.printPermutation(1, i+2, perms[i+1][1], perms[i+1][0]); permprint.printPermutation(1, i+1, perms[i+0][1], perms[i+0][0]); if (i+3 < count) { for (int i = 0; i < count; i+=4) { // print them, interleaving perm1 with perm2 for a later board } perms[i][2] = getPermutation(intermediate, boards[i]); byte[][] intermediate = permute(initial, perms[i][1]); perms[i][1] = generatePermutation(true); byte[][] initial = generateInitialHand(perms[i][0]); perms[i][0] = generateInitialPermutation(); for (int i = 0; i < count; i++) { // generate them all byte[][][] perms = new byte[count][3][]; permprint = new PDFPrinter(permfile, options.get("--title")+" - "+_("Permutations")); } else if ("pdf".equals(options.get("--format"))) { permprint = new HTMLPrinter(permfile, options.get("--title")+" - "+_("Permutations")); } else if ("html".equals(options.get("--format"))) { permprint = new TextPrinter(permfile, options.get("--title")+" - "+_("Permutations")); if ("txt".equals(options.get("--format"))) { Printer permprint = null; PrintStream permfile = new PrintStream(new FileOutputStream(file));ad' X9 yH // print stats if asked for } print.printTricks(tricks[i]); if (null != tricks) print.printPoints(points); points[WEST] = (byte) count(boards[i][WEST]); points[EAST] = (byte) count(boards[i][EAST]); points[SOUTH] = (byte) count(boards[i][SOUTH]); points[NORTH] = (byte) count(boards[i][NORTH]); print.printHand(i+1, boards[i]); for (int i = 0; i < boards.length; i++) { byte[] points = new byte[4]; // print boards and tricks if asked for } System.exit(1); System.err.println(_("Invalid format ")+options.get("--format")); else {ad`OskjFp<  L 6     n _  q $  w c : ! ycG<43~Uqb iMB&u-f6 uD&  // print stats if asked for } print.printTricks(tricks[i]); if (null != tricks) print.printPoints(points); points[WEST] = (byte) count(boards[i][WEST]); points[EAST] = (byte) count(boards[i][EAST]); points[SOUTH] = (byte) count(boards[i][SOUTH]); points[NORTH] = (byte) count(boards[i][NORTH]); print.printHand(i+1, boards[i]); for (int i = 0; i < boards.length; i++) { byte[] points = new byte[4]; // print boards and tricks if asked print = new PDFPrinter(out, (String) options.get("--title")); else if ("pdf".equals(options.get("--format"))) print = new HTMLPrinter(out, (String) options.get("--title")); else if ("html".equals(options.get("--format"))) print = new TextPrinter(out, (String) options.get("--title")); if ("txt".equals(options.get("--format"))) Printer print = null; } System.exit(1); System.err.println(_("Cannot open file for output: ")+e.getMessage()); if (Debug.debug) Debug.print(e); } catch (Exception e) { out = new PrintStream(new FileOutputStream((String) options.get("--output"))); try { if (null != options.get("--output")) PrintStream out = System.out; // redirect output if asked for } curtains(options, boards); if (null != options.get("--curtains") && null != boards) { // save curtain cards, if ased for } permutation_genandsave(options, boards); if (null != options.get("--permutations") && null != boards) { // generate permutations and save, if ased for } } System.exit(1); syntax(); System.err.println(_("Failed to save analysis: ")+e.getMessage()); if (Debug.debug) Debug.print(Debug.ERR, e); } catch (Exception e) { out.close(); exportanalysis(out, tricks); PrintStream out = new PrintStream(new FileOutputStream(file)); String file = (String) options.get("--save-analysis"); if (null == tricks) throw new Exception(_("You must specify --load, --load-analysis or --analyze to save the analysis")); try { if (null != options.get("--save-analysis")) { // export boards if asked for } } System.exit(1); syntax(); System.err.println(_("Failed to save boards: ")+e.getMessage()); if (Debug.debug) Debug.print(Debug.ERR, e); } catch (Exception e) { out.close(); combinedexport(out, boards, tricks); PrintStream out = new PrintStream(new FileOutputStream(file)); try { String file = (String) options.get("--save"); if (null != options.get("--save") && null != boards) { // export boards if asked for } } System.exit(1); syntax(); System.err.println(_("Failed to save boards: ")+e.getMessage()); if (Debug.debug) Debug.print(Debug.ERR, e); } catch (Exception e) { out.close(); ddsexport(out, boards[i], false); for (int i = 0; i < boards.length; i++) PrintStream out = new PrintStream(new FileOutputStream(file)); try { String file = (String) options.get("--save-dds"); if (null != options.get("--save-dds") && null != boards) { // export boards if asked for } tricks[i] = ddanalyse(boards[i]); for (int i = 0; i < boards.length; i++) tricks = new byte[boards.length][];ad~Qq9 w b ] Q r * gO6iaNIH&j]D/ nV)w[?#{_4z^B& if (read) { if (n < 0) n = c-'a'+10; case 'd': case 'c': case 'b': case 'a': if (n < 0) n = c-'A'+10; case 'D': case 'C': case 'B': case 'A': if (n < 0) n = c-'0'; case '9': case '8': case '7': case '6': case '5': case '4': case '3': case '2': case '1': case '0': case '=': suit++; offs=0; if (suit < 5) read = true; break; switch (c) { case READEW: case READNS: break; if (':' == c) state = READNS; case START: switch (state) { if (Debug.debug) Debug.print(Debug.DEBUG, ""+(char) c); while (0 < (c = in.read())) { boolean read = false; int n = -1; int offs = 0; int suit = -1; int state = START; int c; final int READEW = 3; final int READNS = 2; final int START = 1; byte[] out = new byte[20]; { public static byte[] parseDD(InputStream in) throws IOException @SuppressWarnings("fallthrough") } return null; } System.exit(1); System.err.println(_("Failed to DD analyze: ")+e.getMessage()); if (Debug.debug) Debug.print(Debug.ERR, e); } catch (Exception e) { return tricks; temp2.delete(); temp.delete(); byte[] tricks = parseDD(in); BufferedInputStream in = new BufferedInputStream(new FileInputStream(temp2)); p.waitFor(); p = Runtime.getRuntime().exec(new String[] { "/bin/sh", "-c", "/usr/games/dds -deal=2 -tricks "+temp.getCanonicalPath()+" | /usr/bin/tail -n2 >> " +temp2.getCanonicalPath()}); p.waitFor(); Process p = Runtime.getRuntime().exec(new String[] { "/bin/sh", "-c", "/usr/games/dds -deal=1 -tricks "+temp.getCanonicalPath()+" | /usr/bin/tail -n2 > " +temp2.getCanonicalPath() }); fos.close(); ddsexport(fos, hand, true); ddsexport(fos, hand, false); File temp2 = File.createTempFile("pescetti", ".tmp"); PrintStream fos = new PrintStream(new FileOutputStream(temp)); File temp = File.createTempFile("pescetti", ".tmp"); if (!exec.exists()) throw new Exception(_("Must install dds double dummy analyzer to analyze hands")); File exec = new File("/usr/games/dds"); try { { public static byte[] ddanalyse(byte[][] hand) } System.out.println(" Criteria: unbalanced weaknt strongnt twont strongtwo weaktwo three twoclubs 4441 singlesuit twosuits partscore game slam grand game-invite slam-invite jumpshift jumpfit splinter bacon weird"); System.out.println(" Formats: txt html pdf"); System.out.println(" Options: --help --generate=N --load= --load-dds= --load-analysis= --permutations= --demo --stats --analyze --save= --save-dds= --save-analysis= --format= --title= --output=<hands.txt> --curtains=<cutains.txt> --probability=<factor> --criteria=<criteria list>");� System.out.println("Syntax: pescetti [options]");� System.out.println("Pescetti Pseudo-Duplimate Generator - version "+version);� .getImplementationVersion();�ad����������i���������]��E��=��8������[��+�� �� �� �� ��q ��X ��* �� �� �� �� �� �� �� ��o ��D �� �� �� �� �� �� ��] ��> �� �� �� �� �� ��o ��& �� �� �� �� �� ��= ��8 ������t��d��8����������}��S��N��G����������'��!����������v��M��4�� ����������m��^��4������������m��U��M��H������������_��;��3��.��*���� ������������������ String version = Package.getPackage("cx.ath.matthew.pescetti")� {� static void syntax()� � }� }� if (s < 4) out.print('.');� out.print(CARD[hand[i++] & 0x0f]);� while (i < 13 && s == (hand[i] >> 4))� for (int s = 1, i = 0; s <= 4; s++) {� int suit = SPADES;� {� public static void ddsprinthand(PrintStream out, byte[] hand)� }� }� out.println();� ddsprinthand(out, hands[WEST]);� out.print(' ');� ddsprinthand(out, hands[SOUTH]);� out.print(' ');� ddsprinthand(out, hands[EAST]);� out.print(' ');� ddsprinthand(out, hands[NORTH]);� } else {� out.println();� ddsprinthand(out, hands[SOUTH]);� out.print(' ');� ddsprinthand(out, hands[EAST]);� out.print(' ');� ddsprinthand(out, hands[NORTH]);� out.print(' ');� ddsprinthand(out, hands[WEST]);� if (!rotate) {� for (int i = 0; i < 4; i++) Arrays.sort(hands[i]);� {� public static void ddsexport(PrintStream out, byte[][] hands, boolean rotate)� */� *� * dds only solves for N-S, so we have to output two lines, one of them rotated for E-W (rotation printed if rotate is true)� *� * A64.8732.543.Q98 T8.96.AKT.A76432 Q2.AQJT54.Q82.JT KJ9753.K.J976.K5� * W N E S = 3 0 1 2� * Export to format used by dds double dummy solver.� /**� }� tricks.toArray(new byte[0][]) };� return new Object[] { hands.toArray(new byte[0][][]),� }� tricks.add(analysisparse(ss[1]));� hands.add(ddsinparse(ss[0]));� String[] ss = s.split(":");� while (null != (s = br.readLine())) {� String s;� BufferedReader br = new BufferedReader(new InputStreamReader(in));� Vector/*<byte[]>*/ tricks = new Vector/*<byte[]>*/();� Vector/*<byte[][]>*/ hands = new Vector/*<byte[][]>*/();� {� public static Object[] combinedimport(InputStream in) throws IOException� }� return (byte[][]) tricks.toArray(new byte[0][]);� tricks.add(analysisparse(s));� while (null != (s = br.readLine()))� String s;� BufferedReader br = new BufferedReader(new InputStreamReader(in));� Vector/*<byte[]>*/ tricks = new Vector/*<byte[]>*/();� {� public static byte[][] importanalysis(InputStream in) throws IOException� }� }� if ((i+1) != tricks.length) out.print(',');� out.print(tricks[i]);� for (int i = 0; i < tricks.length; i++) {� {� public static void printtricks(PrintStream out, byte[] tricks)� }� return tricks;� tricks[i] = Byte.parseByte(ss[i]);� for (int i = 0; i < ss.length; i++)� byte[] tricks = new byte[ss.length];� String[] ss = s.split(",");� {� public static byte[] analysisparse(String s)� }� }� out.println();� printtricks(out, tricks[i]);� out.print(':');� ddsprinthand(out, boards[i][SOUTH]);� out.print(' ');� ddsprinthand(out, boards[i][EAST]);� out.print(' ');� ddsprinthand(out, boards[i][NORTH]);� out.print(' ');� ddsprinthand(out, boards[i][WEST]);� for (int i = 0; i < boards.length; i++) {� if (null == tricks) throw new Exception(_("Must --load, --load-analysis or --analyze to use --save"));� {� public static void combinedexport(PrintStream out, byte[][][] boards, byte[][] tricks) throws Exception� }� }� out.println();� printtricks(out, tricks[i]);� for (int i = 0; i < tricks.length; i++) {� {� public static void exportanalysis(PrintStream out, byte[][] tricks) �ad����� �����x�����������W��A��(������������u��M��7��,�������� �� �� �� �� ��{ ��W ��% �� �� �� �� �� �� ��M ��H ��% �� �� �� �� �� �� �� ��G ��@ �� �� �� �� ��p ��@ ��- ��( ��' �� �� �� �� ��} ��4 ��/ ��������m��J���� �� ����������o��`��1����������j��&����������p��Z��D��.��������������m��W��A�� ����������~��G��1������������n��Y��N��+��#���� �� �� ��������������������� }� return hand;� }� i++; // next card in hand� }� default:� break;� hand[p][i] = (byte) (ACE + (s << 4));� case 'A':� break;� hand[p][i] = (byte) (KING + (s << 4));� case 'K':� break;� hand[p][i] = (byte) (QUEEN + (s << 4));� case 'Q':� break;� hand[p][i] = (byte) (JACK + (s << 4));� case 'J':� break;� hand[p][i] = (byte) (TEN + (s << 4));� case 'T':� break;� hand[p][i] = (byte) (c - '1' + 1 + (s << 4));� case '9':� case '8':� case '7':� case '6':� case '5':� case '4':� case '3':� case '2':� break;� i=-1; // start cards in hand again� s=1; // start suits again� p = (p + 1) % 4; // next player� case ' ':� break;� i--; // oops, didn't actually want to increment this� s++; // next suit� case '.':� switch (c) {� if (Debug.debug) Debug.print(Debug.DEBUG, "Read c="+c+" s="+s+" p="+p+" i="+i);� char c = str.charAt(j);� for (int j = 0; j < str.length(); j++) {� int i=0;� int p=3; // start at west� int s=1;� byte[][] hand = new byte[4][13]; //start afresh� {� public static byte[][] ddsinparse(String str)�� }� return (byte[][][]) hands.toArray(new byte[0][][]);� hands.add(ddsinparse(s));� while (null != (s = br.readLine()))� String s;� BufferedReader br = new BufferedReader(new InputStreamReader(in));� Vector/*<byte[][]>*/ hands = new Vector/*<byte[][]>*/();� {� public static byte[][][] ddsimport(InputStream in) throws IOException� */� * A64.8732.543.Q98 T8.96.AKT.A76432 Q2.AQJT54.Q82.JT KJ9753.K.J976.K5� * W N E S = 3 0 1 2� * import from format used by dds double dummy solver.� /**�� }� return perm;� perm[k] = find(hand2, hand1[i][j]);� for (int j = 0; j < hand1[i].length; j++, k++) � for (int i = 0, k = 0; i < 4; i++)� byte[] perm = new byte[52];� {� public static byte[] getPermutation(byte[][] hand1, byte[][] hand2)� */� * Takes 2 hands and returns the permutation between them.� /**�� }� return 0; // never happens� return i;� if (hands[i][j] == card)� for (int j = 0; j < hands[i].length; j++) � for (byte i = 0; i < 4; i++)� {� public static byte find(byte[][] hands, byte card)�� }� return newhands;� }� newhands[i][k] = hands[i][j];� for (int j = 0, k = (hands[i].length - 1); j < hands[i].length; j++, k--)� newhands[i] = new byte[hands[i].length];� for (int i = 0; i < 4; i++) {� byte[][] newhands = new byte[4][];� {� public static byte[][] reverse(byte[][] hands)� */� * Reverses the contents of each hand� /** �� }� return hand;� }� break;� hand[i] = INITIAL_CLUBS;� case CLUBS:� break;� hand[i] = INITIAL_DIAMONDS;� case DIAMONDS:� break;� hand[i] = INITIAL_HEARTS;� case HEARTS:� break;� hand[i] = INITIAL_SPADES;� case SPADES:� switch (initperm[i]) {� for (int i = 0; i < 4; i++)� byte[][] hand = new byte[4][];�ad����������j�������_��&��������f��?���� �� �� �� �� ��l ��R ��8 �� �� ��q ��? ��$ �� �� �� �� �� ��u ��[ ��1 �� �� �� �� �� ��w ��T ��8 �� �� �� �� �� �� ��q ��U ��; �� ����������q��`��R��������[��3��������P��E��=��<��'��������s��r��^��Y��7���� ��������h��R��3��������������k��f��e��0��+��������v��S�� �� ������������ {� public static byte[][] generateInitialHand(byte[] initperm)� }� return initperm;� swap(initperm, i, Math.abs(rand[i]) % 4);� for (byte i = 0; i < 4; i++)� sr.nextBytes(rand);� byte[] rand = new byte[4];� byte[] initperm = new byte[] { SPADES, HEARTS, DIAMONDS, CLUBS };� // returns a permutation of the four suits.� {� public static byte[] generateInitialPermutation()�� }� return total;� if (Debug.debug) Debug.print(Debug.DEBUG,"total="+total);� }� }� case JACK: total++;� case QUEEN: total++;� case KING: total++;� case ACE: total++;� switch (b) {� if (Debug.debug) Debug.print(Debug.VERBOSE,"a = "+a+" b = "+b+" / "+CARD[b]);� int b = a & 0x0f;� for (byte a: hand) {� int total = 0;� {� public static int count(byte[] hand)� @SuppressWarnings("fallthrough")� }� return stats;�� stats[STAT_WPOINTS] /= boards.length;� stats[STAT_EPOINTS] /= boards.length;� stats[STAT_SPOINTS] /= boards.length;� stats[STAT_NPOINTS] /= boards.length;� // get average�� }� }� if (Debug.debug) Debug.print(Debug.DEBUG, "stat_4441:"+stats[STAT_4441] );� if (four == 3) stats[STAT_4441]++;� if (five == 2) stats[STAT_55]++;� if (semibal) stats[STAT_SEMIBAL]++;� if (bal) stats[STAT_BAL]++;� if (flat) stats[STAT_4333]++;� if (xton > 2) semibal = false;� if (xton > 1) bal = false;� if (Debug.debug) Debug.print(Debug.DEBUG, "board "+i+" player "+p+" xton= "+xton+" four="+four+" five="+five);� }� }� break;� flat = false;� semibal = false;� bal = false;� case 1:� stats[STAT_VOID]++;� case 0:� break;� flat = false;� xton++;� case 2:� break;� case 3:� four++;� case 4:� break;� flat = false;� five++;� case 5:� break;� flat = false;� stats[STAT_6PLUS]++;� case 6:� stats[STAT_7PLUS]++;� case 7:� stats[STAT_8PLUS]++;� case 8:� case 9:� case 10:� case 11:� case 12:� case 13:� switch (length(boards[i][p], s)) {� if (Debug.debug) Debug.print(Debug.VERBOSE, "board "+i+" player "+p+" suit "+s+" length="+length(boards[i][p], s));� for (int s = 0; s < 4; s++) {� int four = 0;� int five = 0;� int xton = 0;� boolean semibal = true;� boolean bal = true;� boolean flat = true;� for (int p = 0; p < 4; p++) {�� stats[STAT_BACON]++;� bacon(boards[i][EAST]))� bacon(boards[i][WEST]) ||� bacon(boards[i][SOUTH]) ||� if (bacon(boards[i][NORTH]) ||� stats[STAT_WPOINTS] += count(boards[i][WEST]);� stats[STAT_EPOINTS] += count(boards[i][EAST]);� stats[STAT_SPOINTS] += count(boards[i][SOUTH]);� stats[STAT_NPOINTS] += count(boards[i][NORTH]);� }� if (!ewslam && tricks[i][j] >= 12) { ewslam=true; stats[STAT_EWSLAMS]++; }�ad��?��������a�������I��"��������l��g��M��3���� �� �� �� ��b ��* �� �� �� �� �� �� ��| ��{ ��M �� �� �� �� �� ��w ��o ��U ��1 �� �� �� �� �� �� ��F ��A �� �� �� ��s ��< ��; �� ��������K��C��B��"������������z��G������������n��O��0����������r��J��#��������P��(����������\��3�� ������\������������������������������������������������������������������� for (int j = 10; j < 20; j++) � if (!nsslam && tricks[i][j] >= 12) { nsslam=true; stats[STAT_NSSLAMS]++; }� for (int j = 0; j < 10; j++)� tricks[i][15+4] >= 11) if (!ewgame) { ewgame=true; stats[STAT_EWGAMES]++; }� tricks[i][15+3] >= 11 ||� tricks[i][15+2] >= 10 ||� tricks[i][15+1] >= 10 ||� tricks[i][15+0] >= 9 ||� tricks[i][10+4] >= 11 ||� tricks[i][10+3] >= 11 ||� tricks[i][10+2] >= 10 ||� tricks[i][10+1] >= 10 ||� if (tricks[i][10+0] >= 9 ||� tricks[i][5+4] >= 11) if (!nsgame) { nsgame=true; stats[STAT_NSGAMES]++; }� tricks[i][5+3] >= 11 ||� tricks[i][5+2] >= 10 ||� tricks[i][5+1] >= 10 ||� tricks[i][5+0] >= 9 ||� tricks[i][0+4] >= 11 ||� tricks[i][0+3] >= 11 ||� tricks[i][0+2] >= 10 ||� tricks[i][0+1] >= 10 ||� if (tricks[i][0+0] >= 9 ||� if (null != tricks) {� boolean nsgame=false;� boolean nsslam=false;� boolean ewgame=false;� boolean ewslam=false;� for (int i = 0; i < boards.length; i++) {� � double[] stats = new double[STAT_MAX];� // 4333%, bal%, 6+ count, 7+ count, 8+ count }� // N points, E points, S points, W points,� // { NS games, EW games, NS slams, EW slams, � {� public static double[] getStats(byte[][][] boards, byte[][] tricks)� @SuppressWarnings("fallthrough")�� }� return reverse(newhands);�� }� newhands[i][j] = (Byte) newhandv[i].get(j);� for (int j = 0; j < newhands[i].length; j++)� newhands[i] = new byte[newhandv[i].size()];� for (int i = 0; i < 4; i++) {� byte[][] newhands = new byte[4][];�� newhandv[permutation[k]].add(hands[i][j]);� for (int j = 0; j < hands[i].length; j++, k++) � for (int i = 0, k = 0; i < 4; i++)� new Vector(), new Vector() };� Vector[] newhandv = new Vector[] { new Vector(), new Vector(),� {� public static byte[][] permute(byte[][] hands, byte[] permutation)� */� * Takes a set of hands and a permutation and generates the permuted hands.� /**� }� return perm;� swap(perm, k, Math.abs(rand[k]) % 52);� for (byte k = 0; k < 52; k++)� sr.nextBytes(rand);� }� perm[k] = i;� for (byte j = 0; j < 13; j++, k++) � for (byte i = 0, k = 0; i < 4; i++)� } else {� perm[k] = i;� for (byte j = 0; j < d[i]; j++, k++) � for (byte i = 0, k = 0; i < 4; i++) �� }� d[3] = 26-d[0];� d[2] = 26-d[1];� } else {� d[3] = 26-d[1];� d[2] = 26-d[0];� if (sr.nextBoolean()) {� d[1] = MIN + (Math.abs(sr.nextInt()) % RANGE);� d[0] = MIN + (Math.abs(sr.nextInt()) % RANGE);� int[] d = new int[4];� if (random) { � byte[] rand = new byte[52];� byte[] perm = new byte[52];� final int RANGE = MAX-MIN;� final int MIN = 10;� final int MAX = 16;� {� public static byte[] generatePermutation(boolean random)� */� * to having between 10 and 16 of each number� * the parameter changes the mode from have 13 of each number � * chosen item in the list 0....51.� * for each item in the list 0....51 swap it with a randomly� * Start with 11111.....22222....33333...444444..., then� * Generates a random permutaion using Knuth's Shuffle.�ad��$���D������������b��a��7������������g��W��C��1��&��������� �� �� �� �� �� �� ��~ ��U ��4 �� �� �� �� �� �� ��m ��] ��I ��7 ��, ��$ �� �� ��I ��H �� �� �� �� �� ��t ��` ��N ��C �� �� �� �� �� �� �� ��v ��u ��_ ��Z ��Y ��R �� �� ��������3��2��������m��l��R��5��4����������s��c��Q��'����������������w��v��u������������������w��S��"������������|��l��A��0��������������h��g��Q��L��K��D��C���������������������������������� /**�� }� return newdeck;�� if (Debug.debug) Debug.print(Debug.DEBUG, "New deck: "+formatDeck(newdeck));�� }� }� j1 = 0;� i1 = perm1[1][o]-1;� if (o >= perm1[1].length) break;� o++;� // select the next random pile� else {� if (j1 < (intermediate[i1].length-1)) j1++;� }� j2 = 0;� i2++;� else {� if (j2 < (newdeck[i2].length-1)) j2++;� newdeck[i2][j2] = intermediate[i1][j1];� while (i2 < newdeck.length) {� // copy back from ten piles in random order�� i1 = perm1[1][o]-1;� j1 = i2 = j2 = 0;� int o = 0;�� byte[][] newdeck = new byte[4][13];�� if (Debug.debug) Debug.print(Debug.DEBUG, "Intermediate: "+formatDeck(intermediate));��� }� }� j1 = 0;� i1++;� else {� if (j1 < (deck[i1].length-1)) j1++;� }� j2 = intermediate[i2].length-1;� if (i2 < intermediate.length)� i2++;� else {� if (j2 > 0) j2--;� intermediate[i2][j2] = deck[i1][j1];� while (i1 < deck.length) {� j2 = intermediate[i2].length-1;� // copy into 10 piles, inverting as you do�� i1 = j1 = i2 = j2 = 0;� int i1, j1, i2, j2;�� intermediate[i] = new byte[perm1[0][i]];� for (int i = 0; i < intermediate.length; i++)� byte[][] intermediate = new byte[perm1[0].length][];� // get the sizes of the piles�� if (Debug.debug) Debug.print(Debug.DEBUG, "perm: "+formatDeck(perm1));� if (Debug.debug) Debug.print(Debug.DEBUG, "deck: "+formatDeck(deck));� {� public static byte[][] permute1(byte[][] deck, byte[][] perm1)� */� * Returns a deck permuted with a perm1 permutation.� /**�� }� return newdeck;�� if (Debug.debug) Debug.print(Debug.DEBUG, "New deck: "+formatDeck(newdeck));�� }� }� i2++;� j2 = 0;� else {� if (j2 < (newdeck[i2].length-1)) j2++;� }� i1++;� j1 = 0;� else {� if (j1 < (deck[i1].length-1)) j1++;� newdeck[i2][j2] = deck[i1][j1];� while (i1 < i3 || (i1 == i3 && j1 <= j3)) {� i1 = j1 = 0;� // copy 0=>c to c=>end in new deck�� if (Debug.debug) Debug.print(Debug.DEBUG, "Intermediate deck: "+formatDeck(newdeck));� if (Debug.debug) Debug.print(Debug.VERBOSE, "Got i1="+i1+", j1="+j1+", i2="+i2+", j2="+j2+", i3="+i3+", j3="+j3);� � }� }� i2++;� j2 = 0;� else {� if (j2 < (newdeck[i2].length-1)) j2++;� }� i1++;� j1 = 0;� else {� if (j1 < (deck[i1].length-1)) j1++;� newdeck[i2][j2] = deck[i1][j1];� while (i1 < deck.length) {� // copy c=>end to 0=>c in new deck�� }� i1++;� j1 = 0;� else {� if (j1 < (deck[i1].length-1)) j1++;� // actually we want c last�� j3 = j1;� i3 = i1;� }� }� i1++;� j1 = 0;� else {� if (j1 < (deck[i1].length-1)) j1++;� while (i1 < deck.length && deck[i1][j1] != cutpoint) {� // find the cut point�� i1 = j1 = i2 = j2 = i3 = j3 = 0;� int i1, j1, i2, j2, i3, j3;� byte[][] newdeck = new byte[4][13];�� if (Debug.debug) Debug.print(Debug.DEBUG, "Cut point: "+cutpoint);� if (Debug.debug) Debug.print(Debug.DEBUG, "Old deck: "+formatDeck(deck));� {�ad����������Z���y��?��������W��"�� �� ��t ��5 �� �� �� �� ��u ��Y ��= �� �� �� �� �� �� ��j ��= ��& �� �� �� �� �� �� �� ��n �� �� �� ��g ��7 �� ��������}��>��������T��S��/��������;������g��8��1����������������;��6��������u��T��(������������c��X��P��K��J����������������������������������� try {� String file = (String) options.get("--permutations");� {� public static void permutation_genandsave(HashMap/* <String,String> */ options, byte[][][] boards)�� }� }� }� System.exit(1);� syntax();� System.out.println(_("Error: unknown option ")+opt[0]);� } else {� options.put(opt[0], opt[1]);� else� options.put(opt[0], "true");� if (opt.length == 1)� if (options.containsKey(opt[0])) {� if (Debug.debug) Debug.print(Arrays.asList(opt));� String[] opt = args[i].split("=");� for (int i = 0; i < args.length; i++) {� {� public static void parseopts(HashMap/* <String,String> */ options, String[] args)�� }� System.exit(0);� print.close();� print.printTricks(tricks);� print.println("It says: ");� byte[] tricks = ddanalyse(resulthand);� � ddsexport(System.out, resulthand, true);� ddsexport(System.out, resulthand, false);� print.println("These can go into a file to be run with dds -deal=1 -tricks file.txt and dds -deal=2 -tricks file.txt");� print.printHand(1, resulthand);� print.println("You should now have these hands hand 1 = north, hand 2 = east, hand 3 = south, hand 4 = west");� print.printPermutation(2, 1, perm2, null);� print.println("Second Deal:");� print.printPermutation1(1, perm1);� print.println("First Deal:");�� byte[] perm2 = getPermutation(intermediatehand, resulthand);� byte[][] intermediatehand = permute1(inithand, perm1);� byte[][] perm1 = generatePermutation1();� byte[][] inithand = cutDeck(INITIAL_HAND, cutpoint);� byte[][] resulthand = permute(INITIAL_HAND, targetperm);� byte[] targetperm = generatePermutation(false);�� print.println(" is at the bottom.");� print.print(""+SUIT[cutpoint >> 4]);� print.print(""+CARD[cutpoint & 0x0f]);� print.print("Cut the deck so that the ");� int cutpoint = getCutPoint();�� print.println("Stack the suits in the order Spades, Hearts, Diamonds, Clubs, so the first suit is spades.");� print.println("Sort decending within each suit, A K .... 3 2 (so that the first card delt is the Ace)");� Printer print = new TextPrinter(System.out, "Pescetti PseudoDuplimate - Demo mode");� {� public static void demo()� }� return out;� }� }� }� ;� // skip everything else� default:� break;� suit=-1;� state=READEW;� case ':':� break;� read = false;� case ' ':� break;� offs++;� n = -1;� }� out[15 + suit] = (byte) n;� // west gets n tricks in suit� else if (READEW == state && 3 == offs)� out[10 + suit] = (byte) n;� // east gets n tricks in suit� else if (READEW == state && 1 == offs)� out[5 + suit] = (byte) n;� // south gets n tricks in suit� else if (READNS == state && 3 == offs)� out[0 + suit] = (byte) n;� // north gets n tricks in suit� if (READNS == state && 1 == offs)� if (Debug.debug) Debug.print(Debug.DEBUG, "state="+state+" c="+((char)c)+" n="+n+" offs="+offs+" suit="+suit);�ad����������X���������J��8��������+���� �� �� �� ��F �� ��y ��R ��- �� �� ��f ��2 �� �� ��{ ��H ��. �� �� �� ��E ��3 ��% �� ������i��Z��������n��V��5��������~��s��r��<��-��������a��)����������m��l��[��Z��K��������������y����������k��������������������������������������� if (null != options.get("--analyze")) {� // analyze if asked for�� }�� }� System.exit(1);� syntax();� System.err.println(_("Failed to load analysis: ")+e.getMessage());� if (Debug.debug) Debug.print(Debug.ERR, e);� } catch (Exception e) {� in.close();� tricks = importanalysis(in);� InputStream in = new BufferedInputStream(new FileInputStream((String) options.get("--load-analysis")));� try {� if (null != options.get("--load-analysis")) {�� }� System.exit(1);� syntax();� System.out.println(_("Must specify either --generate --load{,-dds} or --demo"));� } else {�� demo();�� } else if (null != options.get("--demo")) {� }� System.exit(1);� syntax();� System.err.println(_("Failed to load boards: ")+e.getMessage());� if (Debug.debug) Debug.print(Debug.ERR, e);� } catch (Exception e) {� in.close();� boards = ddsimport(in);� InputStream in = new BufferedInputStream(new FileInputStream((String) options.get("--load-dds")));� try {� } else if (null != options.get("--load-dds")) {�� }� System.exit(1);� syntax();� System.err.println(_("Failed to load boards: ")+e.getMessage());� if (Debug.debug) Debug.print(Debug.ERR, e);� } catch (Exception e) {� in.close();� tricks = (byte[][]) tmp[1];� boards = (byte[][][]) tmp[0];� Object[] tmp = combinedimport(in);� InputStream in = new BufferedInputStream(new FileInputStream((String) options.get("--load")));� try {� } else if (null != options.get("--load")) {� boards[i] = permute(INITIAL_HAND, generatePermutation(false));� for (int i = 0; i < count; i++)� } else� }� } � if (Debug.debug) Debug.print(Debug.INFO, "Board "+i+" matches criteria");� } else� continue;� maxattempts--; // don't try forever to create matching hands� i--;� if (!match && maxattempts > 0) {� boolean match = bc.check(boards[i]);� }� Debug.print(Debug.VERBOSE, "hand "+p+" suit "+s+" is "+length(boards[i][p], s));� for (int s = 0; s < 4; s++)� for (int p = 0; p < 4; p++)� Debug.print(Debug.VERBOSE, "hand "+j+" has "+count(boards[i][j])+" points");� for (int j = 0; j < 4; j++)� if (Debug.debug) {� if (cw < probability) {� if (Debug.debug) Debug.print(Debug.DEBUG, "board "+i+" probability factor "+probability+" current number "+cw);� boards[i] = permute(INITIAL_HAND, generatePermutation(false));� double cw = ((double) r.nextInt(1073741824)) / 1073741824.0;� for (int i = 0; i < count; i++) {� Random r = new Random();� }� System.exit(1);� syntax();� System.err.println(_("Failed to parse probability: ")+e.getMessage());� if (Debug.debug) Debug.print(Debug.ERR, e);� } catch (Exception e) {� probability = Double.parseDouble((String) options.get("--probability"));� try {� if (null != options.get("--probability"))� int maxattempts = 100000;� double probability = 1.0;� BoardChecker bc = new BoardChecker(cs);�ad��6��������t�����s��H��@��,��'��&��%����������������i��;��)��$��#�� �� �� �� ��y ��x ��c ��? �� �� �� �� �� ��n ��+ �� �� �� �� �� �� �� ��g ��T ��4 ��) �� �� �� �� �� �� �� �� �� ��| ��R ��C ��' �� �� �� �� �� ��I ��& ����������^��;����������y��U��/��������~��^��]��=��������������l��T��E��������>��(�� �������������u��c��������a��H��)����������������������������������������������������������� }� System.exit(1);� syntax();� System.err.println(_("Failed to parse criteria: ")+e.getMessage());� if (Debug.debug) Debug.print(Debug.ERR, e);� } catch (Exception e) {� cs = Criteria.parseCriteria((String) options.get("--criteria"));� try {� HashMap<Criteria, Double> cs = null;� if (null != options.get("--criteria")) {�� boards = new byte[count][][];�� }� System.exit(1);� syntax();� System.err.println(_("Failed to parse number of boards to generate: ")+e.getMessage());� if (Debug.debug) Debug.print(Debug.ERR, e);� } catch (Exception e) {� count = Integer.parseInt((String) options.get("--generate"));� try {� int count = 0;� } else if (null != options.get("--generate")) {� System.exit(0);� syntax();� if (null != options.get("--help")) {� // get boards somehow, or demo�� byte[][] tricks = null;� byte[][][] boards = null;�� parseopts(options, args);� options.put("--title", "Pescetti PseudoDuplimate");� options.put("--format", "txt");� options.put("--criteria", null);� options.put("--probability", null);� options.put("--analyze", null);� options.put("--stats", null);� options.put("--curtains", null);� options.put("--output", null);� options.put("--save-analysis", null);� options.put("--save-dds", null);� options.put("--save", null);� options.put("--demo", null);� options.put("--permutations", null);� options.put("--load-analysis", null);� options.put("--load-dds", null);� options.put("--load", null);� options.put("--generate", null);� options.put("--help", null);� HashMap/* <String,String> */ options = new HashMap/* <String,String> */();� // read options� }� Debug.setThrowableTraces(true);� } catch (Exception e) {}� Debug.loadConfig(f);� if (f.exists())� try {� File f = new File("debug.conf");� if (Debug.debug) {� {� public static void main(String[] args)� @SuppressWarnings("unchecked")�� }� return false;�� }� if (l == 5) return true;� }� s = hand[i] & 0xf0;� l = 0;� if ((hand[i] & 0xf0) != s) {� }� c = hand[i] & 0x0f;� l = 0;� } else {� c++;� l++;� if ((hand[i] & 0x0f) == (c+1)) {� for (int i = 0, s = 0, c = 0, l = 0; i < hand.length; i++) {� // straight flush�� contains(hand, SPADES | i)) return true;� contains(hand, HEARTS | i) &&� contains(hand, DIAMONDS | i) &&� if (contains(hand, CLUBS | i) &&� for (int i = 2; i < ACE; i++)� // 4 of a kind�� contains(hand, DIAMONDS | 7)) return true;� if (1 == length(hand, DIAMONDS) && � // singleton beer� {� public static boolean bacon(byte[] hand)�� }� return len;� if ((hand[i] & 0xf0) == suit) len++;� for (int i = 0; i < hand.length; i++)� }� suit <<= 4;� suit++;� if (suit < 10) {� int len = 0;� {� public static int length(byte[] hand, int suit)��� }� return false;� }� if (hand[i] == card) return true;� if (Debug.debug) Debug.print(Debug.VERBOSE, "hand["+i+"]: "+hand[i]+", card: "+card);� for (int i = 0; i < hand.length; i++) {�pescetti-0.5/cx/ath/matthew/pescetti/Printer.java���������������������������������������������������0000644�0001750�0001750�00000006440�11300010173�020601� 0����������������������������������������������������������������������������������������������������ustar �mjj29���������������������������mjj29������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * Pescetti Pseudo-Duplimate Generator * * Copyright (C) 2007 Matthew Johnson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License Version 2 as published by * the Free Software Foundation. This program is distributed in the hope that * it will be useful, but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. You should have received a * copy of the GNU General Public License along with this program; if not, * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * To Contact me, please email src@matthew.ath.cx * */ package cx.ath.matthew.pescetti; import java.util.Arrays; import cx.ath.matthew.debug.Debug; public abstract class Printer implements Constants { public void doPlayerPrintable(String[] out, int j /* offs */, byte[] hand, char[] suits) { Arrays.sort(hand); byte lastsuit = SPADES >> 4; int k = j; for (int i = 0; i < hand.length ; ) { while (i < hand.length && lastsuit == (hand[i] >> 4)) { if (Debug.debug) Debug.print(Debug.DEBUG, j+" "+(hand[i] & 0x0f)); out[j] = CARD[hand[i] & 0x0f] + (null==out[j]?"":out[j]); i++; } if (i < hand.length) { j += (hand[i] >> 4) - lastsuit; lastsuit = (byte) (hand[i] >> 4); } } for (int i = k; i < k+4; i++) out[i] = suits[i-k+1]+" "+(null==out[i]?"":out[i]); } /** * Returns a 16 element array of North Spades, North Hearts, ... West Spades, ... East, ... South Spades, ... South Clubs. */ public String[] getHandPrintables(byte[][] hand) { return getHandPrintables(hand, SUIT); } public String[] getHandPrintables(byte[][] hand, char[] suits) { String[] out = new String[16]; doPlayerPrintable(out, 0, hand[NORTH], suits); doPlayerPrintable(out, 4, hand[WEST], suits); doPlayerPrintable(out, 8, hand[EAST], suits); doPlayerPrintable(out, 12, hand[SOUTH], suits); return out; } @SuppressWarnings("fallthrough") public static int count(byte[] hand) { int total = 0; for (byte a: hand) { int b = a & 0x0f; if (Debug.debug) Debug.print(Debug.DEBUG,"a = "+a+" b = "+b+" / "+CARD[b]); switch (b) { case ACE: total++; case KING: total++; case QUEEN: total++; case JACK: total++; } if (Debug.debug) Debug.print(Debug.DEBUG,"total="+total); } return total; } public abstract void printHand(int num, byte[][] hand); public abstract void printCurtains(int num, byte[][] hand); public abstract void printCurtainBack(int num); public abstract void printPermutation(int permnum, int boardnum, byte[] perm, byte[] initperm); public abstract void printPermutation1(int boardnum, byte[][] perm); public abstract void close(); public abstract void printTricks(byte[] tricks); public abstract void printPoints(byte[] points); public abstract void printStats(double[] stats); public abstract void println(String s); public abstract void print(String s); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������pescetti-0.5/cx/ath/matthew/pescetti/pescetti.java��������������������������������������������������0000644�0001750�0001750�00000126242�11300014605�021005� 0����������������������������������������������������������������������������������������������������ustar �mjj29���������������������������mjj29������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * Pescetti Pseudo-Duplimate Generator * * Copyright (C) 2007 Matthew Johnson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License Version 2 as published by * the Free Software Foundation. This program is distributed in the hope that * it will be useful, but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. You should have received a * copy of the GNU General Public License along with this program; if not, * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * To Contact me, please email src@matthew.ath.cx * */ package cx.ath.matthew.pescetti; import cx.ath.matthew.debug.Debug; import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import java.io.PrintStream; import java.security.SecureRandom; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Random; import java.util.Vector; import static cx.ath.matthew.pescetti.Gettext._; public class pescetti implements Constants { private static SecureRandom sr = new SecureRandom(); public static void swap(byte[] perm, int a, int b) { byte t = perm[a]; perm[a] = perm[b]; perm[b] = t; } public static String formatDeck(byte[][] deck) { StringBuffer b = new StringBuffer(); if (Debug.debug) { for (int i = 0; i < deck.length; i++) for (int j = 0; j < deck[i].length; j++) { b.append(CARD[deck[i][j] & 0x0f]); b.append(SUIT[deck[i][j] >> 4]); b.append(' '); } return b.toString(); } else { return ""; } } /** * Generates a part 1 permutation. * Result is 10 random numbers between 3 and 8 which sum to 52. */ public static byte[][] generatePermutation1() { // number in each pile byte[] res = new byte[10]; int rem = 52; for (int i = 0; i < 10; i++) { int top = Math.min(8, rem - 3*(10-(i+1))); int bottom = Math.max(3, rem - 8*(10-(i+1))); int range = top - bottom + 1; int rand = sr.nextInt() % range; if (rand < 0) rand = -rand; res[i] = (byte) (bottom + rand); rem -= res[i]; } if (Debug.debug) Debug.print(Debug.DEBUG, "First perm: "+Arrays.toString(res)); // pickup order byte[] res2 = new byte[10]; for (byte i = 0; i < 10; i++) res2[i] = (byte) (i+1); // knuth shuffle byte[] rand = new byte[10]; sr.nextBytes(rand); for (byte k = 0; k < 10; k++) swap(res2, k, Math.abs(rand[k]) % 10); if (Debug.debug) Debug.print(Debug.DEBUG, "Pickup: "+Arrays.toString(res2)); return new byte[][] { res, res2 }; } /** * Generates a random card to cut to. */ public static int getCutPoint() { int s = sr.nextInt() % 4; int c = sr.nextInt() % KING; if (s < 0) s = -s; if (c < 0) c = -c; s += 1; c += 2; if (Debug.debug) Debug.print(Debug.DEBUG, "Cut point: suit="+s+", card="+c); return (s << 4) | c; } /** * Returns a deck cut to the given position. */ public static byte[][] cutDeck(byte[][] deck, int cutpoint) { if (Debug.debug) Debug.print(Debug.DEBUG, "Old deck: "+formatDeck(deck)); if (Debug.debug) Debug.print(Debug.DEBUG, "Cut point: "+cutpoint); byte[][] newdeck = new byte[4][13]; int i1, j1, i2, j2, i3, j3; i1 = j1 = i2 = j2 = i3 = j3 = 0; // find the cut point while (i1 < deck.length && deck[i1][j1] != cutpoint) { if (j1 < (deck[i1].length-1)) j1++; else { j1 = 0; i1++; } } i3 = i1; j3 = j1; // actually we want c last if (j1 < (deck[i1].length-1)) j1++; else { j1 = 0; i1++; } // copy c=>end to 0=>c in new deck while (i1 < deck.length) { newdeck[i2][j2] = deck[i1][j1]; if (j1 < (deck[i1].length-1)) j1++; else { j1 = 0; i1++; } if (j2 < (newdeck[i2].length-1)) j2++; else { j2 = 0; i2++; } } if (Debug.debug) Debug.print(Debug.VERBOSE, "Got i1="+i1+", j1="+j1+", i2="+i2+", j2="+j2+", i3="+i3+", j3="+j3); if (Debug.debug) Debug.print(Debug.DEBUG, "Intermediate deck: "+formatDeck(newdeck)); // copy 0=>c to c=>end in new deck i1 = j1 = 0; while (i1 < i3 || (i1 == i3 && j1 <= j3)) { newdeck[i2][j2] = deck[i1][j1]; if (j1 < (deck[i1].length-1)) j1++; else { j1 = 0; i1++; } if (j2 < (newdeck[i2].length-1)) j2++; else { j2 = 0; i2++; } } if (Debug.debug) Debug.print(Debug.DEBUG, "New deck: "+formatDeck(newdeck)); return newdeck; } /** * Returns a deck permuted with a perm1 permutation. */ public static byte[][] permute1(byte[][] deck, byte[][] perm1) { if (Debug.debug) Debug.print(Debug.DEBUG, "deck: "+formatDeck(deck)); if (Debug.debug) Debug.print(Debug.DEBUG, "perm: "+formatDeck(perm1)); // get the sizes of the piles byte[][] intermediate = new byte[perm1[0].length][]; for (int i = 0; i < intermediate.length; i++) intermediate[i] = new byte[perm1[0][i]]; int i1, j1, i2, j2; i1 = j1 = i2 = j2 = 0; // copy into 10 piles, inverting as you do j2 = intermediate[i2].length-1; while (i1 < deck.length) { intermediate[i2][j2] = deck[i1][j1]; if (j2 > 0) j2--; else { i2++; if (i2 < intermediate.length) j2 = intermediate[i2].length-1; } if (j1 < (deck[i1].length-1)) j1++; else { i1++; j1 = 0; } } if (Debug.debug) Debug.print(Debug.DEBUG, "Intermediate: "+formatDeck(intermediate)); byte[][] newdeck = new byte[4][13]; int o = 0; j1 = i2 = j2 = 0; i1 = perm1[1][o]-1; // copy back from ten piles in random order while (i2 < newdeck.length) { newdeck[i2][j2] = intermediate[i1][j1]; if (j2 < (newdeck[i2].length-1)) j2++; else { i2++; j2 = 0; } if (j1 < (intermediate[i1].length-1)) j1++; else { // select the next random pile o++; if (o >= perm1[1].length) break; i1 = perm1[1][o]-1; j1 = 0; } } if (Debug.debug) Debug.print(Debug.DEBUG, "New deck: "+formatDeck(newdeck)); return newdeck; } /** * Generates a random permutaion using Knuth's Shuffle. * Start with 11111.....22222....33333...444444..., then * for each item in the list 0....51 swap it with a randomly * chosen item in the list 0....51. * the parameter changes the mode from have 13 of each number * to having between 10 and 16 of each number */ public static byte[] generatePermutation(boolean random) { final int MAX = 16; final int MIN = 10; final int RANGE = MAX-MIN; byte[] perm = new byte[52]; byte[] rand = new byte[52]; if (random) { int[] d = new int[4]; d[0] = MIN + (Math.abs(sr.nextInt()) % RANGE); d[1] = MIN + (Math.abs(sr.nextInt()) % RANGE); if (sr.nextBoolean()) { d[2] = 26-d[0]; d[3] = 26-d[1]; } else { d[2] = 26-d[1]; d[3] = 26-d[0]; } for (byte i = 0, k = 0; i < 4; i++) for (byte j = 0; j < d[i]; j++, k++) perm[k] = i; } else { for (byte i = 0, k = 0; i < 4; i++) for (byte j = 0; j < 13; j++, k++) perm[k] = i; } sr.nextBytes(rand); for (byte k = 0; k < 52; k++) swap(perm, k, Math.abs(rand[k]) % 52); return perm; } /** * Takes a set of hands and a permutation and generates the permuted hands. */ public static byte[][] permute(byte[][] hands, byte[] permutation) { Vector[] newhandv = new Vector[] { new Vector(), new Vector(), new Vector(), new Vector() }; for (int i = 0, k = 0; i < 4; i++) for (int j = 0; j < hands[i].length; j++, k++) newhandv[permutation[k]].add(hands[i][j]); byte[][] newhands = new byte[4][]; for (int i = 0; i < 4; i++) { newhands[i] = new byte[newhandv[i].size()]; for (int j = 0; j < newhands[i].length; j++) newhands[i][j] = (Byte) newhandv[i].get(j); } return reverse(newhands); } @SuppressWarnings("fallthrough") public static double[] getStats(byte[][][] boards, byte[][] tricks) { // { NS games, EW games, NS slams, EW slams, // N points, E points, S points, W points, // 4333%, bal%, 6+ count, 7+ count, 8+ count } double[] stats = new double[STAT_MAX]; for (int i = 0; i < boards.length; i++) { boolean ewslam=false; boolean ewgame=false; boolean nsslam=false; boolean nsgame=false; if (null != tricks) { if (tricks[i][0+0] >= 9 || tricks[i][0+1] >= 10 || tricks[i][0+2] >= 10 || tricks[i][0+3] >= 11 || tricks[i][0+4] >= 11 || tricks[i][5+0] >= 9 || tricks[i][5+1] >= 10 || tricks[i][5+2] >= 10 || tricks[i][5+3] >= 11 || tricks[i][5+4] >= 11) if (!nsgame) { nsgame=true; stats[STAT_NSGAMES]++; } if (tricks[i][10+0] >= 9 || tricks[i][10+1] >= 10 || tricks[i][10+2] >= 10 || tricks[i][10+3] >= 11 || tricks[i][10+4] >= 11 || tricks[i][15+0] >= 9 || tricks[i][15+1] >= 10 || tricks[i][15+2] >= 10 || tricks[i][15+3] >= 11 || tricks[i][15+4] >= 11) if (!ewgame) { ewgame=true; stats[STAT_EWGAMES]++; } for (int j = 0; j < 10; j++) if (!nsslam && tricks[i][j] >= 12) { nsslam=true; stats[STAT_NSSLAMS]++; } for (int j = 10; j < 20; j++) if (!ewslam && tricks[i][j] >= 12) { ewslam=true; stats[STAT_EWSLAMS]++; } } stats[STAT_NPOINTS] += count(boards[i][NORTH]); stats[STAT_SPOINTS] += count(boards[i][SOUTH]); stats[STAT_EPOINTS] += count(boards[i][EAST]); stats[STAT_WPOINTS] += count(boards[i][WEST]); if (bacon(boards[i][NORTH]) || bacon(boards[i][SOUTH]) || bacon(boards[i][WEST]) || bacon(boards[i][EAST])) stats[STAT_BACON]++; for (int p = 0; p < 4; p++) { boolean flat = true; boolean bal = true; boolean semibal = true; int xton = 0; int five = 0; int four = 0; for (int s = 0; s < 4; s++) { if (Debug.debug) Debug.print(Debug.VERBOSE, "board "+i+" player "+p+" suit "+s+" length="+length(boards[i][p], s)); switch (length(boards[i][p], s)) { case 13: case 12: case 11: case 10: case 9: case 8: stats[STAT_8PLUS]++; case 7: stats[STAT_7PLUS]++; case 6: stats[STAT_6PLUS]++; flat = false; break; case 5: five++; flat = false; break; case 4: four++; case 3: break; case 2: xton++; flat = false; break; case 0: stats[STAT_VOID]++; case 1: bal = false; semibal = false; flat = false; break; } } if (Debug.debug) Debug.print(Debug.DEBUG, "board "+i+" player "+p+" xton= "+xton+" four="+four+" five="+five); if (xton > 1) bal = false; if (xton > 2) semibal = false; if (flat) stats[STAT_4333]++; if (bal) stats[STAT_BAL]++; if (semibal) stats[STAT_SEMIBAL]++; if (five == 2) stats[STAT_55]++; if (four == 3) stats[STAT_4441]++; if (Debug.debug) Debug.print(Debug.DEBUG, "stat_4441:"+stats[STAT_4441] ); } } // get average stats[STAT_NPOINTS] /= boards.length; stats[STAT_SPOINTS] /= boards.length; stats[STAT_EPOINTS] /= boards.length; stats[STAT_WPOINTS] /= boards.length; return stats; } @SuppressWarnings("fallthrough") public static int count(byte[] hand) { int total = 0; for (byte a: hand) { int b = a & 0x0f; if (Debug.debug) Debug.print(Debug.VERBOSE,"a = "+a+" b = "+b+" / "+CARD[b]); switch (b) { case ACE: total++; case KING: total++; case QUEEN: total++; case JACK: total++; } } if (Debug.debug) Debug.print(Debug.DEBUG,"total="+total); return total; } public static byte[] generateInitialPermutation() { // returns a permutation of the four suits. byte[] initperm = new byte[] { SPADES, HEARTS, DIAMONDS, CLUBS }; byte[] rand = new byte[4]; sr.nextBytes(rand); for (byte i = 0; i < 4; i++) swap(initperm, i, Math.abs(rand[i]) % 4); return initperm; } public static byte[][] generateInitialHand(byte[] initperm) { byte[][] hand = new byte[4][]; for (int i = 0; i < 4; i++) switch (initperm[i]) { case SPADES: hand[i] = INITIAL_SPADES; break; case HEARTS: hand[i] = INITIAL_HEARTS; break; case DIAMONDS: hand[i] = INITIAL_DIAMONDS; break; case CLUBS: hand[i] = INITIAL_CLUBS; break; } return hand; } /** * Reverses the contents of each hand */ public static byte[][] reverse(byte[][] hands) { byte[][] newhands = new byte[4][]; for (int i = 0; i < 4; i++) { newhands[i] = new byte[hands[i].length]; for (int j = 0, k = (hands[i].length - 1); j < hands[i].length; j++, k--) newhands[i][k] = hands[i][j]; } return newhands; } public static byte find(byte[][] hands, byte card) { for (byte i = 0; i < 4; i++) for (int j = 0; j < hands[i].length; j++) if (hands[i][j] == card) return i; return 0; // never happens } /** * Takes 2 hands and returns the permutation between them. */ public static byte[] getPermutation(byte[][] hand1, byte[][] hand2) { byte[] perm = new byte[52]; for (int i = 0, k = 0; i < 4; i++) for (int j = 0; j < hand1[i].length; j++, k++) perm[k] = find(hand2, hand1[i][j]); return perm; } /** * import from format used by dds double dummy solver. * W N E S = 3 0 1 2 * A64.8732.543.Q98 T8.96.AKT.A76432 Q2.AQJT54.Q82.JT KJ9753.K.J976.K5 */ public static byte[][][] ddsimport(InputStream in) throws IOException { Vector/*<byte[][]>*/ hands = new Vector/*<byte[][]>*/(); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String s; while (null != (s = br.readLine())) hands.add(ddsinparse(s)); return (byte[][][]) hands.toArray(new byte[0][][]); } public static byte[][] ddsinparse(String str) { byte[][] hand = new byte[4][13]; //start afresh int s=1; int p=3; // start at west int i=0; for (int j = 0; j < str.length(); j++) { char c = str.charAt(j); if (Debug.debug) Debug.print(Debug.DEBUG, "Read c="+c+" s="+s+" p="+p+" i="+i); switch (c) { case '.': s++; // next suit i--; // oops, didn't actually want to increment this break; case ' ': p = (p + 1) % 4; // next player s=1; // start suits again i=-1; // start cards in hand again break; case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': hand[p][i] = (byte) (c - '1' + 1 + (s << 4)); break; case 'T': hand[p][i] = (byte) (TEN + (s << 4)); break; case 'J': hand[p][i] = (byte) (JACK + (s << 4)); break; case 'Q': hand[p][i] = (byte) (QUEEN + (s << 4)); break; case 'K': hand[p][i] = (byte) (KING + (s << 4)); break; case 'A': hand[p][i] = (byte) (ACE + (s << 4)); break; default: } i++; // next card in hand } return hand; } public static void exportanalysis(PrintStream out, byte[][] tricks) { for (int i = 0; i < tricks.length; i++) { printtricks(out, tricks[i]); out.println(); } } public static void combinedexport(PrintStream out, byte[][][] boards, byte[][] tricks) throws Exception { if (null == tricks) throw new Exception(_("Must --load, --load-analysis or --analyze to use --save")); for (int i = 0; i < boards.length; i++) { ddsprinthand(out, boards[i][WEST]); out.print(' '); ddsprinthand(out, boards[i][NORTH]); out.print(' '); ddsprinthand(out, boards[i][EAST]); out.print(' '); ddsprinthand(out, boards[i][SOUTH]); out.print(':'); printtricks(out, tricks[i]); out.println(); } } public static byte[] analysisparse(String s) { String[] ss = s.split(","); byte[] tricks = new byte[ss.length]; for (int i = 0; i < ss.length; i++) tricks[i] = Byte.parseByte(ss[i]); return tricks; } public static void printtricks(PrintStream out, byte[] tricks) { for (int i = 0; i < tricks.length; i++) { out.print(tricks[i]); if ((i+1) != tricks.length) out.print(','); } } public static byte[][] importanalysis(InputStream in) throws IOException { Vector/*<byte[]>*/ tricks = new Vector/*<byte[]>*/(); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String s; while (null != (s = br.readLine())) tricks.add(analysisparse(s)); return (byte[][]) tricks.toArray(new byte[0][]); } public static Object[] combinedimport(InputStream in) throws IOException { Vector/*<byte[][]>*/ hands = new Vector/*<byte[][]>*/(); Vector/*<byte[]>*/ tricks = new Vector/*<byte[]>*/(); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String s; while (null != (s = br.readLine())) { String[] ss = s.split(":"); hands.add(ddsinparse(ss[0])); tricks.add(analysisparse(ss[1])); } return new Object[] { hands.toArray(new byte[0][][]), tricks.toArray(new byte[0][]) }; } /** * Export to format used by dds double dummy solver. * W N E S = 3 0 1 2 * A64.8732.543.Q98 T8.96.AKT.A76432 Q2.AQJT54.Q82.JT KJ9753.K.J976.K5 * * dds only solves for N-S, so we have to output two lines, one of them rotated for E-W (rotation printed if rotate is true) * */ public static void ddsexport(PrintStream out, byte[][] hands, boolean rotate) { for (int i = 0; i < 4; i++) Arrays.sort(hands[i]); if (!rotate) { ddsprinthand(out, hands[WEST]); out.print(' '); ddsprinthand(out, hands[NORTH]); out.print(' '); ddsprinthand(out, hands[EAST]); out.print(' '); ddsprinthand(out, hands[SOUTH]); out.println(); } else { ddsprinthand(out, hands[NORTH]); out.print(' '); ddsprinthand(out, hands[EAST]); out.print(' '); ddsprinthand(out, hands[SOUTH]); out.print(' '); ddsprinthand(out, hands[WEST]); out.println(); } } public static void ddsprinthand(PrintStream out, byte[] hand) { int suit = SPADES; for (int s = 1, i = 0; s <= 4; s++) { while (i < 13 && s == (hand[i] >> 4)) out.print(CARD[hand[i++] & 0x0f]); if (s < 4) out.print('.'); } } static void syntax() { String version = Package.getPackage("cx.ath.matthew.pescetti") .getImplementationVersion(); System.out.println("Pescetti Pseudo-Duplimate Generator - version "+version); System.out.println("Syntax: pescetti [options]"); System.out.println(" Options: --help --generate=N --load=<boards.txt> --load-dds=<boards.dds> --load-analysis=<tricks.txt> --permutations=<permutations.txt> --demo --stats --analyze --save=<boards.txt> --save-dds=<boards.dds> --save-analysis=<tricks.txt> --format=<format> --title=<title> --output=<hands.txt> --curtains=<cutains.txt> --probability=<factor> --criteria=<criteria list>"); System.out.println(" Formats: txt html pdf"); System.out.println(" Criteria: unbalanced weaknt strongnt twont strongtwo weaktwo three twoclubs 4441 singlesuit twosuits partscore game slam grand game-invite slam-invite jumpshift jumpfit splinter bacon weird"); } public static byte[] ddanalyse(byte[][] hand) { try { File exec = new File("/usr/games/dds"); if (!exec.exists()) throw new Exception(_("Must install dds double dummy analyzer to analyze hands")); File temp = File.createTempFile("pescetti", ".tmp"); PrintStream fos = new PrintStream(new FileOutputStream(temp)); File temp2 = File.createTempFile("pescetti", ".tmp"); ddsexport(fos, hand, false); ddsexport(fos, hand, true); fos.close(); Process p = Runtime.getRuntime().exec(new String[] { "/bin/sh", "-c", "/usr/games/dds -deal=1 -tricks "+temp.getCanonicalPath()+" | /usr/bin/tail -n2 > " +temp2.getCanonicalPath() }); p.waitFor(); p = Runtime.getRuntime().exec(new String[] { "/bin/sh", "-c", "/usr/games/dds -deal=2 -tricks "+temp.getCanonicalPath()+" | /usr/bin/tail -n2 >> " +temp2.getCanonicalPath()}); p.waitFor(); BufferedInputStream in = new BufferedInputStream(new FileInputStream(temp2)); byte[] tricks = parseDD(in); temp.delete(); temp2.delete(); return tricks; } catch (Exception e) { if (Debug.debug) Debug.print(Debug.ERR, e); System.err.println(_("Failed to DD analyze: ")+e.getMessage()); System.exit(1); } return null; } @SuppressWarnings("fallthrough") public static byte[] parseDD(InputStream in) throws IOException { byte[] out = new byte[20]; final int START = 1; final int READNS = 2; final int READEW = 3; int c; int state = START; int suit = -1; int offs = 0; int n = -1; boolean read = false; while (0 < (c = in.read())) { if (Debug.debug) Debug.print(Debug.DEBUG, ""+(char) c); switch (state) { case START: if (':' == c) state = READNS; break; case READNS: case READEW: switch (c) { case '=': suit++; offs=0; if (suit < 5) read = true; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (n < 0) n = c-'0'; case 'A': case 'B': case 'C': case 'D': if (n < 0) n = c-'A'+10; case 'a': case 'b': case 'c': case 'd': if (n < 0) n = c-'a'+10; if (read) { if (Debug.debug) Debug.print(Debug.DEBUG, "state="+state+" c="+((char)c)+" n="+n+" offs="+offs+" suit="+suit); if (READNS == state && 1 == offs) // north gets n tricks in suit out[0 + suit] = (byte) n; else if (READNS == state && 3 == offs) // south gets n tricks in suit out[5 + suit] = (byte) n; else if (READEW == state && 1 == offs) // east gets n tricks in suit out[10 + suit] = (byte) n; else if (READEW == state && 3 == offs) // west gets n tricks in suit out[15 + suit] = (byte) n; } n = -1; offs++; break; case ' ': read = false; break; case ':': state=READEW; suit=-1; break; default: // skip everything else ; } } } return out; } public static void demo() { Printer print = new TextPrinter(System.out, "Pescetti PseudoDuplimate - Demo mode"); print.println("Sort decending within each suit, A K .... 3 2 (so that the first card delt is the Ace)"); print.println("Stack the suits in the order Spades, Hearts, Diamonds, Clubs, so the first suit is spades."); int cutpoint = getCutPoint(); print.print("Cut the deck so that the "); print.print(""+CARD[cutpoint & 0x0f]); print.print(""+SUIT[cutpoint >> 4]); print.println(" is at the bottom."); byte[] targetperm = generatePermutation(false); byte[][] resulthand = permute(INITIAL_HAND, targetperm); byte[][] inithand = cutDeck(INITIAL_HAND, cutpoint); byte[][] perm1 = generatePermutation1(); byte[][] intermediatehand = permute1(inithand, perm1); byte[] perm2 = getPermutation(intermediatehand, resulthand); print.println("First Deal:"); print.printPermutation1(1, perm1); print.println("Second Deal:"); print.printPermutation(2, 1, perm2, null); print.println("You should now have these hands hand 1 = north, hand 2 = east, hand 3 = south, hand 4 = west"); print.printHand(1, resulthand); print.println("These can go into a file to be run with dds -deal=1 -tricks file.txt and dds -deal=2 -tricks file.txt"); ddsexport(System.out, resulthand, false); ddsexport(System.out, resulthand, true); byte[] tricks = ddanalyse(resulthand); print.println("It says: "); print.printTricks(tricks); print.close(); System.exit(0); } public static void parseopts(HashMap/* <String,String> */ options, String[] args) { for (int i = 0; i < args.length; i++) { String[] opt = args[i].split("="); if (Debug.debug) Debug.print(Arrays.asList(opt)); if (options.containsKey(opt[0])) { if (opt.length == 1) options.put(opt[0], "true"); else options.put(opt[0], opt[1]); } else { System.out.println(_("Error: unknown option ")+opt[0]); syntax(); System.exit(1); } } } public static void permutation_genandsave(HashMap/* <String,String> */ options, byte[][][] boards) { String file = (String) options.get("--permutations"); try { PrintStream permfile = new PrintStream(new FileOutputStream(file)); Printer permprint = null; if ("txt".equals(options.get("--format"))) { permprint = new TextPrinter(permfile, options.get("--title")+" - "+_("Permutations")); } else if ("html".equals(options.get("--format"))) { permprint = new HTMLPrinter(permfile, options.get("--title")+" - "+_("Permutations")); } else if ("pdf".equals(options.get("--format"))) { permprint = new PDFPrinter(permfile, options.get("--title")+" - "+_("Permutations")); } else { System.err.println(_("Invalid format ")+options.get("--format")); System.exit(1); } int count = boards.length; byte[][][] perms = new byte[count][3][]; // generate them all for (int i = 0; i < count; i++) { perms[i][0] = generateInitialPermutation(); byte[][] initial = generateInitialHand(perms[i][0]); perms[i][1] = generatePermutation(true); byte[][] intermediate = permute(initial, perms[i][1]); perms[i][2] = getPermutation(intermediate, boards[i]); } // print them, interleaving perm1 with perm2 for a later board for (int i = 0; i < count; i+=4) { if (i+3 < count) { permprint.printPermutation(1, i+1, perms[i+0][1], perms[i+0][0]); permprint.printPermutation(1, i+2, perms[i+1][1], perms[i+1][0]); permprint.printPermutation(2, i+3, perms[i+2][2], null); permprint.printPermutation(2, i+4, perms[i+3][2], null); permprint.printPermutation(1, i+3, perms[i+2][1], perms[i+2][0]); permprint.printPermutation(1, i+4, perms[i+3][1], perms[i+3][0]); permprint.printPermutation(2, i+1, perms[i+0][2], null); permprint.printPermutation(2, i+2, perms[i+1][2], null); } else { for (int j = i; j < count; j++) permprint.printPermutation(1, j+1, perms[j][1], perms[j][0]); for (int j = i; j < count; j++) permprint.printPermutation(2, j+1, perms[j][2], null); } } permprint.close(); } catch (Exception e) { if (Debug.debug) Debug.print(Debug.ERR, e); System.err.println(_("Failed to save permutations: ")+e.getMessage()); syntax(); System.exit(1); } } public static void curtains(HashMap/* <String,String> */ options, byte[][][] boards) { try { PrintStream curtainfile = new PrintStream(new FileOutputStream((String) options.get("--curtains"))); Printer curtainprint = null; if ("txt".equals(options.get("--format"))) curtainprint = new TextPrinter(curtainfile, options.get("--title")+" - "+_("Curtain Cards")); else if ("html".equals(options.get("--format"))) curtainprint = new HTMLPrinter(curtainfile, options.get("--title")+" - "+_("Curtain Cards")); else if ("pdf".equals(options.get("--format"))) curtainprint = new PDFPrinter(curtainfile, options.get("--title")+" - "+_("Curtain Cards")); else { System.err.println(_("Invalid format ")+options.get("--format")); System.exit(1); } int count = boards.length; int i = 0; while (i < count) { int j; for (j = i; j < i+6 && j < count; j++) { curtainprint.printCurtains(j+1, boards[j]); } for (j = i; j < i+6 && j < count; j++) { curtainprint.printCurtainBack(j+1); } i = j; } curtainprint.close(); } catch (Exception e) { if (Debug.debug) Debug.print(Debug.ERR, e); System.err.println(_("Failed to save curtaincards: ")+e.getMessage()); syntax(); System.exit(1); } } public static boolean contains(byte[] hand, int card) { for (int i = 0; i < hand.length; i++) { if (Debug.debug) Debug.print(Debug.VERBOSE, "hand["+i+"]: "+hand[i]+", card: "+card); if (hand[i] == card) return true; } return false; } public static int length(byte[] hand, int suit) { int len = 0; if (suit < 10) { suit++; suit <<= 4; } for (int i = 0; i < hand.length; i++) if ((hand[i] & 0xf0) == suit) len++; return len; } public static boolean bacon(byte[] hand) { // singleton beer if (1 == length(hand, DIAMONDS) && contains(hand, DIAMONDS | 7)) return true; // 4 of a kind for (int i = 2; i < ACE; i++) if (contains(hand, CLUBS | i) && contains(hand, DIAMONDS | i) && contains(hand, HEARTS | i) && contains(hand, SPADES | i)) return true; // straight flush for (int i = 0, s = 0, c = 0, l = 0; i < hand.length; i++) { if ((hand[i] & 0x0f) == (c+1)) { l++; c++; } else { l = 0; c = hand[i] & 0x0f; } if ((hand[i] & 0xf0) != s) { l = 0; s = hand[i] & 0xf0; } if (l == 5) return true; } return false; } @SuppressWarnings("unchecked") public static void main(String[] args) { if (Debug.debug) { File f = new File("debug.conf"); try { if (f.exists()) Debug.loadConfig(f); } catch (Exception e) {} Debug.setThrowableTraces(true); } // read options HashMap/* <String,String> */ options = new HashMap/* <String,String> */(); options.put("--help", null); options.put("--generate", null); options.put("--load", null); options.put("--load-dds", null); options.put("--load-analysis", null); options.put("--permutations", null); options.put("--demo", null); options.put("--save", null); options.put("--save-dds", null); options.put("--save-analysis", null); options.put("--output", null); options.put("--curtains", null); options.put("--stats", null); options.put("--analyze", null); options.put("--probability", null); options.put("--criteria", null); options.put("--format", "txt"); options.put("--title", "Pescetti PseudoDuplimate"); parseopts(options, args); byte[][][] boards = null; byte[][] tricks = null; // get boards somehow, or demo if (null != options.get("--help")) { syntax(); System.exit(0); } else if (null != options.get("--generate")) { int count = 0; try { count = Integer.parseInt((String) options.get("--generate")); } catch (Exception e) { if (Debug.debug) Debug.print(Debug.ERR, e); System.err.println(_("Failed to parse number of boards to generate: ")+e.getMessage()); syntax(); System.exit(1); } boards = new byte[count][][]; if (null != options.get("--criteria")) { HashMap<Criteria, Double> cs = null; try { cs = Criteria.parseCriteria((String) options.get("--criteria")); } catch (Exception e) { if (Debug.debug) Debug.print(Debug.ERR, e); System.err.println(_("Failed to parse criteria: ")+e.getMessage()); syntax(); System.exit(1); } BoardChecker bc = new BoardChecker(cs); double probability = 1.0; int maxattempts = 100000; if (null != options.get("--probability")) try { probability = Double.parseDouble((String) options.get("--probability")); } catch (Exception e) { if (Debug.debug) Debug.print(Debug.ERR, e); System.err.println(_("Failed to parse probability: ")+e.getMessage()); syntax(); System.exit(1); } Random r = new Random(); for (int i = 0; i < count; i++) { double cw = ((double) r.nextInt(1073741824)) / 1073741824.0; boards[i] = permute(INITIAL_HAND, generatePermutation(false)); if (Debug.debug) Debug.print(Debug.DEBUG, "board "+i+" probability factor "+probability+" current number "+cw); if (cw < probability) { if (Debug.debug) { for (int j = 0; j < 4; j++) Debug.print(Debug.VERBOSE, "hand "+j+" has "+count(boards[i][j])+" points"); for (int p = 0; p < 4; p++) for (int s = 0; s < 4; s++) Debug.print(Debug.VERBOSE, "hand "+p+" suit "+s+" is "+length(boards[i][p], s)); } boolean match = bc.check(boards[i]); if (!match && maxattempts > 0) { i--; maxattempts--; // don't try forever to create matching hands continue; } else if (Debug.debug) Debug.print(Debug.INFO, "Board "+i+" matches criteria"); } } } else for (int i = 0; i < count; i++) boards[i] = permute(INITIAL_HAND, generatePermutation(false)); } else if (null != options.get("--load")) { try { InputStream in = new BufferedInputStream(new FileInputStream((String) options.get("--load"))); Object[] tmp = combinedimport(in); boards = (byte[][][]) tmp[0]; tricks = (byte[][]) tmp[1]; in.close(); } catch (Exception e) { if (Debug.debug) Debug.print(Debug.ERR, e); System.err.println(_("Failed to load boards: ")+e.getMessage()); syntax(); System.exit(1); } } else if (null != options.get("--load-dds")) { try { InputStream in = new BufferedInputStream(new FileInputStream((String) options.get("--load-dds"))); boards = ddsimport(in); in.close(); } catch (Exception e) { if (Debug.debug) Debug.print(Debug.ERR, e); System.err.println(_("Failed to load boards: ")+e.getMessage()); syntax(); System.exit(1); } } else if (null != options.get("--demo")) { demo(); } else { System.out.println(_("Must specify either --generate --load{,-dds} or --demo")); syntax(); System.exit(1); } if (null != options.get("--load-analysis")) { try { InputStream in = new BufferedInputStream(new FileInputStream((String) options.get("--load-analysis"))); tricks = importanalysis(in); in.close(); } catch (Exception e) { if (Debug.debug) Debug.print(Debug.ERR, e); System.err.println(_("Failed to load analysis: ")+e.getMessage()); syntax(); System.exit(1); } } // analyze if asked for if (null != options.get("--analyze")) { tricks = new byte[boards.length][]; for (int i = 0; i < boards.length; i++) tricks[i] = ddanalyse(boards[i]); } // export boards if asked for if (null != options.get("--save-dds") && null != boards) { String file = (String) options.get("--save-dds"); try { PrintStream out = new PrintStream(new FileOutputStream(file)); for (int i = 0; i < boards.length; i++) ddsexport(out, boards[i], false); out.close(); } catch (Exception e) { if (Debug.debug) Debug.print(Debug.ERR, e); System.err.println(_("Failed to save boards: ")+e.getMessage()); syntax(); System.exit(1); } } // export boards if asked for if (null != options.get("--save") && null != boards) { String file = (String) options.get("--save"); try { PrintStream out = new PrintStream(new FileOutputStream(file)); combinedexport(out, boards, tricks); out.close(); } catch (Exception e) { if (Debug.debug) Debug.print(Debug.ERR, e); System.err.println(_("Failed to save boards: ")+e.getMessage()); syntax(); System.exit(1); } } // export boards if asked for if (null != options.get("--save-analysis")) { try { if (null == tricks) throw new Exception(_("You must specify --load, --load-analysis or --analyze to save the analysis")); String file = (String) options.get("--save-analysis"); PrintStream out = new PrintStream(new FileOutputStream(file)); exportanalysis(out, tricks); out.close(); } catch (Exception e) { if (Debug.debug) Debug.print(Debug.ERR, e); System.err.println(_("Failed to save analysis: ")+e.getMessage()); syntax(); System.exit(1); } } // generate permutations and save, if ased for if (null != options.get("--permutations") && null != boards) { permutation_genandsave(options, boards); } // save curtain cards, if ased for if (null != options.get("--curtains") && null != boards) { curtains(options, boards); } // redirect output if asked for PrintStream out = System.out; if (null != options.get("--output")) try { out = new PrintStream(new FileOutputStream((String) options.get("--output"))); } catch (Exception e) { if (Debug.debug) Debug.print(e); System.err.println(_("Cannot open file for output: ")+e.getMessage()); System.exit(1); } Printer print = null; if ("txt".equals(options.get("--format"))) print = new TextPrinter(out, (String) options.get("--title")); else if ("html".equals(options.get("--format"))) print = new HTMLPrinter(out, (String) options.get("--title")); else if ("pdf".equals(options.get("--format"))) print = new PDFPrinter(out, (String) options.get("--title")); else { System.err.println(_("Invalid format ")+options.get("--format")); System.exit(1); } // print boards and tricks if asked for byte[] points = new byte[4]; for (int i = 0; i < boards.length; i++) { print.printHand(i+1, boards[i]); points[NORTH] = (byte) count(boards[i][NORTH]); points[SOUTH] = (byte) count(boards[i][SOUTH]); points[EAST] = (byte) count(boards[i][EAST]); points[WEST] = (byte) count(boards[i][WEST]); print.printPoints(points); if (null != tricks) print.printTricks(tricks[i]); } // print stats if asked for if (null != options.get("--stats")) { double[] stats = getStats(boards, tricks); print.printStats(stats); } print.close(); } } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������pescetti-0.5/cx/ath/matthew/pescetti/.Constants.java.swo��������������������������������������������0000644�0001750�0001750�00000040000�11300051551�022012� 0����������������������������������������������������������������������������������������������������ustar �mjj29���������������������������mjj29������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������b0VIM 7.1������@S�K�/s��mjj29�����������������������������������qadesh����������������������������������/mnt/tmp/mjj29/scm/bridgedeal/cx/ath/matthew/pescetti/Constants.java���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������utf-8 �3210#"! U�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������tp�������/���������������0������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ad���������/�������������]������v��)�� �� ��E ��% ��" �� �� �� �� �� �� �� �� ��~ ��S ��& �� �� �� ��~ ��T ��+ �� �� ��" �� ��A �� ��D����q��@������Y�� ����.������������j��=����������\��/����������X��,����������U��T��R��Q��������������������}�� public static final int STAT_MAX = 18;� public static final int STAT_4441 = 17;� public static final int STAT_VOID = 16;� public static final int STAT_55 = 15;� public static final int STAT_SEMIBAL = 14;� public static final int STAT_BACON = 13;� public static final int STAT_8PLUS = 12;� public static final int STAT_7PLUS = 11;� public static final int STAT_6PLUS = 10;� public static final int STAT_BAL = 9;� public static final int STAT_4333 = 8;� public static final int STAT_WPOINTS = 7;� public static final int STAT_EPOINTS = 6;� public static final int STAT_SPOINTS = 5;� public static final int STAT_NPOINTS = 4;� public static final int STAT_EWSLAMS = 3;� public static final int STAT_NSSLAMS = 2;� public static final int STAT_EWGAMES = 1;� public static final int STAT_NSGAMES = 0;�� public static final int WEST = 3;� public static final int SOUTH = 2;� public static final int EAST = 1;� public static final int NORTH = 0;� public static final char[] CARD = { '!', '!', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A' };� public static final char[] DINGSUIT = { '!', (char) 171, (char) 170, (char) 169, (char) 168, 'N' };� public static final char[] SHORTSUIT = { '!', 'S', 'H', 'D', 'C', 'N' };� public static final char[] SUIT = { '!', '♠', '♡', '♢', '♣', 'N' };� public static final String[] PLAYER = { "North", "East", "South", "West" };� INITIAL_SPADES, INITIAL_HEARTS, INITIAL_DIAMONDS, INITIAL_CLUBS };� public static final byte[][] INITIAL_HAND = {� {CLUBS | ACE, CLUBS | KING, CLUBS | QUEEN, CLUBS | JACK, CLUBS | TEN, CLUBS | 9, CLUBS | 8, CLUBS | 7, CLUBS | 6, CLUBS | 5, CLUBS | 4, CLUBS | 3, CLUBS | 2};� public static final byte[] INITIAL_CLUBS =� {DIAMONDS | ACE, DIAMONDS | KING, DIAMONDS | QUEEN, DIAMONDS | JACK, DIAMONDS | TEN, DIAMONDS | 9, DIAMONDS | 8, DIAMONDS | 7, DIAMONDS | 6, DIAMONDS | 5, DIAMONDS | 4, DIAMONDS | 3, DIAMONDS | 2};� public static final byte[] INITIAL_DIAMONDS =� {HEARTS | ACE, HEARTS | KING, HEARTS | QUEEN, HEARTS | JACK, HEARTS | TEN, HEARTS | 9, HEARTS | 8, HEARTS | 7, HEARTS | 6, HEARTS | 5, HEARTS | 4, HEARTS | 3, HEARTS | 2};� public static final byte[] INITIAL_HEARTS =� {SPADES | ACE, SPADES | KING, SPADES | QUEEN, SPADES | JACK, SPADES | TEN, SPADES | 9, SPADES | 8, SPADES | 7, SPADES | 6, SPADES | 5, SPADES | 4, SPADES | 3, SPADES | 2};� public static final byte[] INITIAL_SPADES =� public static final byte ACE = 0x0E;� public static final byte KING = 0x0D;� public static final byte QUEEN = 0x0C;� public static final byte JACK = 0x0B;� public static final byte TEN = 0x0A;� public static final byte NOTRUMPS = 0x50;� public static final byte CLUBS = 0x40;� public static final byte DIAMONDS = 0x30;� public static final byte HEARTS = 0x20;� public static final byte SPADES = 0x10;�{�public interface Constants��package cx.ath.matthew.pescetti;�� */� *� * To Contact me, please email src@matthew.ath.cx� *� * Boston, MA 02111-1307, USA.� * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,� * copy of the GNU General Public License along with this program; if not,� * GNU General Public License for more details. You should have received a� * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the� * it will be useful, but WITHOUT ANY WARRANTY; without even the implied� * the Free Software Foundation. This program is distributed in the hope that� * under the terms of the GNU General Public License Version 2 as published by� * This program is free software; you can redistribute it and/or modify it� *� * Copyright (C) 2007 Matthew Johnson� * � * Pescetti Pseudo-Duplimate Generator�/* �ad�� ��E ����������!������������]��0���� �� ��| ��O ��" �� �� �� ��w ��K �� �� �� �� ��r ��H ��G ��E �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������}�� public static final int STAT_MAX = 18;� public static final int STAT_4441 = 17;� public static final int STAT_VOID = 16;� public static final int STAT_55 = 15;� public static final int STAT_SEMIBAL = 14;� public static final int STAT_BACON = 13;� public static final int STAT_8PLUS = 12;� public static final int STAT_7PLUS = 11;� public static final int STAT_6PLUS = 10;� public static final int STAT_BAL = 9;� public static final int STAT_4333 = 8;� public static final int STAT_WPOINTS = 7;� public static final int STAT_EPOINTS = 6;� public static final int STAT_SPOINTS = 5;� public static final int STAT_NPOINTS = 4;� public static final int STAT_EWSLAMS = 3;� public static final int STAT_NSSLAMS = 2;� public static final int STAT_EWGAMES = 1;� public static final int STAT_NSGAMES = 0;�� public static final int WEST = 3;� public static final int SOUTH = 2;� public static final int EAST = 1;� public static final int NORTH = 0;� public static final char[] CARD = { '!', '!', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A' };� public static final String[] LONGSUIT = { "!", "Spades", "Hearts", "Diamonds", "Clubs", "No Trumps" };�pescetti-0.5/cx/ath/matthew/pescetti/.PDFPrinter.java.swo�������������������������������������������0000644�0001750�0001750�00000140000�11300062535�022020� 0����������������������������������������������������������������������������������������������������ustar �mjj29���������������������������mjj29������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������b0VIM 7.1������e�Kd���mjj29�����������������������������������qadesh����������������������������������/mnt/tmp/mjj29/scm/bridgedeal/cx/ath/matthew/pescetti/PDFPrinter.java��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������utf-8 �3210#"! U�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������tp �������q��������� ������x��������� ���j���������.���p���������V������������ ��������� ���<��������������G����� ���\���L��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ad��\���4�����q�������������]������v��)�� �� ��E ��% ��" �� �� �� �� �� �� �� ��_ ��= �� �� �� �� �� ��t ��D ��C �� �� �� �� ��u ��t ��7 ��5 �� �� �� �� �� ��a ��H ��1 �� ������������c��9�� ����������l��S��,������������h��`��[��2��/�� ��������w��f��F��.��������������o��l��J��8��5�� ����������{��d��C��!������������������l��L��4��9��"���� ���� ��� break;� suit = ( break;� break;� break;� su default: return ' ';� case 'S': return (char) 171;� case 'H': return (char) 170;� case 'D': return (char) 169;� case 'C': return (char) 168;� switch (suit) {� {� char getDingSuit(char suit)� }� cellcount++;� incell = true;� handstruct.setDefaultLayout(c);� c.setBorderColor(Color.WHITE);� Cell c = new Cell();� handstruct.setBorderWidth(1);� handstruct.setBorderColor(new Color(0, 0, 0));� handstruct.setWidth(100);� handstruct = new Table(3,3);� {� void startcell() throws DocumentException� }� incell = false;� struct.insertTable(handstruct);� {� void stopcell() throws DocumentException� }� infulltable = true;� struct.setDefaultLayout(c);� c.setBorderColor(Color.BLACK);� Cell c = new Cell();� struct.setBorderColor(Color.WHITE);� struct.setWidth(100);� struct = new Table(MAXCELLS);� doc.add(head);� head.setSpacingAfter(-20);� Paragraph head = new Paragraph(header, new Font(Font.HELVETICA, 16, Font.BOLD));� doc.newPage();� doc.add(struct);� if (infulltable) stopfulltable();� {� void newpage() throws DocumentException� }� }� if (Debug.debug) Debug.print(De);� } catch (DocumentException De) {� this.header = header;� struct.setDefaultLayout(c);� c.setBorderColor(Color.BLACK);� Cell c = new Cell();� struct.setBorderColor(Color.WHITE);� struct.setWidth(100);� struct = new Table(MAXCELLS);� doc.add(head);� head.setSpacingAfter(-20);� Paragraph head = new Paragraph(header, new Font(Font.HELVETICA, 16, Font.BOLD));� doc.open();� doc.addTitle(header);� PdfWriter.getInstance(doc, out);� this.doc = new Document(PageSize.A4, 20,20,30,30);� this.out = out;� try {� {� public PDFPrinter(PrintStream out, String header)� private String header;� private Table handstruct;� private Table struct;� private Document doc;� private static final int MAXCELLS = 3;� private int cellcount = 0;� private boolean incell = false;� /*private boolean inrow = false;*/� private boolean infulltable = true;� private PrintStream out;�{�public class PDFPrinter extends Printer implements Constants��import java.text.DecimalFormat;�import java.io.PrintStream;�import java.awt.Color; ��import cx.ath.matthew.debug.Debug;��import com.lowagie.text.pdf.draw.LineSeparator;�import com.lowagie.text.pdf.PdfWriter;�import com.lowagie.text.Table;�import com.lowagie.text.Phrase;�import com.lowagie.text.Paragraph;�import com.lowagie.text.PageSize;�import com.lowagie.text.Font;�import com.lowagie.text.Document;�import com.lowagie.text.DocumentException;�import com.lowagie.text.Chunk;�import com.lowagie.text.Cell;��package cx.ath.matthew.pescetti;� */� *� * To Contact me, please email src@matthew.ath.cx� *� * Boston, MA 02111-1307, USA.� * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,� * copy of the GNU General Public License along with this program; if not,� * GNU General Public License for more details. You should have received a� * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the� * it will be useful, but WITHOUT ANY WARRANTY; without even the implied� * the Free Software Foundation. This program is distributed in the hope that� * under the terms of the GNU General Public License Version 2 as published by� * This program is free software; you can redistribute it and/or modify it� *� * Copyright (C) 2007 Matthew Johnson� * � * Pescetti Pseudo-Duplimate Generator�/* �ad�� �� ������������H����������L������ �� �� ��\ ��< �� �� �� �� �� �� �� �� �� �� �� �� ��v ��X ��B ��A ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������}� }� out.prin�}� }� out.print(s);� �}� }� out.pr�}� }� {� public void print(String s)� }� {� public void println(String s)� }� }� if (Debug.debug) Debug.print(De);� } catch (DocumentException De) {� handstruct.addCell(r, 2, 0);� r.setVerticalAlignment(Cell.ALIGN_MIDDLE);� Cell r = new Cell(table);� table.addCell(c);� c = new Cell(new Phrase("", new Font(Font.HELVETICA, 6, Font.NORMAL)));� table.addCell(c);� c.setHorizontalAlignment(Cell.ALIGN_CENTER);� c = new Cell(new Phrase(""+points[SOUTH], new Font(Font.HELVETICA, 6, Font.NORMAL)));� table.addCell(c);� c = new Cell(new Phrase("", new Font(Font.HELVETICA, 6, Font.NORMAL)));� table.addCell(c);� c.setHorizontalAlignment(Cell.ALIGN_LEFT);� c = new Cell(new Phrase(""+points[EAST], new Font(Font.HELVETICA, 6, Font.NORMAL)));� table.addCell(c);� c = new Cell(new Phrase("", new Font(Font.HELVETICA, 6, Font.NORMAL)));�ad�� �� �����.���������j��T��%����������y��b��W��K��?��2��%�� ����� �� �� �� �� �� �� �� �� ��y ��m ��a ��H ��< ��/ ��" �� �� �� �� ��T �� �� �� �� �� �� �� ��1 �� ��x ��X ��A �� �� �� �� �� ��r ��X ��S �� �� �� �� �� ��u ��S ��1 �� ��������c��C��B��6������������Q��#��������������z��O����������8��$������������z��N��=��&�� ����������|��Z��;��'������������r��\��'���� } catch (DocumentException De) {� if (2 == permnum && 0 == boardnum % 2) newpage();� struct.addCell(c);� c.setColspan(4);� c = new Cell(new Phrase(sb.toString(), new Font(Font.HELVETICA, 14, Font.NORMAL)));� }� sb.append("\n");� if (19 == k % 20) � sb.append(" ");� if (3 == k % 4)� sb.append(""+(perm[k]+1));� for (int k = 0; k < 52; k++) {� sb = new StringBuilder();� }� struct.addCell(c);� c.setColspan(4);� c = new Cell(new Phrase(sb.toString(), new Font(Font.HELVETICA, 10, Font.BOLD)));� }� sb.append(", ");� if (i < 3) � sb.append(LONGSUIT[initperm[i] >> 4]);� for (int i = 0; i < 4; i++) {� sb.append("Order the suits: ");� sb = new StringBuilder();� if (null != initperm) {� StringBuilder sb;� struct.addCell(c);� c.setColspan(4);� Cell c = new Cell(new Phrase("Board "+boardnum+" permutation "+permnum, new Font(Font.HELVETICA, 12, Font.BOLD)));� try {� {� public void printPermutation(int permnum, int boardnum, byte[] perm, byte[] initperm)� public void printPermutation1(int num, byte[][] perm){}� public void printCurtainBack(int num){}� public void printCurtains(int num, byte[][] hand){}�� }� }� if (Debug.debug) Debug.print(De);� } catch (DocumentException De) {� handstruct.addCell(c, 2, 1);� c.setHorizontalAlignment(Cell.ALIGN_LEFT);� c = new Cell(new Phrase(handstr.toString(), new Font(Font.HELVETICA, 7, Font.NORMAL)));� }� handstr.append("\n");� handstr.append(printablehand[i]);� for (int i = 12; i < 16; i++) {� handstr = new StringBuilder();� // SOUTH�� handstruct.addCell(c, 1, 2);� c.setHorizontalAlignment(Cell.ALIGN_LEFT);� c = new Cell(new Phrase(handstr.toString(), new Font(Font.HELVETICA, 7, Font.NORMAL)));� }� handstr.append("\n");� handstr.append(printablehand[i]);� for (int i = 8; i < 12; i++) {� handstr = new StringBuilder();� // EAST�� handstruct.addCell(new Cell(), 1, 1);� handstruct.addCell(c, 1, 0);� c.setHorizontalAlignment(Cell.ALIGN_LEFT);� c = new Cell(new Phrase(handstr.toString(), new Font(Font.HELVETICA, 7, Font.NORMAL)));� }� handstr.append("\n");� handstr.append(printablehand[i]);� handstr.append(" ");� for (int i = 4; i < 8; i++) {� handstr = new StringBuilder();� // WEST�� handstruct.addCell(c, 0, 1);� c.setH Phrase handstr = new Phrase();� {� // NORTH;� // 2� // 3 1� // 0 �handstr.ad Ph Phrase handstr = new Phrase(8);� // NORTH;� // 2� // 3 1� // 0 � Font HEL = new Font(Font.HELVETICA, 7, Font.NORMAL);� Font DINGFONT = new Font(Font.ZAPFDINGBATS, 7, Font.NORMAL);�� handstruct.addCell(new Cell(new Phrase(vuln.toString(), new Font(Font.HELVETICA, 8, Font.NORMAL))), 0, 2);� }� vuln.append("NONE");� default:� // NONE� break;� vuln.append("E-W");� case 0:� case 9:� case 6:� case 3:� // E-W� break;� vuln.append("N-S");� case 15:� case 12:� case 5:� case 2:� // N-S� break;� vuln.append("ALL");� case 13:� case 10:� case 7:� case 4:� // ALL� switch (num % 16) {� vuln.append("\nVuln: ");� }� case 0: vuln.append(PLAYER[WEST]); break;� case 3: vuln.append(PLAYER[SOUTH]); break;� case 2: vuln.append(PLAYER[EAST]); break;� case 1: vuln.append(PLAYER[NORTH]); break;� switch (num % 4) {� vuln.append("Dlr: ");� StringBuilder vuln = new StringBuilder();� handstruct.addCell(c, 0, 0);� c.setHorizontalAlignment(Cell.ALIGN_CENTER);�ad��^�������V�������w��7���� ������������x��W���� �� �� ��} ��c ��5 �� �� �� �� �� �� ��i ��: �� �� �� �� �� ��f ��e ��Y ��= �� �� �� ��r ��K ��F ��, �� �� �� �� �� �� �� ��U ��* ����������������������p��N��"������������k��f��I��'��������������S��8��"��������^���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� } catch (DocumentException De) {� if (2 == permnum && 0 == boardnum % } catch (DocumentException De) {� if (2 == per } catch (DocumentException De) {� if (2 } } catch (DocumentException De) {� } catch (DocumentException De) {� if (2 == permnum && 0 == boardnu } catch (DocumentException De) {� if (2 == permnum && 2 == boardnum % 4) newpage();� struct.addCell(c);� c.setColspan(MAXCELLS);� c = new Cell(new Phrase(sb.toString(), new Font(Font.HELVETICA, 14, Font.NORMAL)));� }� sb.append("\n");� if (19 == k % 20) � sb.append(" ");� if (3 == k % 4)� sb.append(""+(perm[k]+1));� for (int k = 0; k < 52; k++) {� sb = new StringBuilder();� }� struct.addCell(c);� c.setColspan(MAXCELLS);� c = new Cell(new Phrase(sb.toString(), new Font(Font.HELVETICA, 10, Font.BOLD)));� }� sb.append(", ");� if (i < 3) � sb.append(LONGSUIT[initperm[i] >> 4]);� for (int i = 0; i < 4; i++) {� sb.append("Order the suits: ");� sb = new StringBuilder();� if (null != initperm) {� StringBuilder sb;� struct.addCell(c);� c.setColspan(MAXCELLS);� Cell c = new Cell(new Phrase("Board "+boardnum+" permutation "+permnum, new Font(Font.HELVETICA, 12, Font.BOLD)));� try {� {� public void printPermutation(int permnum, int boardnum, byte[] perm, byte[] initperm)� public void printPermutation1(int num, byte[][] perm){}� public void printCurtainBack(int num){}� public void printCurtains(int num, byte[][] hand){}�� }� }� if (Debug.debug) Debug.print(De);� } catch (DocumentException De) {� handstruct.addCell(c, 2, 1);� c.setHorizontalAlignment(Cell.ALIGN_LEFT);� c = new Cell(handstr);� }� handstr.add(new Chunk("\n", HEL));� handstr.add(new Chunk(printablehand[i].substring(1), HEL));� handstr.add(new Chunk(""+suit, DINGFONT));� char suit = getDingSuit(printablehand[i].charAt(0));� for (int i = 12; i < 16; i++) {� handstr = new Phrase(8);� // SOUTH�� handstruct.addCell(c, 1, 2);� c.setHorizontalAlignment(Cell.ALIGN_LEFT);� c = new Cell(handstr);� }� handstr.add(new Chunk("\n", HEL));� handstr.add(new Chunk(printablehand[i].substring(1), HEL));� handstr.add(new Chunk(""+suit, DINGFONT));� char suit = getDingSuit(printablehand[i].charAt(0));� for (int i = 8; i < 12; i++) {� handstr = new Phrase(8);� // EAST�� handstruct.addCell(new Cell(), 1, 1);� handstruct.addCell(c, 1, 0);� c.setHorizontalAlignment(Cell.ALIGN_LEFT);� c = new Cell(handstr);� }� handstr.add(new Chunk("\n", HEL));� handstr.add(new Chunk(printablehand[i].substring(1), HEL));� handstr.add(new Chunk(" "+suit, DINGFONT));� char suit = getDingSuit(printablehand[i].charAt(0));� for (int i = 4; i < 8; i++) {� handstr = new Phrase(8);� // WEST� � handstruct.addCell(c, 0, 1);� c.setHorizontalAlignment(Cell.ALIGN_LEFT);� c = new Cell(handstr);� }� handstr.add(new Chunk("\n", HEL));� handstr.add(new Chunk(printablehand[i].substring(1), HEL));� handstr.add(new Chunk(""+suit, DINGFONT));� char suit = getDingSuit(printablehand[i].charAt(0));� for (int i = 0; i < 4; i++) {�ad��������� ���������������t��U��E��)��������������������{��P��H��C��B������ �� �� �� ��| ��V ��> �� �� �� �� �� ��D �� ��I �� �� �� �� �� ��Y ��A ��! �� �� �� �� ����)����������������l��k������������o��n��U��/����������q������!�� ������������{��d��c������ table.addCell(new Phrase("# Bacon hands: "+(int)stats[STAT_BACON], new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("# Voids: "+(int)stats[STAT_VOID], new Font(Font.HELVETICA, 10, Font.NORMAL)));�� table.endHeaders();� table.setDefaultLayout(def);� table.setPadding(2);� table.setBorderColor(Color.WHITE);� table = new Table(1);�� struct.addCell(c);� c = new Cell(table);� table.addCell(new Phrase("# 8+ suits: "+(int)stats[STAT_8PLUS], new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("# 7+ suits: "+(int)stats[STAT_7PLUS], new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("# 6+ suits: "+(int)stats[STAT_6PLUS], new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("# 5-5 hands: "+(int)stats[STAT_55], new Font(Font.HELVETICA, 10, Font.NORMAL)));�� table.endHeaders();� table.setDefaultLayout(def);� table.setPadding(2);� table.setBorderColor(Color.WHITE);� table = new Table(1);�� struct.addCell(c);� c = new Cell(table);� table.addCell(new Phrase("# 4441 hands: "+(int)stats[STAT_4441], new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("# Semi-bal hands: "+(int)stats[STAT_SEMIBAL], new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("# Balanced hands: "+(int)stats[STAT_BAL], new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("# 4333 hands: "+(int)stats[STAT_4333], new Font(Font.HELVETICA, 10, Font.NORMAL)));�� table.endHeaders();� table.setDefaultLayout(def);� table.setPadding(2);� table.setBorderColor(Color.WHITE);� table = new Table(1);�� struct.addCell(c);� c = new Cell(table);� table.addCell(new Phrase("East-West slams: "+(int)stats[STAT_NSSLAMS], new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("North-South slams: "+(int)stats[STAT_NSSLAMS], new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("East-West games: "+(int)stats[STAT_NSGAMES], new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("North-South games: "+(int)stats[STAT_NSGAMES], new Font(Font.HELVETICA, 10, Font.NORMAL)));�� table.endHeaders();� table.setDefaultLayout(def);� table.setPadding(2);� table.setBorderColor(Color.WHITE);� table = new Table(1);�� struct.addCell(c);� Cell c = new Cell(table);� table.addCell(new Phrase("West avg points: "+df.format(stats[STAT_WPOINTS]), new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("East avg points: "+df.format(stats[STAT_EPOINTS]), new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("South avg points: "+df.format(stats[STAT_SPOINTS]), new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("North avg points: "+df.format(stats[STAT_NPOINTS]), new Font(Font.HELVETICA, 10, Font.NORMAL)));� if (infulltable) stopfulltable();� /* if (inrow) stoprow();*/�� table.endHeaders();� table.setDefaultLayout(def);� table.setPadding(2);� table.setBorderColor(Color.WHITE);� Table table = new Table(1);� def.setBorderColor(Color.WHITE);� Cell def = new Cell();� DecimalFormat df = new DecimalFormat("##.##");� try {� {� public void printStats(double[] stats)�� }� }� if (Debug.debug) Debug.print(De);� } catch (DocumentException De) {� out.close();� doc.close();� doc cellcount = 0;� }� stopcell();� handstruct.addCell(" ");� cellcount = 0;� }� stopcell();� handstruct.addCell(" ");� startcell();� while (0 != cellcount % 3) {� if (incell) stopcell();� {� public void stopfulltable() throws DocumentException�� }� }� if (Debug.debug) Debug.print(De);�ad�� ��} ������������������x��X��A��@����D�� ��J ��2 �� �� �� �� �� �� �� �� �� �� ��# �� �� ��~ ��} ��u �� �� �� ��Q ��< �� �� �� �� �� ��5 �� �� �� ��v ��q ��& �� ����}��g��b��������l��V��Q��������[��E��@��#�� ������������h��c��7��������������y��W��9��"��������b��M��������d��O��������������������������������� table.addCell(c);� c.setHorizontalAlignment(Cell.ALIGN_RIGHT);� c = new Cell(new Phrase(""+points[WEST], new Font(Font.HELVETICA, 6, Font.NORMAL)));� table.addCell(c);� c = new Cell(new Phrase("", new Font(Font.HELVETICA, 6, Font.NORMAL)));� table.addCell(c);� c.setHorizontalAlignment(Cell.ALIGN_CENTER);� c = new Cell(new Phrase(""+points[NORTH], new Font(Font.HELVETICA, 6, Font.NORMAL)));� table.addCell(c);� c = new Cell(new Phrase("", new Font(Font.HELVETICA, 6, Font.NORMAL)));� table.addCell(c);� c.setColspan(3);� c = new Cell(new Phrase(" ", new Font(Font.HELVETICA, 6, Font.NORMAL)));� table.endHeaders();� table.setDefaultLayout(c);� c.setBorderColor(Color.WHITE);� Cell c = new Cell();� table.setPadding(0);� table.setBorderColor(Color.WHITE);� Table table = new Table(3);� try {� if (!incell) startcell();*/� if (!inrow) startrow(6);� /*if (!infulltable) startfulltable();� {� public void printPoints(byte[] points)� }� }� if (Debug.debug) Debug.print(De);� } catch (DocumentException De) {� handstruct.addCell(r, 2, 2);� r.setWidth("100");� Cell r = new Cell(table);� }� table.addCell(c);� c.setHorizontalAlignment(Cell.ALIGN_CENTER);� c = new Cell(new Phrase(""+tricks[i], new Font(Font.HELVETICA, 5, Font.NORMAL)));� for (int i = 19; i >= 15; i--) {� table.addCell(new Phrase("W", new Font(Font.HELVETICA, 5, Font.BOLD)));� }� table.addCell(c);� c.setHorizontalAlignment(Cell.ALIGN_CENTER);� c = new Cell(new Phrase(""+tricks[i], new Font(Font.HELVETICA, 5, Font.NORMAL)));� for (int i = 14; i >= 10; i--) {� table.addCell(new Phrase("E", new Font(Font.HELVETICA, 5, Font.BOLD)));� }� table.addCell(c);� c.setHorizontalAlignment(Cell.ALIGN_CENTER);� c = new Cell(new Phrase(""+tricks[i], new Font(Font.HELVETICA, 5, Font.NORMAL)));� for (int i = 9; i >= 5; i--) {� table.addCell(new Phrase("S", new Font(Font.HELVETICA, 5, Font.BOLD)));� }� table.addCell(c);� c.setHorizontalAlignment(Cell.ALIGN_CENTER);� c = new Cell(new Phrase(""+tricks[i], new Font(Font.HELVETICA, 5, Font.NORMAL)));� for (int i = 4; i >= 0; i--) {� table.addCell(new Phrase("N", new Font(Font.HELVETICA, 5, ���� � s� struct.addCell(c);� c = new Cell(table);� table.addCell(new Phrase("East-West slams: "+(int)stats[STAT_NSSLAMS], new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("North-South slams: "+(int)stats[STAT_NSSLAMS], new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("East-West games: "+(int)stats[STAT_NSGAMES], new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("North-South games: "+(int)stats[STAT_NSGAMES], new Font(Font.HELVETICA, 10, Font.NORMAL)));�� table.endHeaders();� table.setDefaultLayout(def);� table.setPadding(2);� table.setBorderColor(Color.WHITE);� table = new Table(1);�� struct.addCell(c);� c = new Cell(table);� table.addCell(new Phrase("West avg points: "+df.format(stats[STAT_WPOINTS]), new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("East avg points: "+df.format(stats[STAT_EPOINTS]), new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("South avg points: "+df.format(stats[STAT_SPOINTS]), new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("North avg points: "+df.format(stats[STAT_NPOINTS]), new Font(Font.HELVETICA, 10, Font.NORMAL)));�� table.endHeaders();� table.setDefaultLayout(def);� table.setPadding(2);� table.setBorderColor(Color.WHITE);� table = new Table(1);�;�� struct.addCell(c);� c = new Cell(table);�ad��Q������� �����������y��^��0�� ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� Cell c = new Cell(new Phrase(""+num, new Font(Font.HELVETICA, 12, Font.BOLD)));� String[] printablehand = getHandPrintables(hand, SHORTSUIT);� startcell();� if (1 != num && 1 == num % 21) newpage();� if (incell) stopcell();� if (!inrow) startrow(6);*/� /*if (!infulltable) startfulltable();� try {� {� public void printHand(int num, byte[][] hand)�ad������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� } }� }�ad��{�������<�������������������^��J��:��*������������������e��@��?��%������� �� �� �� ��l ��k �� �� �� �� �� ��j ��i ��P ��* �� �� �� �� ��l �� �� �� �� ������������v��_��^������o����p��X����h����x��w��`��@��(������������8����=����������o��I���������������������������������������������������������������������������������������������������������������������������������������������������������������������� table.addCell(new Phras table.addCell(new Phrase( table.addCell(new Phrase("# Bacon h table.addCell(new Phr table.addCell(new Phrase("# B table.addCell(new Ph table.addCell(new Phrase("# Bacon hands: "+(int)stats[STAT_BACON], new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.ad table.addCell(new Phrase("# Bacon hands: "+(int)stats[STAT_BACON], new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.ad table.addCell(new Phrase("# Bacon hands: "+(int)stats[STAT_BACON], new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.a table.addCell(new Phrase("# Bacon hands: "+(int)stats[STAT_BACON], new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.a table.addCell(new Phrase(" table.addCell(new P table.addCell(new Phra table.addCell(new Phrase("# Bacon h table.addCell(new Phr table.addCell(new Phrase("# B table.addCell(new Ph table.addCell(new Phrase("# Bacon hands: "+(int)stats[STAT_BACON], new Font(Font.HELVETICA, 10, Font.NORMAL)));� tab table.addCell(new Phrase("# Bacon hands: "+(int)stats[STAT_BACON], new Font(Font.HELVETICA, 10, Font.NORMAL)));� t table.addCell(new Phrase("# Bacon hands: "+(int)stats[STAT_BACON], new Font(Font.HELVETICA, 10, Font.NORMAL)));� tab table.addCell(new Phrase("# Bacon hands: "+(int)stats[STAT_BACON], new Font(Font.HELVETICA, 10, Font.NORMAL)));� t table.addCell(new Ph table.addCell table.addCell(new Phrase("# Bacon hands: "+(int)stats[STAT_BACON], new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("# Voids: "+(int)stats[STAT_VOID], new Font(Font.HELVETICA, 10, Font.NORMAL)));�� table.endHeaders();� table.setDefaultLayout(def);� table.setPadding(2);� table.setBorderColor(Color.WHITE);� table = new Table(1);�� struct.addCell(c);� c = new Cell(table);� table.addCell(new Phrase("# 8+ suits: "+(int)stats[STAT_8PLUS], new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("# 7+ suits: "+(int)stats[STAT_7PLUS], new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("# 6+ suits: "+(int)stats[STAT_6PLUS], new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("# 5-5 hands: "+(int)stats[STAT_55], new Font(Font.HELVETICA, 10, Font.NORMAL)));�� table.endHeaders();� table.setDefaultLayout(def);� table.setPadding(2);� table.setBorderColor(Color.WHITE);� table = new Table(1);�� struct.addCell(c);� Cell c = new Cell(table);� table.addCell(new Phrase("# 4441 hands: "+(int)stats[STAT_4441], new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("# Semi-bal hands: "+(int)stats[STAT_SEMIBAL], new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("# Balanced hands: "+(int)stats[STAT_BAL], new Font(Font.HELVETICA, 10, Font.NORMAL)));� table.addCell(new Phrase("# 4333 hands: "+(int)stats[STAT_4333], new Font(Font.HELVETICA, 10, Font.NORMAL)));�� table.endHeaders();� table.setDefaultLayout(def);� table.setPadding(2);� table.setBorderColor(Color.WHITE);� Table table = new Table(1);�� def.setBorderColor(Color.WHITE);� Cell def = new Cell();�� if (infulltable) stopfulltable();� DecimalFormat df = new DecimalFormat("##.##");� try {� {� public void printStats(double[] stats)�� }� }� if (Debug.debug) Debug.print(De);� } catch (DocumentException De) {� out.close();� doc.close();� doc.add(struct);� if (infulltable) stopfulltable();� try {� if (inrow) stoprow();*/� /*if (incell) stopcell();� {� public void close()�� }� infulltable = false;�ad��`��������\�������������|��w��K��-�� ������������l��N���� ��s ��^ �� �� �� ��W ��' �� �� �� ��m �� �� �� �� �� ��f ��D �� �� �� �� ��W ��5 ����������H��$����������7��������v��q��T��>����������������h��I��'���������������j��S����������~��%����������(��������������������������������������������������������������������������������������������������� table.addCell(c);� c.setHorizontalAlignment(Cell.ALIGN_RIGHT);� c = new Cell(new Phrase(""+points[WEST], new Font(Font.HELVETICA, 6, Font.NORMAL)));� table.addCell(c);� c = new Cell(new Phrase("", new Font(Font.HELVETICA, 6, Font.NORMAL)));� table.addCell(c);� c.setHorizontalAlignment(Cell.ALIGN_CENTER);� c = new Cell(new Phrase(""+points[NORTH], new Font(Font.HELVETICA, 6, Font.NORMAL)));� table.addCell(c);� c = new Cell(new Phrase("", new Font(Font.HELVETICA, 6, Font.NORMAL)));� table.addCell(c);� c.setColspan(3);� c = new Cell(new Phrase(" ", new Font(Font.HELVETICA, 6, Font.NORMAL)));� table.endHeaders();� table.setDefaultLayout(c);� c.setBorderColor(Color.WHITE);� Cell c = new Cell();� table.setPadding(0);� table.setBorderColor(Color.WHITE);� Table table = new Table(3);� try {� if (!incell) startcell();*/� if (!inrow) startrow(6);� /*if (!infulltable) startfulltable();� {� public void printPoints(byte[] points)� }� }� if (Debug.debug) Debug.print(De);� } catch (DocumentException De) {� handstruct.addCell(r, 2, 2);� r.setWidth("100");� Cell r = new Cell(table);� }� table.addCell(c);� c.setHorizontalAlignment(Cell.ALIGN_CENTER);� c = new Cell(new Phrase(""+tricks[i], new Font(Font.HELVETICA, 5, Font.NORMAL)));� for (int i = 19; i >= 15; i--) {� table.addCell(new Phrase("W", new Font(Font.HELVETICA, 5, Font.BOLD)));� }� table.addCell(c);� c.setHorizontalAlignment(Cell.ALIGN_CENTER);� c = new Cell(new Phrase(""+tricks[i], new Font(Font.HELVETICA, 5, Font.NORMAL)));� for (int i = 14; i >= 10; i--) {� table.addCell(new Phrase("E", new Font(Font.HELVETICA, 5, Font.BOLD)));� }� table.addCell(c);� c.setHorizontalAlignment(Cell.ALIGN_CENTER);� c = new Cell(new Phrase(""+tricks[i], new Font(Font.HELVETICA, 5, Font.NORMAL)));� for (int i = 9; i >= 5; i--) {� table.addCell(new Phrase("S", new Font(Font.HELVETICA, 5, Font.BOLD)));� }� table.addCell(c);� c.setHorizontalAlignment(Cell.ALIGN_CENTER);� c = new Cell(new Phrase(""+tricks[i], new Font(Font.HELVETICA, 5, Font.NORMAL)));� for (int i = 4; i >= 0; i--) {� table.addCell(new Phrase("N", new Font(Font.HELVETICA, 5, Font.BOLD)));�� table.endHeaders();� table.addCell(c);� c.setHorizontalAlignment(Cell.ALIGN_CENTER);� c = new Cell(new Phrase(""+DINGSUIT[NOTRUMPS>>4], new Font(Font.HELVETICA, 6, Font.BOLD)));� table.addCell(c);� c.setHorizontalAlignment(Cell.ALIGN_CENTER);� c = new Cell(new Phrase(""+DINGSUIT[SPADES>>4], new Font(Font.ZAPFDINGBATS, 6, Font.BOLD)));� table.addCell(c);� c.setHorizontalAlignment(Cell.ALIGN_CENTER);� c = new Cell(new Phrase(""+DINGSUIT[HEARTS>>4], new Font(Font.ZAPFDINGBATS, 6, Font.BOLD)));� table.addCell(c);� c.setHorizontalAlignment(Cell.ALIGN_CENTER);� c = new Cell(new Phrase(""+DINGSUIT[DIAMONDS>>4], new Font(Font.ZAPFDINGBATS, 6, Font.BOLD)));� table.addCell(c);� c.setHorizontalAlignment(Cell.ALIGN_CENTER);� c = new Cell(new Phrase(""+DINGSUIT[CLUBS>>4], new Font(Font.ZAPFDINGBATS, 6, Font.BOLD)));� table.addCell(new Phrase("", new Font(Font.HELVETICA, 6, Font.NORMAL)));� table.setDefaultLayout(c);� c.setBorderColor(Color.WHITE);� Cell c = new Cell();� table.setPadding(0);� table.setBorderColor(Color.WHITE);� Table table = new Table(6);� try {� if (!incell) startcell();*/� if (!inrow) startrow();� /*if (!infulltable) startfulltable();� {� public void printTricks(byte[] tricks)�� }� }� if (Debug.debug) Debug.print(De);� } catch (DocumentException De) {�pescetti-0.5/cx/ath/matthew/pescetti/PDFPrinter.java������������������������������������������������0000644�0001750�0001750�00000037420�11303202176�021146� 0����������������������������������������������������������������������������������������������������ustar �mjj29���������������������������mjj29������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * Pescetti Pseudo-Duplimate Generator * * Copyright (C) 2007 Matthew Johnson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License Version 2 as published by * the Free Software Foundation. This program is distributed in the hope that * it will be useful, but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. You should have received a * copy of the GNU General Public License along with this program; if not, * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * To Contact me, please email src@matthew.ath.cx * */ package cx.ath.matthew.pescetti; import com.lowagie.text.Cell; import com.lowagie.text.Chunk; import com.lowagie.text.DocumentException; import com.lowagie.text.Document; import com.lowagie.text.Font; import com.lowagie.text.PageSize; import com.lowagie.text.Paragraph; import com.lowagie.text.Phrase; import com.lowagie.text.Table; import com.lowagie.text.pdf.PdfWriter; import cx.ath.matthew.debug.Debug; import java.awt.Color; import java.io.PrintStream; import java.text.DecimalFormat; public class PDFPrinter extends Printer implements Constants { private PrintStream out; private boolean infulltable = true; /*private boolean inrow = false;*/ private boolean incell = false; private int cellcount = 0; private static final int MAXCELLS = 3; private Document doc; private Table struct; private Table handstruct; private String header; public PDFPrinter(PrintStream out, String header) { try { this.out = out; this.doc = new Document(PageSize.A4, 20,20,30,30); PdfWriter.getInstance(doc, out); doc.addTitle(header); doc.open(); Paragraph head = new Paragraph(header, new Font(Font.HELVETICA, 16, Font.BOLD)); head.setSpacingAfter(-20); doc.add(head); struct = new Table(MAXCELLS); struct.setWidth(100); struct.setBorderColor(Color.WHITE); Cell c = new Cell(); c.setBorderColor(Color.BLACK); struct.setDefaultLayout(c); this.header = header; } catch (DocumentException De) { if (Debug.debug) Debug.print(De); } } void newpage() throws DocumentException { if (infulltable) stopfulltable(); doc.add(struct); doc.newPage(); Paragraph head = new Paragraph(header, new Font(Font.HELVETICA, 16, Font.BOLD)); head.setSpacingAfter(-20); doc.add(head); struct = new Table(MAXCELLS); struct.setWidth(100); struct.setBorderColor(Color.WHITE); Cell c = new Cell(); c.setBorderColor(Color.BLACK); struct.setDefaultLayout(c); infulltable = true; } void stopcell() throws DocumentException { struct.insertTable(handstruct); incell = false; } void startcell() throws DocumentException { handstruct = new Table(3,3); handstruct.setWidth(100); handstruct.setBorderColor(new Color(0, 0, 0)); handstruct.setBorderWidth(1); Cell c = new Cell(); c.setBorderColor(Color.WHITE); handstruct.setDefaultLayout(c); incell = true; cellcount++; } char getDingSuit(char suit) { switch (suit) { case 'C': return (char) 168; case 'D': return (char) 169; case 'H': return (char) 170; case 'S': return (char) 171; default: return ' '; } } public void printHand(int num, byte[][] hand) { try { /*if (!infulltable) startfulltable(); if (!inrow) startrow(6);*/ if (incell) stopcell(); if (1 != num && 1 == num % 21) newpage(); startcell(); String[] printablehand = getHandPrintables(hand, SHORTSUIT); Cell c = new Cell(new Phrase(""+num, new Font(Font.HELVETICA, 12, Font.BOLD))); c.setHorizontalAlignment(Cell.ALIGN_CENTER); handstruct.addCell(c, 0, 0); StringBuilder vuln = new StringBuilder(); vuln.append("Dlr: "); switch (num % 4) { case 1: vuln.append(PLAYER[NORTH]); break; case 2: vuln.append(PLAYER[EAST]); break; case 3: vuln.append(PLAYER[SOUTH]); break; case 0: vuln.append(PLAYER[WEST]); break; } vuln.append("\nVuln: "); switch (num % 16) { // ALL case 4: case 7: case 10: case 13: vuln.append("ALL"); break; // N-S case 2: case 5: case 12: case 15: vuln.append("N-S"); break; // E-W case 3: case 6: case 9: case 0: vuln.append("E-W"); break; // NONE default: vuln.append("NONE"); } handstruct.addCell(new Cell(new Phrase(vuln.toString(), new Font(Font.HELVETICA, 8, Font.NORMAL))), 0, 2); Font DINGFONT = new Font(Font.ZAPFDINGBATS, 7, Font.NORMAL); Font HEL = new Font(Font.HELVETICA, 7, Font.NORMAL); // 0 // 3 1 // 2 // NORTH; Phrase handstr = new Phrase(8); for (int i = 0; i < 4; i++) { char suit = getDingSuit(printablehand[i].charAt(0)); handstr.add(new Chunk(""+suit, DINGFONT)); handstr.add(new Chunk(printablehand[i].substring(1), HEL)); handstr.add(new Chunk("\n", HEL)); } c = new Cell(handstr); c.setHorizontalAlignment(Cell.ALIGN_LEFT); handstruct.addCell(c, 0, 1); // WEST handstr = new Phrase(8); for (int i = 4; i < 8; i++) { char suit = getDingSuit(printablehand[i].charAt(0)); handstr.add(new Chunk(" "+suit, DINGFONT)); handstr.add(new Chunk(printablehand[i].substring(1), HEL)); handstr.add(new Chunk("\n", HEL)); } c = new Cell(handstr); c.setHorizontalAlignment(Cell.ALIGN_LEFT); handstruct.addCell(c, 1, 0); handstruct.addCell(new Cell(), 1, 1); // EAST handstr = new Phrase(8); for (int i = 8; i < 12; i++) { char suit = getDingSuit(printablehand[i].charAt(0)); handstr.add(new Chunk(""+suit, DINGFONT)); handstr.add(new Chunk(printablehand[i].substring(1), HEL)); handstr.add(new Chunk("\n", HEL)); } c = new Cell(handstr); c.setHorizontalAlignment(Cell.ALIGN_LEFT); handstruct.addCell(c, 1, 2); // SOUTH handstr = new Phrase(8); for (int i = 12; i < 16; i++) { char suit = getDingSuit(printablehand[i].charAt(0)); handstr.add(new Chunk(""+suit, DINGFONT)); handstr.add(new Chunk(printablehand[i].substring(1), HEL)); handstr.add(new Chunk("\n", HEL)); } c = new Cell(handstr); c.setHorizontalAlignment(Cell.ALIGN_LEFT); handstruct.addCell(c, 2, 1); } catch (DocumentException De) { if (Debug.debug) Debug.print(De); } } public void printCurtains(int num, byte[][] hand){} public void printCurtainBack(int num){} public void printPermutation1(int num, byte[][] perm){} public void printPermutation(int permnum, int boardnum, byte[] perm, byte[] initperm) { try { Cell c = new Cell(new Phrase("Board "+boardnum+" permutation "+permnum, new Font(Font.HELVETICA, 12, Font.BOLD))); c.setColspan(MAXCELLS); struct.addCell(c); StringBuilder sb; if (null != initperm) { sb = new StringBuilder(); sb.append("Order the suits: "); for (int i = 0; i < 4; i++) { sb.append(LONGSUIT[initperm[i] >> 4]); if (i < 3) sb.append(", "); } c = new Cell(new Phrase(sb.toString(), new Font(Font.HELVETICA, 10, Font.BOLD))); c.setColspan(MAXCELLS); struct.addCell(c); } sb = new StringBuilder(); for (int k = 0; k < 52; k++) { sb.append(""+(perm[k]+1)); if (3 == k % 4) sb.append(" "); if (19 == k % 20) sb.append("\n"); } c = new Cell(new Phrase(sb.toString(), new Font(Font.HELVETICA, 14, Font.NORMAL))); c.setColspan(MAXCELLS); struct.addCell(c); if (2 == permnum && 2 == boardnum % 4) newpage(); } catch (DocumentException De) { if (Debug.debug) Debug.print(De); } } public void stopfulltable() throws DocumentException { if (incell) stopcell(); while (0 != cellcount % 3) { startcell(); handstruct.addCell(" "); stopcell(); } cellcount = 0; infulltable = false; } public void close() { /*if (incell) stopcell(); if (inrow) stoprow();*/ try { if (infulltable) stopfulltable(); doc.add(struct); doc.close(); out.close(); } catch (DocumentException De) { if (Debug.debug) Debug.print(De); } } public void printStats(double[] stats) { try { DecimalFormat df = new DecimalFormat("##.##"); if (infulltable) stopfulltable(); Cell def = new Cell(); def.setBorderColor(Color.WHITE); Table table = new Table(1); table.setBorderColor(Color.WHITE); table.setPadding(2); table.setDefaultLayout(def); table.endHeaders(); table.addCell(new Phrase("# 4333 hands: "+(int)stats[STAT_4333], new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("# Balanced hands: "+(int)stats[STAT_BAL], new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("# Semi-bal hands: "+(int)stats[STAT_SEMIBAL], new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("# 4441 hands: "+(int)stats[STAT_4441], new Font(Font.HELVETICA, 10, Font.NORMAL))); Cell c = new Cell(table); struct.addCell(c); table = new Table(1); table.setBorderColor(Color.WHITE); table.setPadding(2); table.setDefaultLayout(def); table.endHeaders(); table.addCell(new Phrase("# 5-5 hands: "+(int)stats[STAT_55], new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("# 6+ suits: "+(int)stats[STAT_6PLUS], new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("# 7+ suits: "+(int)stats[STAT_7PLUS], new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("# 8+ suits: "+(int)stats[STAT_8PLUS], new Font(Font.HELVETICA, 10, Font.NORMAL))); c = new Cell(table); struct.addCell(c); table = new Table(1); table.setBorderColor(Color.WHITE); table.setPadding(2); table.setDefaultLayout(def); table.endHeaders(); table.addCell(new Phrase("# Voids: "+(int)stats[STAT_VOID], new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("# Bacon hands: "+(int)stats[STAT_BACON], new Font(Font.HELVETICA, 10, Font.NORMAL))); c = new Cell(table); struct.addCell(c); table = new Table(1); table.setBorderColor(Color.WHITE); table.setPadding(2); table.setDefaultLayout(def); table.endHeaders(); table.addCell(new Phrase("North avg points: "+df.format(stats[STAT_NPOINTS]), new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("South avg points: "+df.format(stats[STAT_SPOINTS]), new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("East avg points: "+df.format(stats[STAT_EPOINTS]), new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("West avg points: "+df.format(stats[STAT_WPOINTS]), new Font(Font.HELVETICA, 10, Font.NORMAL))); c = new Cell(table); struct.addCell(c); table = new Table(1); table.setBorderColor(Color.WHITE); table.setPadding(2); table.setDefaultLayout(def); table.endHeaders(); table.addCell(new Phrase("North-South games: "+(int)stats[STAT_NSGAMES], new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("East-West games: "+(int)stats[STAT_NSGAMES], new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("North-South slams: "+(int)stats[STAT_NSSLAMS], new Font(Font.HELVETICA, 10, Font.NORMAL))); table.addCell(new Phrase("East-West slams: "+(int)stats[STAT_NSSLAMS], new Font(Font.HELVETICA, 10, Font.NORMAL))); c = new Cell(table); struct.addCell(c); } catch (DocumentException De) { if (Debug.debug) Debug.print(De); } } public void printTricks(byte[] tricks) { /*if (!infulltable) startfulltable(); if (!inrow) startrow(); if (!incell) startcell();*/ try { Table table = new Table(6); table.setBorderColor(Color.WHITE); table.setPadding(0); Cell c = new Cell(); c.setBorderColor(Color.WHITE); table.setDefaultLayout(c); table.addCell(new Phrase("", new Font(Font.HELVETICA, 6, Font.NORMAL))); c = new Cell(new Phrase(""+DINGSUIT[CLUBS>>4], new Font(Font.ZAPFDINGBATS, 6, Font.BOLD))); c.setHorizontalAlignment(Cell.ALIGN_CENTER); table.addCell(c); c = new Cell(new Phrase(""+DINGSUIT[DIAMONDS>>4], new Font(Font.ZAPFDINGBATS, 6, Font.BOLD))); c.setHorizontalAlignment(Cell.ALIGN_CENTER); table.addCell(c); c = new Cell(new Phrase(""+DINGSUIT[HEARTS>>4], new Font(Font.ZAPFDINGBATS, 6, Font.BOLD))); c.setHorizontalAlignment(Cell.ALIGN_CENTER); table.addCell(c); c = new Cell(new Phrase(""+DINGSUIT[SPADES>>4], new Font(Font.ZAPFDINGBATS, 6, Font.BOLD))); c.setHorizontalAlignment(Cell.ALIGN_CENTER); table.addCell(c); c = new Cell(new Phrase(""+DINGSUIT[NOTRUMPS>>4], new Font(Font.HELVETICA, 6, Font.BOLD))); c.setHorizontalAlignment(Cell.ALIGN_CENTER); table.addCell(c); table.endHeaders(); table.addCell(new Phrase("N", new Font(Font.HELVETICA, 5, Font.BOLD))); for (int i = 4; i >= 0; i--) { c = new Cell(new Phrase(""+tricks[i], new Font(Font.HELVETICA, 5, Font.NORMAL))); c.setHorizontalAlignment(Cell.ALIGN_CENTER); table.addCell(c); } table.addCell(new Phrase("S", new Font(Font.HELVETICA, 5, Font.BOLD))); for (int i = 9; i >= 5; i--) { c = new Cell(new Phrase(""+tricks[i], new Font(Font.HELVETICA, 5, Font.NORMAL))); c.setHorizontalAlignment(Cell.ALIGN_CENTER); table.addCell(c); } table.addCell(new Phrase("E", new Font(Font.HELVETICA, 5, Font.BOLD))); for (int i = 14; i >= 10; i--) { c = new Cell(new Phrase(""+tricks[i], new Font(Font.HELVETICA, 5, Font.NORMAL))); c.setHorizontalAlignment(Cell.ALIGN_CENTER); table.addCell(c); } table.addCell(new Phrase("W", new Font(Font.HELVETICA, 5, Font.BOLD))); for (int i = 19; i >= 15; i--) { c = new Cell(new Phrase(""+tricks[i], new Font(Font.HELVETICA, 5, Font.NORMAL))); c.setHorizontalAlignment(Cell.ALIGN_CENTER); table.addCell(c); } Cell r = new Cell(table); r.setWidth("100"); handstruct.addCell(r, 2, 2); } catch (DocumentException De) { if (Debug.debug) Debug.print(De); } } public void printPoints(byte[] points) { /*if (!infulltable) startfulltable(); if (!inrow) startrow(6); if (!incell) startcell();*/ try { Table table = new Table(3); table.setBorderColor(Color.WHITE); table.setPadding(0); Cell c = new Cell(); c.setBorderColor(Color.WHITE); table.setDefaultLayout(c); table.endHeaders(); c = new Cell(new Phrase(" ", new Font(Font.HELVETICA, 6, Font.NORMAL))); c.setColspan(3); table.addCell(c); c = new Cell(new Phrase("", new Font(Font.HELVETICA, 6, Font.NORMAL))); table.addCell(c); c = new Cell(new Phrase(""+points[NORTH], new Font(Font.HELVETICA, 6, Font.NORMAL))); c.setHorizontalAlignment(Cell.ALIGN_CENTER); table.addCell(c); c = new Cell(new Phrase("", new Font(Font.HELVETICA, 6, Font.NORMAL))); table.addCell(c); c = new Cell(new Phrase(""+points[WEST], new Font(Font.HELVETICA, 6, Font.NORMAL))); c.setHorizontalAlignment(Cell.ALIGN_RIGHT); table.addCell(c); c = new Cell(new Phrase("", new Font(Font.HELVETICA, 6, Font.NORMAL))); table.addCell(c); c = new Cell(new Phrase(""+points[EAST], new Font(Font.HELVETICA, 6, Font.NORMAL))); c.setHorizontalAlignment(Cell.ALIGN_LEFT); table.addCell(c); c = new Cell(new Phrase("", new Font(Font.HELVETICA, 6, Font.NORMAL))); table.addCell(c); c = new Cell(new Phrase(""+points[SOUTH], new Font(Font.HELVETICA, 6, Font.NORMAL))); c.setHorizontalAlignment(Cell.ALIGN_CENTER); table.addCell(c); c = new Cell(new Phrase("", new Font(Font.HELVETICA, 6, Font.NORMAL))); table.addCell(c); Cell r = new Cell(table); r.setVerticalAlignment(Cell.ALIGN_MIDDLE); handstruct.addCell(r, 2, 0); } catch (DocumentException De) { if (Debug.debug) Debug.print(De); } } public void println(String s) { } public void print(String s) { } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������pescetti-0.5/README���������������������������������������������������������������������������������0000644�0001750�0001750�00000000440�10765746034�012540� 0����������������������������������������������������������������������������������������������������ustar �mjj29���������������������������mjj29������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������Pescetti Pseudo-Duplimate Generator ----------------------------------- Pescetti generates dealing sheets for pseudo-duplimating boards from a computer-dealt source. Pescetti will also generate deals for you, and export them in a suitable form to be read by the dds double-dummy solver. ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������pescetti-0.5/INSTALL��������������������������������������������������������������������������������0000644�0001750�0001750�00000001240�10765746034�012710� 0����������������������������������������������������������������������������������������������������ustar �mjj29���������������������������mjj29������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������Installation Instructions ------------------------- To build pescetti you will need a 1.5 compatible Java compiler with at least 1.4 compatible java libraries, libmatthew-debug-java (http://www.matthew.ath.cx/projects/java/) and libitext-java (http://www.lowagie.com/iText/). You will also need GNU gettext installed. To build: make all To install: make install Both of these can be modified by setting variables. See the Makefile for more details, but the most likely ones to be changed are: PREFIX = install prefix JAVAC = Java compiler JAVA = Java VM CLASSPATH = path to libmatthew-debug-java and libitext DEBUG = enable to enable debugging ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������pescetti-0.5/COPYING��������������������������������������������������������������������������������0000644�0001750�0001750�00000043102�10702654734�012711� 0����������������������������������������������������������������������������������������������������ustar �mjj29���������������������������mjj29������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. <signature of Ty Coon>, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������pescetti-0.5/changelog������������������������������������������������������������������������������0000644�0001750�0001750�00000001546�11300060176�013520� 0����������������������������������������������������������������������������������������������������ustar �mjj29���������������������������mjj29������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������Version 0.5: * Add PDF output Version 0.4: * Add a probability value to each criteria so you can value some more highly * Add self balancing to weird shape criteria * Add points grid to HTML output * Tidy up some warnings Version 0.3: * Add script to convert PBN files to DDS files * Add program to convert DUP files to DDS files (maybe faulty?) * Add more general hand-criteria to generator Version 0.2: * Output analysis * Separate dds or combined output * Load analysis * Weird hands generator * More stats * Specify types of weirdness * Only initialize PRNG once Version 0.1: * Initial support for deal generating, dealing sheet generating and dds export * Pretty-print boards and permutations * Run DDS analyzer * Generate stats about the hands * HTML output * Curtain cards * How-to document for dealing * Interleave perm1/2 ����������������������������������������������������������������������������������������������������������������������������������������������������������pescetti-0.5/pescetti.sh����������������������������������������������������������������������������0000644�0001750�0001750�00000000163�10702655764�014036� 0����������������������������������������������������������������������������������������������������ustar �mjj29���������������������������mjj29������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/bin/sh -- JAVA=%JAVA% VERSION=%VERSION% JARPATH=%JARPATH% exec $JAVA -jar $JARPATH/pescetti-$VERSION.jar "$@" �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������pescetti-0.5/pescetti.sgml��������������������������������������������������������������������������0000664�0001750�0001750�00000017115�11306704657�014372� 0����������������������������������������������������������������������������������������������������ustar �mjj29���������������������������mjj29������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [ <!-- Process this file with docbook-to-man to generate an nroff manual page: `docbook-to-man manpage.sgml > manpage.1'. You may view the manual page with: `docbook-to-man manpage.sgml | nroff -man | less'. A typical entry in a Makefile or Makefile.am is: manpage.1: manpage.sgml docbook-to-man $< > $@ The docbook-to-man binary is found in the docbook-to-man package. Please remember that if you create the nroff version in one of the debian/rules file targets (such as build), you will need to include docbook-to-man in your Build-Depends control field. --> <!-- Fill in your name for FIRSTNAME and SURNAME. --> <!ENTITY dhfirstname "<firstname>Matthew</firstname>"> <!ENTITY dhsurname "<surname>Johnson</surname>"> <!-- Please adjust the date whenever revising the manpage. --> <!ENTITY dhdate "<date>April 28, 2007</date>"> <!-- SECTION should be 1-8, maybe w/ subsection other parameters are allowed: see man(7), man(1). --> <!ENTITY dhsection "<manvolnum>1</manvolnum>"> <!ENTITY dhemail "<email><debian@matthew.ath.cx></email>"> <!ENTITY dhusername "Matthew Johnson"> <!ENTITY dhucpackage "<refentrytitle>PESCETTI</refentrytitle>"> <!ENTITY dhpackage "pescetti"> <!ENTITY debian "<productname>Debian</productname>"> <!ENTITY gnu "<acronym>GNU</acronym>"> <!ENTITY gpl "&gnu; <acronym>GPL</acronym>"> ]> <refentry> <refentryinfo> <address> &dhemail; </address> <author> &dhfirstname; &dhsurname; </author> <copyright> <year>2007</year> <holder>&dhusername;</holder> </copyright> &dhdate; </refentryinfo> <refmeta> &dhucpackage; &dhsection; </refmeta> <refnamediv> <refname>&dhpackage;</refname> <refpurpose>Pseudo-Duplimate Generator</refpurpose> </refnamediv> <refsynopsisdiv> <cmdsynopsis> <command>&dhpackage;</command> </cmdsynopsis> </refsynopsisdiv> <refsect1> <title>DESCRIPTION This manual page documents briefly the &dhpackage; command. OPTIONS Here are a list of the available options and what they do. You must specify exactly one from --demo, --generate or --load. --help Prints the help text --demo Demonstration mode. Generates one hand with permutations and the tutorial for how to use them. --generate=N Generate N random boards --load=boards.txt Load boards+analysis from boards.txt --load-dds=boards.dds Load boards from boards.dds in dds format --load-analysis=tricks.txt Load analysis from tricks.txt --permutations=permutations.txt Generate the permutations and save them to the given file --curtains=curtains.txt Save curtain cards to file curtains.txt --save=boards.txt Save the boards+analysis to boards.txt --save-dds=boards.dds Save the boards to boards.dds in dds format --save-analysis=tricks.txt Save the analysis to tricks.txt --format=html|txt|pdf Set the output mode to the given format --title=title Set the title for the output --output=hands.txt Print the hands to hands.txt, rather than to standard output --stats Generate statistics about the set of boards; included in the hands output --analyze Run the dds analyzer on the boards and print the resulting numberof tricks (warning SLOW) --criteria="criteria..." A list of criteria to apply to each generated hand to generate specific hand types. The list should be space separated and each item may be suffixed with a colon and a (fractional) probability value which can be used to weight the criteria. E.g. --criteria="weaknt:0.8 strongnt:0.5" Valid criteria are: unbalanced weaknt strongnt twont strongtwo weaktwo three twoclubs 4441 singlesuit twosuits partscore game slam game-invite slam-invite jumpshift jumpfit splinter bacon weird --probability=factor Generate hands matching the criteria with only the given probability. Factor is in the range 0 to 1. On each attempt to generate a board it is rejected if it doesn't match the criteria with the given probability. A factor of about 0.8 gives roughly half matching boards AUTHOR This manual page was written by &dhusername; &dhemail;. Permission is granted to copy, distribute and/or modify this document under the terms of the &gnu; General Public License, Version 2 as published by the Free Software Foundation. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. pescetti-0.5/Manifest.txt.in0000644000175000017500000000017710702655173014575 0ustar mjj29mjj29Name: cx/ath/matthew/pescetti Implementation-Title: Pescetti Pseudo-Duplimate Generator Implementation-Vendor: Matthew Johnson pescetti-0.5/dealing-howto.tex0000664000175000017500000000557310710746154015152 0ustar mjj29mjj29\documentclass[a4paper,11pt]{article} \usepackage{times} \usepackage{fullpage} \setcounter{secnumdepth}{-2} \begin{document} \pagestyle{empty} \begin{centering} {\Large \bf Pescetti PseudoDuplimate Generator: Dealing How-to} \end{centering} \section{Before You Start} You should have a set of boards, two sets of permutations (each person should only have one of the permutations for any given board) and optionally a set of curtain cards. \section{Deck Setup} The packs of cards all need to be sorted before starting. Ensure that each suit is sorted in descending order. That is, such that the first card dealt is the Ace. The order of the suits will be given in the first permutation. \section{Dealing the First Permutation} The dealing sheet for the first permutation (each board will be labelled ``permutation 1'') will have for each board a list of the numbers 1 through 4. There are 13 of each number, 52 in total, arranged in groups of 4; two rows of 5 groups and one row of 3 groups. You should read across the top row from left to right, then across the second row from left to right, then the bottom row from left to right. First you will have to ensure that the deck is sorted as above. The first permutation will also give an order of the suits you need to start with. The first suit in the list should be the first suit which is dealt out, i.e. at the top. The first card dealt should be the ace of this suit. To deal the permutation, take the sorted deck and then for each number in order deal into that pile. For example,if the first group is {\bf 4233} you will deal the first card (this should be the Ace of first suit in the list) into pile 4, the second into pile two and then the 3rd and 4th (in that order) into pile 3. Continue with the second group on the first row and then in order until you have dealt all the cards into the four piles Next, take pile 1 and put it on top of pile 2. Then take the stack of both of them and put them on top of pile 3. Then take all of these and put the result on top of pile 4, getting to a complete deck again. Pass the deck onto the person doing the second permutation of this board. \section{Dealing the Second Permutation} The second permutation is very similar to the first. The dealing sheet will look the same, except that it will be labelled "permutation 2" by each board number and won't include the suit order. Take the deck from the person dealing the first permutation and {\it do not rearrange the cards in any way before starting}. Deal the cards as above into 4 piles by reading the dealing sheet in order. When you have finished, take hand 1 and put it in the board pocket for North. Insert the rest of the piles clockwise, that is pile 2 is East, 3 is South and 4 is West. Give each hand a quick shuffle before putting them into the pockets. If there are curtain cards then also add these to the board, without looking at them! \end{document} pescetti-0.5/translations/0000755000175000017500000000000010765746034014403 5ustar mjj29mjj29pescetti-0.5/translations/en_GB.po0000644000175000017500000000316511300062515015677 0ustar mjj29mjj29#java-format msgid "Cannot open file for output: " msgstr "Cannot open file for output: " msgid "Curtain Cards" msgstr "Curtain Cards" msgid "Error: unknown option " msgstr "Error: unknown option " msgid "Failed to DD analyze: " msgstr "Failed to DD analyze: " msgid "Failed to load analysis: " msgstr "Failed to load analysis: " msgid "Failed to load boards: " msgstr "Failed to load boards: " msgid "Failed to parse criteria: " msgstr "Failed to parse criteria: " msgid "Failed to parse number of boards to generate: " msgstr "Failed to parse number of boards to generate: " msgid "Failed to parse probability: " msgstr "Failed to parse probability: " msgid "Failed to save analysis: " msgstr "Failed to save analysis: " msgid "Failed to save boards: " msgstr "Failed to save boards: " msgid "Failed to save curtaincards: " msgstr "Failed to save curtaincards: " msgid "Failed to save permutations: " msgstr "Failed to save permutations: " msgid "Invalid format " msgstr "Invalid format " msgid "Must install dds double dummy analyzer to analyze hands" msgstr "Must install dds double dummy analyzer to analyze hands" msgid "Must --load, --load-analysis or --analyze to use --save" msgstr "Must --load, --load-analysis or --analyze to use --save" msgid "Must specify either --generate --load{,-dds} or --demo" msgstr "Must specify either --generate --load{,-dds} or --demo" msgid "Permutations" msgstr "Permutations" msgid "Usage: dup2dds " msgstr "Usage: dup2dds " msgid "You must specify --load, --load-analysis or --analyze to save the analysis" msgstr "You must specify --load, --load-analysis or --analyze to save the analysis" pescetti-0.5/dup2dds.sh0000644000175000017500000000016210765746034013562 0ustar mjj29mjj29#!/bin/sh -- JAVA=%JAVA% VERSION=%VERSION% JARPATH=%JARPATH% exec $JAVA -jar $JARPATH/dup2dds-$VERSION.jar "$@" pescetti-0.5/dup2dds.10000644000175000017500000000035010765746034013307 0ustar mjj29mjj29.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36. .TH DUP2DDS "1" "February 2008" "DUP2DDS" "User Commands" .SH NAME Pescetti -- dup2dds converts Duplimate (DUP) format to dds .SH SYNOPSIS .B dup2dds \fI\fR pescetti-0.5/pbn2dds0000755000175000017500000000134710765746034013151 0ustar mjj29mjj29#!/bin/sh -- # dds order: W N E S PBN="$1" RESULT="$1" RESULT=${RESULT%.pbn} RESULT=${RESULT%.PBN} RESULT=${RESULT}.dds if [ -z "$PBN" ]; then echo "Usage: pbn2dds " exit 1 fi IFS=' ' ( for i in `grep -i 'deal ' "$PBN"`; do DEALER="`echo $i | sed 's/^.*"\(.\):.*$/\1/'`" HANDS="`echo $i | sed 's/^.*:\(.*\)".*$/\1/'`" case $DEALER in "W") echo $HANDS ;; "N") echo $HANDS | awk '{print $4" "$1" "$2" "$3}' ;; "E") echo $HANDS | awk '{print $3" "$4" "$1" "$2}' ;; "S") echo $HANDS | awk '{print $2" "$3" "$4" "$1}' ;; *) echo "ERROR: dealer is $DEALER" exit 1 ;; esac done ) > $RESULT pescetti-0.5/pbn2dds.10000644000175000017500000000036710765746034013306 0ustar mjj29mjj29.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36. .TH PBN2DDS "1" "February 2008" "PBN2DDS" "User Commands" .SH NAME Pescetti -- pbn2dds converts Portable Bridge Notation (PBN) format to dds .SH SYNOPSIS .B pbn2dds \fI\fR