public SewerSub1() { Rat rat = new Rat(); BigRat bigRat = new BigRat(); this.name = "Sewer Sub 1"; this.levelRequirement = 1; this.monsters.Add(rat); this.monsters.Add(bigRat); }
public SewerSub2() { Rat rat = new Rat(); BigRat bigRat = new BigRat(); this.name = "Sewer Sub 2"; this.levelRequirement = 2; this.monsters.Add(rat); this.monsters.Add(bigRat); //this.canGoTo.Add(new SewerSub1()); }
public override Expr _Simplify(Expr e) { Expr ret = Canonicalize(e); return Reformat(ret); /* simplifyrules. integer evaluation. trig of special expressions. half/double angle formulas; formulas with pi etc. */ /* sin2+cos2 ? in middle of addition of other things? etc? */ #if false // Grr, this code was for the magnitude case of the CompositeExpr switch for Numericize--but numericize does only doubles: this should become part of simplify instead. Trace.Assert(args.Length == 1); if(args[0] is RealNumber) { if(args[0] is DoubleNumber) return new DoubleNumber(Math.Abs(((DoubleNumber)args[0]).Num)); else if(args[0] is IntegerNumber) return new IntegerNumber(((IntegerNumber)args[0]).Num.abs()); else if(args[0] is RationalNumber) return new RationalNumber(((RationalNumber)args[0]).Num.abs()); } else if(args[0] is ComplexNumber) { ComplexNumber cn = (ComplexNumber)args[0]; DoubleNumber red = cn.Re as DoubleNumber; DoubleNumber imd = cn.Im as DoubleNumber; if(red != null && imd != null) return new DoubleNumber(Math.Sqrt(red.Num*red.Num + imd.Num*imd.Num)); IntegerNumber rei = cn.Re as IntegerNumber; IntegerNumber imi = cn.Im as IntegerNumber; IntegerNumber rer = cn.Re as RationalNumber; IntegerNumber imr = cn.Im as RationalNumber; BigRat re, im; bool gotem = false; if(rei != null && imi != null) { re = rei.Num; im = imi.Num; gotem = true; } if(rer != null && imr != null) { re = rer.Num; im = imr.Num; gotem = true; } if(gotem) { /* This is a hack. There *are* integer square root algorithms (thus working for larger values than doubles represent). See http://www.embedded.com/98/9802fe2.htm, for instance. */ BigRat ss = re*re + im*im; BigInt sqssnum = (long)Math.Round(Math.Sqrt(ss.Num.Num.doubleValue())); BigInt sqssdenom = (long)Math.Round(Math.Sqrt(ss.Denom.Num.doubleValue())); bool havenum, havedenom; havenum = (ss.Num == sqssnum*sqssnum); havedenom = (ss.Denom == sqssdenom*sqssdenom); #if false // grr, wrote code here for what should be in simplify. Actually, this whole case of the switch can be simplified dramatically since we know we won't get any numbers but doubles (or machine precision) here if(havenum && havedenom) { BigRat val = new BigRat(sqssnum, sqssdenom); if(val.Denom == 1) return new IntegerNumber(val.Denom); else return new RationalNumber(val); } else if(!havenum && !havedenom) { return new CompositeExpr(WellKnownSym.root, new IntegerNumber(2), new RationalNumber(ss)); } else { return new CompositeExpr(WellKnownSym.divide, havenum ? new IntegerNumber(sqssnum) : new CompositeExpr(WellKnownSym.root, new IntegerNumber(2), ss.Num), havedenom ? new IntegerNumber(sqssdenom) : new CompositeExpr(WellKnownSym.root, new IntegerNumber(2), ss.Denom)); } #endif if(havenum && havedenom) { BigRat val = new BigRat(sqssnum, sqssdenom); if(val.Denom == 1) return new IntegerNumber(val.Denom); else return new DoubleNumber(val.Num.Num.AsDouble()/val.Denom.Num.AsDouble()); } else { /* Not as accurate as it could be if we have one as an integer (with an actual int sqrt function) but * not the other */ return new DoubleNumber(Math.Sqrt(ss.Num.Num.AsDouble()/ss.Denom.Num.AsDouble())); } } } #endif }