public override Value DoReduce(Slot[] me, Slot[] opponent, Value[] args, ref int applicationsDone, bool zombieMode) { var proponentSlot = args[0].AsSlot(); var opponentSlot = 255 - args[1].AsSlot(); var n = args[2].AsNum(); if (me[proponentSlot].vitality < n) throw new GameError("not enough vitality " + me[proponentSlot].vitality + " for " + this); me[proponentSlot].vitality -= n; if (opponent[opponentSlot].vitality > 0) { if (!zombieMode) { opponent[opponentSlot].vitality -= n*9/10; if (opponent[opponentSlot].vitality < 0) opponent[opponentSlot].vitality = 0; } else { opponent[opponentSlot].vitality += n * 9 / 10; if (opponent[opponentSlot].vitality > 65535) opponent[opponentSlot].vitality = 65535; } } return Funcs.I; }
public Move(Value card, int slot) { this.slot = slot; this.card = card; card_to_slot = true; }
public Move(int slot, Value card) { this.slot = slot; this.card = card; card_to_slot = false; }
private static void Apply(Slot[] me, Slot[] opponent, Value left, Value right, int resultSlot) { RessurectZombies(me, opponent); try { if (me[resultSlot].vitality <= 0) throw new GameError("result slot is dead:" + resultSlot); if (left.ArgsNeeded <= 0) throw new GameError("incorrect application: " + left + " " + right); var applicationsDone = 0; var res = new Application(left, right).Reduce(me, opponent, ref applicationsDone, false); me[resultSlot].value = res; } catch (GameError e) { Log(e.Message); me[resultSlot].value = Funcs.I; } }
public override Value DoReduce(Slot[] me, Slot[] opponent, Value[] args, ref int applicationsDone, bool zombieMode) { var opponentSlot = 255 - args[0].AsSlot(); var x = args[1]; if (opponent[opponentSlot].vitality > 0) throw new GameError("Slot is not dead! " + this); opponent[opponentSlot].value = x; opponent[opponentSlot].vitality = -1; return Funcs.I; }
public override Value DoReduce(Slot[] me, Slot[] opponent, Value[] args, ref int applicationsDone, bool zombieMode) { var f = args[0]; var g = args[1]; var x = args[2]; var left = new Application(f, x).Reduce(me, opponent, ref applicationsDone, zombieMode); var right = new Application(g, x).Reduce(me, opponent, ref applicationsDone, zombieMode); var res = new Application(left, right).Reduce(me, opponent, ref applicationsDone, zombieMode); return res; }
public override Value DoReduce(Slot[] me, Slot[] opponent, Value[] args, ref int applicationsDone, bool zombieMode) { var arg = args.First(); if (arg is Num) return new Num(Math.Min(((Num)arg).num + 1, 65535)); throw new GameError("Call succ with not a num: " + arg); }
public override Value DoReduce(Slot[] me, Slot[] opponent, Value[] args, ref int applicationsDone, bool zombieMode) { return Funcs.I; }
public override Value DoReduce(Slot[] me, Slot[] opponent, Value[] args, ref int applicationsDone, bool zombieMode) { var proponentSlot = args[0].AsSlot(); if (me[proponentSlot].vitality <= 0) me[proponentSlot].vitality = 1; return Funcs.I; }
public override Value DoReduce(Slot[] me, Slot[] opponent, Value[] args, ref int applicationsDone, bool zombieMode) { var slot = args.First().AsSlot(); var vitality = me[slot].vitality; if (!zombieMode) { if (vitality > 0 && vitality < 65535) me[slot].vitality = vitality + 1; } else { if (vitality > 0) me[slot].vitality = vitality - 1; } return Funcs.I; }
public override Value DoReduce(Slot[] me, Slot[] opponent, Value[] args, ref int applicationsDone, bool zombieMode) { return me[args.First().AsSlot()].value; }
public Value Reduce(Slot[] me, Slot[] opponent, Value[] args, ref int applicationsDone, bool zombieMode) { if (args.Length != ArgsNeeded) throw new Exception("Bug in code!"); if (applicationsDone >= 1000) throw new GameError("Too many applications " + applicationsDone); applicationsDone++; //r.Append(" " + ToString()); var res = DoReduce(me, opponent, args, ref applicationsDone, zombieMode); return res; }
public abstract Value DoReduce(Slot[] me, Slot[] opponent, Value[] args, ref int applicationsDone, bool zombieMode);
public Application(Value f, Value arg) : base(f.ArgsNeeded - 1, () => string.Format("{0}({1})", f, arg)) { this.f = f; this.arg = arg; }