Esempio n. 1
0
void nfprint(void)
{
    char s[MAXSTRL];
    int  i, j;
    printf("NF payoffs:\n");
    
    colset(nstrats[2]+1);
    colleft(0);
    colpr("pay1");
    for (j=0; j<nstrats[2]; j++)
	{
	strattomovetuple(j, 2);
	movetupletoa(2, s);    colpr(s);
	}
    colpr("pay2");
    colnl();
    for (i=0; i<nstrats[1]; i++)
	{
	strattomovetuple(i, 1);
	movetupletoa(1, s);    colpr(s);
	/* payoffs player 1 */
	for (j=0; j<nstrats[2]; j++)
	    {
	    rattoa(nfpay[i][j][0], s);        colpr(s);
	    }
	/* payoffs player 2 */
	colpr("");
	for (j=0; j<nstrats[2]; j++)
	    {
	    rattoa(nfpay[i][j][1], s);        colpr(s);
	    }
	colnl();
	}
    colout();
}       /* end of  nfprint()    */
Esempio n. 2
0
void sfprint(void)
{
    char s[MAXSTRL];
    int i, j, k;
    printf("SF payoffs and constraints:\n");
    
    colset(nseqs[2]+2+nisets[1]);
    colleft(0);
    colpr("pay1");
    for (j=0; j<nseqs[2]; j++)
	{
        seqtoa(firstmove[2] + j, 2, s);    colpr(s);
	}
    colnl();
    colpr("pay2");
    for (j=0; j<nseqs[2]; j++)
	colpr(" ");
    colpr("cons1");
    for (k=1; k<=nisets[1]; k++)
	/* headers for constraint matrix pl1, printed on right of payoffs   */
	colpr((firstiset[1]+k-1)->name);
    for (i=0; i<nseqs[1]; i++)
	{
	/* payoffs player 1 */
	seqtoa(firstmove[1] + i, 1, s);    colpr(s);
	for (j=0; j<nseqs[2]; j++)
	    {
	    rattoa(sfpay[i][j][0], s);     colpr(s);
	    }
	colnl();
	/* payoffs player 2 */
	colpr("");
	for (j=0; j<nseqs[2]; j++)
	    {
	    rattoa(sfpay[i][j][1], s);     colpr(s);
	    }
	/* constraints player 1 */
	for (k=0; k<=nisets[1]; k++)
	    colipr(sfconstr[1][k][i]);    
	colnl();
	}
    /* constraints player 2 */
    for (k=0; k<=nisets[2]; k++)
	{
	colnl();
	if (k==0)
	    colpr("cons2");
	else
	    colpr((firstiset[2]+k-1)->name);
	for (j=0; j<nseqs[2]; j++)
	    colipr(sfconstr[2][k][j]);
	colnl();
	}
    colout();
}       /* end of  sfprint()            */
Esempio n. 3
0
void outbehavstrat(int pl, Rat *rplan, Bool bnewline)
{
    char s[MAXSTRL];
    int i;
    Move c;
    Iset h;
    Rat rprob, bprob;

    for (h = firstiset[pl]; h < firstiset[pl+1]; h++)
        for (c = h->move0, i=0; i < h->nmoves; c++, i++)
            {
            rprob = rplan[ c - firstmove[pl] ];
            if ( rprob.num != 0)
                {
                movetoa(c, pl, s);
                printf(" %s", s);
                bprob = ratdiv( rprob, rplan[ h->seqin - firstmove[pl]]);
                if (!ratiseq(bprob, ratfromi(1) ) )
                    {
                    rattoa(bprob, s);
                    printf(":%s", s);
                    }
                }
            }
    if (bnewline)
        printf("\n");
}
Esempio n. 4
0
void twolineoutmixed(int pl, Rat *mixed)
{
    int i;
    char s[MAXSTRL];
    int *support;
    int suppsize = 0;


    support = TALLOC( nstrats[pl], int);

    for (i = 0; i < nstrats[pl]; i++)
        if (mixed[i].num != 0)
	    support[suppsize++] = i ;
    colset(suppsize) ;
    for (i = 0; i < suppsize; i++)
        {
        strattomovetuple (support[i], pl);
        movetupletoa(pl, s);
        colpr(s);
        }
    for (i = 0; i < suppsize; i++)
        {
        rattoa(mixed[support[i]], s);
        colpr(s);
        }
   colout();
   free(support);
}
Esempio n. 5
0
void colprEquilibrium(Equilibrium eq)
{
    char smp [2*DIG2DEC(MAX_DIGITS) + 4];
    
    int i;
    int n = eq.lcpdim;
    
    Rat *rats = getStrategies(eq);
    
    colpr("P1:");
	for(i = 2; i < eq.nrows + 2; ++i)
	{
		rattoa(rats[i], smp);
		colpr(smp);
	}
	
    colpr("P2:");
    for(; i < n; ++i)
    {
    	rattoa(rats[i], smp);
    	colpr(smp);
    }
}
Esempio n. 6
0
Bool iseqrealplantoprob(int pl, Rat *rplan, Bool bcomplain)
{
    int i;
    char s[MAXSTRL];
    Bool isok=1;

    for (i = 0; i < nseqs[pl]; i++)
        if (! ratiseq(rplan[i], (firstmove[pl] + i)->realprob))
	    {
	    isok = 0;
            if (bcomplain)
                {
                seqtoa(firstmove[pl] + i, pl, s);
                printf ("Player %d, move %s has realprob ", pl, s);
                rattoa( (firstmove[pl] + i)->realprob, s);
                printf ("%s", s);
                rattoa( rplan[i], s);
                printf (", but should be %s\n", s);
                }
            else
                break;
            }
    return isok ;
}
Esempio n. 7
0
void outrealplan(int pl, Rat *rplan)
{
    int i;
    char s[MAXSTRL];

    colset(nseqs[pl]) ;
    for (i = 0; i < nseqs[pl]; i++)
        {
        seqtoa(firstmove[pl] + i, pl, s);
        colpr(s);
        }
    for (i = 0; i < nseqs[pl]; i++)
        {
        rattoa(rplan[i], s);
        colpr(s);
        }
   colout();
}
Esempio n. 8
0
void outmixed(int pl, Rat *mixed, Bool bnewline)
{
    int i;
    char s[MAXSTRL];
    Rat prob;

    for (i = 0; i < nstrats[pl]; i++)
        {
        prob = mixed[i] ;
        if ( prob.num != 0)
            {
            strattomovetuple (i, pl);
            movetupletoa(pl, s);
            printf(" %s", s);
            if (!ratiseq(prob, ratfromi(1) ) )
                {
                rattoa(prob, s);
                printf(":%s", s);
                }
            }
        }
    if (bnewline)
        printf("\n");
}