Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class KancsosAllapot : AbsztraktÁllapot
- {
- //MEZŐK, AMIVEL LE TUDOM ÍRNI A KEZDŐÁLLAPOTOT
- int k3, k5, k8; //3,5,8 literes kancsó
- public override object Clone()
- {
- KancsosAllapot kancsóklón = new KancsosAllapot();
- kancsóklón.k3 = this.k3;
- kancsóklón.k5 = this.k5;
- kancsóklón.k8 = this.k8;
- return kancsóklón;
- }
- public KancsosAllapot()
- {
- k3 = 3;
- k5 = 5;
- k8 = 0;
- }
- public override bool ÁllapotE()
- {
- return k3 >= 0 && k3 <= 3 && k5 >= 0 && k5 <= 5 && k8 >= 0 && k8 <= 8;
- }
- public override bool CélÁllapotE()
- {
- return k5 == 4 && k8 == 4;
- }
- public override int OperátorokSzáma()
- {
- return 6;
- }
- public override bool SzuperOperátor(int i)
- {
- switch (i)
- {
- case 0: return atont35(); // átönt k3ból k5be
- case 1: return atont38();
- case 2: return atont53();
- case 3: return atont58();
- case 4: return atont83();
- case 5: return atont85();
- default: return false;
- }
- }
- private bool atont85()
- {
- if (!preAtont85()) return false;
- int attoltheto = k8 + k3 <= 3 ? k8 : 3 - k3;
- k8 -= attoltheto;
- k3 += attoltheto;
- if (ÁllapotE()) return true;
- return false;
- }
- private bool preAtont85()
- {
- return k8 > 0 && k5 < 5;
- }
- private bool atont83()
- {
- if (!preAtont83()) return false;
- int attoltheto = k8 + k3 <= 3 ? k8 : 3 - k3;
- k8 -= attoltheto;
- k3 += attoltheto;
- if (ÁllapotE()) return true;
- return false;
- }
- private bool preAtont83()
- {
- return k8 > 0 && k3 < 3;
- }
- private bool atont58()
- {
- if (!preAtont58()) return false;
- int attoltheto = k5 + k8 <= 8 ? k5 : 8 - k8;
- k5 -= attoltheto;
- k8 += attoltheto;
- if (ÁllapotE()) return true;
- return false;
- }
- private bool preAtont58()
- {
- return k5 > 0 && k8 < 8;
- }
- private bool atont53()
- {
- if (!preAtont53()) return false;
- int attoltheto = k5 + k3 <= 3 ? k5 : 3 - k3;
- k5 -= attoltheto;
- k3 += attoltheto;
- if (ÁllapotE()) return true;
- return false;
- }
- private bool preAtont53()
- {
- return k5 > 0 && k3 < 3;
- }
- private bool atont38()
- {
- if (!preAtont38()) return false;
- int attotheto = k3 + k8 <= 8 ? k3 : 8 - k8;
- k3 -= attotheto;
- k8 += attotheto;
- if (ÁllapotE()) return true;
- return false;
- }
- private bool preAtont38()
- {
- return k3 > 0 && k8 < 8;
- }
- private bool atont35()
- {
- //előfeltétel
- if (!preAtont35()) return false;
- //állapotátmenet
- //mennyit lehet áttölteni
- int attoltheto = k3 + k5 <= 5 ? k3 : 5 - k5;
- k3 -= attoltheto;
- k5 += attoltheto;
- //állapot-e
- if (ÁllapotE())
- return true;
- return false;
- }
- private bool preAtont35()
- {
- return k3 > 0 && k5 < 5;
- }
- public override string ToString()
- {
- return k3 + " " + k5 + " " + k8;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement