DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T m

⟦4088ba07b⟧ TextFile

    Length: 651 (0x28b)
    Types: TextFile
    Names: »makemove.c«

Derivation

└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
    └─⟦this⟧ »EUUGD18/Sun/Pyramid/makemove.c« 

TextFile

#include "pyramid.h"
short table[32768]={
#include "pyramid.table"
};
extern Panel_item panel_mes;
extern char board[8][5][5];
extern int eofg,depth,nl;
extern long seed;
move()
{  int i,j,n,o;
   n=0;FOR_BOARD(i,j) n+=board[nl][i][j];
   if(n==0) {panel_msg("Game is over.  I win.");eofg=1;return;}
   if(n==1) {panel_msg("Game is over.  You win!");eofg=1;return;}
   o=0; FOR_BOARD(i,j) o=2*o+board[nl][i][j];
   if(n>depth||table[o]<=0){
     n=random()%n;
     FOR_BOARD(i,j) if(board[nl][i][j]==1&&(n-- ==0))board[nl][i][j]=0;
   }
   else{
      o=table[o]; 
      for(i=BOARDSIZE-1;i>=0;--i)for(j=i;j>=0;--j){board[nl][i][j]=o%2;o/=2;}
   }
}