/************************************************************************\ |* gtf is a framework for analyzing two-player zero-sum games *| |* Copyright (C) 2005 Troels Bjerre Sorensen *| |* *| |* 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. *| \************************************************************************/ package gtf.examples; import gtf.game.*; public class GalaPoker extends ExtensiveForm { public static String[] deck = {"6", "7", "8", "9", "T", "J", "Q", "K", "A"}; public GameTree generateTree() { return new GalaDeal(); } private static int p1card = 0, p2card = 0; private class GalaDeal extends RandomNode { public GalaDeal() { for(p1card = 0 ; p1card < deck.length ; p1card++) { for(p2card = 0 ; p2card < deck.length ; p2card++) { if(p1card != p2card) { addChild(deck[p1card], deck[p2card], 1, new RoundOne()); } } } } } private class RoundOne extends PlayerNode { public RoundOne() { super(1); addChild(",check", ",p1 checks", new RoundTwo(false)); // check addChild(",bet", ",p1 bets", new RoundTwo(true)); // bet } } private class RoundTwo extends PlayerNode { public RoundTwo(boolean p1bet) { super(2); if(p1bet) { addChild(",p2 folds", ",fold", new GameLeaf(1)); // fold addChild(",p2 calls", ",call", new GameLeaf(p1card < p2card ? -2 : 2)); // call } else { addChild(",p2 checks", ",check", new GameLeaf(p1card < p2card ? -1 : 1)); // check addChild(",p2 bets", ",bet", new RoundThree()); // bet } } } private class RoundThree extends PlayerNode { public RoundThree() { super(1); addChild(",fold", ",p1 folds", new GameLeaf(-1)); // fold addChild(",call", ",p1 calls", new GameLeaf(p1card < p2card ? -2 : 2)); // call } } }