/* LOGIC.CPP Programming Start date - The 13th of October , 1993. Programming End date - The 9th of November, 1993. Programmed by Shlomi Fish. */ #include #include //LTable::LTable(unsigned i, unsigned t) //{clear(t,i);} void LTable::clear(unsigned t, unsigned i) { traits=t;itemsnum=i; for(t=0;t<100;t++) for(i=0;i<100;i++) con[t][i]=0; } int LTable::setcon(unsigned t1,unsigned i1,unsigned t2,unsigned i2,unsigned val) { if (val>2) {cerr << "Error in LTAble::setcon()! What value is this?";return 2;} unsigned int a, check_var[2] = {1,1}; if (val==2) { for(a=0;a2) {cerr << "Error in LTable::setcon()! What value is this?";return 2;} unsigned a,b; if (t1 == traits-1) { a=t1;t1=t2;t2=a; //swaps the traits a=i1;i1=i2;i2=a; //swaps the items } if (t2 == traits-1) //last field stuff { b=getcon(t1,i1,t2,i2); //assigning check argument if ((val == 2) && checkit(t1,i1,i2) && (b!=2)) return 2; else if ((val == 1) && checkitX(t1,i1,i2)) return 2; else { con[t1*itemsnum+i1][t2*itemsnum+i2] = val; con[t2*itemsnum+i2][t1*itemsnum+2-val] += ((b!=val) && val); con[t2*itemsnum+i2][t1*itemsnum+2-b] -= ((b!=val) && b); } return 0; } else return LTable::setcon(t1,i1,t2,i2,val); } int LTable_LFAN::checkit(unsigned int t1, unsigned int i1,unsigned int i2) { /* unsigned a, lt_total; for(a=0;aitemsnum)) cerr << "Error in input to LTable_LFIAN!"; } int LTable_LFIAN::checkit(unsigned t1, unsigned i1,unsigned i2) { return (LTable_LFAN::checkit(t1,i1,i2) || (con[(traits-1)*itemsnum+i2][t1*itemsnum]==lfi_ticksnum[i2])); } int LTable_LFIAN::checkitX(unsigned t1, unsigned i1,unsigned i2) { return (LTable_LFAN::checkitX(t1,i1,i2) || (con[(traits-1)*itemsnum+i2][t1*itemsnum+1]==itemsnum-lfi_ticksnum[i2])); } void NameTable::clear(unsigned i,unsigned t, unsigned ltt, unsigned *lti) { unsigned total=0; itemsnum=i;traits=t;lttype=ltt,last_ti[10]=traits; if (ltt > 0) { last_ti[10]=*lti;lti++; if (ltt>1) { for (i= 0;iitemsnum)) cerr << "Error in input to NameTable::clear()!"; } } for(i=0;i<10;i++) for(t=0;t<10;t++) cell[i][t] = 10; } /* NOTE!!! A cell with a 10 in it means nothing is written in it. last_ti[10] represents the number of possibilities in the last traits. (for ltt = 1 and for ltt = 2). */ unsigned NameTable::getitem(unsigned number, unsigned trait_) { if ((number last_ti[10]) cell[number][trait_]=10; else switch(lttype) { case lfan_nt : if (trait_ == traits-1) { cell[number][trait_] = newval; break; } case normal_nt : label_one: for(a=0;a50) { stats_num = 50; cerr << "Error in input to LogicStats::clear()!"; } } void LogicStats::set_stat(unsigned sn,unsigned newval) { if ((sn>=stats_num)||(newval>2)) cerr << "Error in input to LogicStats::setstat()!"; else statements[sn]=newval; } unsigned LogicStats::get_stat(unsigned sn) { if (sn>=stats_num) { cerr << "Error in input to LogicStats::setstat()!"; return 4; } else return statements[sn]; }