/************************************************************************\ |* 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; import gtf.game.*; import gtf.util.*; import java.io.*; import java.util.*; public class ValueVisitor> extends RealizationVisitor { private Strategy p1strategy, p2strategy; private T value; public ValueVisitor(Strategy strategy) { this(strategy, strategy); } public ValueVisitor(Strategy p1strategy, Strategy p2strategy) { this.p1strategy = p1strategy; this.p2strategy = p2strategy; value = p1strategy.ZERO; } public T getValue() { return value; } public void visitGameLeaf(GameLeaf leaf) { value = value.add( p1strategy.probOf(p1real).multiply( p2strategy.probOf(p2real).multiplyFrac( leaf.getValue().multiplyFrac(prob)))); } }