public bool identTo(Comb b) { bool p = true; for (int i = 0; (i < 3) && p; i++) p = p && (this[i] == b[i]); return p; }
public Game(int p) { secret = new Comb( p % 6 + 1, (p / 6) % 6 + 1, (p / 36) % 6 + 1, (p / 216) % 6 + 1 ); start = DateTime.Now; }
public bool identTo(Comb b) { bool p = true; for (int i = 0; (i < 3) && p; i++) { p = p && (this[i] == b[i]); } return(p); }
internal Guess Try(Comb p) { if (attempts < 6) { attempts++; bool cor = p.identTo(secret); solved = solved || cor; return secret.compare(p); } return new Guess(0, 0); }
internal Guess Try(Comb p) { if (attempts < 6) { attempts++; bool cor = p.identTo(secret); solved = solved || cor; return(secret.compare(p)); } return(new Guess(0, 0)); }
public Guess compare(Comb b) { int t = 0, d = 0; int[] c1 = this.count(), c2 = b.count(); for (int i = 1; i <= 6; i++) t += Math.Min(c1[i], c2[i]); for (int i = 0; i < 4; i++) d += (this[i] == b[i]) ? 1 : 0; return new Guess(d, t - d); }
public int[] Try(int[] c) { Comb com = new Comb( c[0], c[1], c[2], c[3]); if (g != null) { Guess asdf = g.Try(com); int[] arr = asdf.toArray(); return arr; } return null; }
public int[] Try(int[] c) { Comb com = new Comb( c[0], c[1], c[2], c[3]); if (g != null) { Guess asdf = g.Try(com); int[] arr = asdf.toArray(); return(arr); } return(null); }
public Guess compare(Comb b) { int t = 0, d = 0; int[] c1 = this.count(), c2 = b.count(); for (int i = 1; i <= 6; i++) { t += Math.Min(c1[i], c2[i]); } for (int i = 0; i < 4; i++) { d += (this[i] == b[i]) ? 1 : 0; } return(new Guess(d, t - d)); }