How to execute an instruction multiple times
The Church Numerals represent
integers as compositions of functions, i.e., f(f(f(...)))
, as many times as
the number they represent. When used not as integers, but as functions, they
take 2 arguments: 1) the function to execute n
times, and 2) the argument
passed to the initial call of the function.
Considering this, a possible strategy to execute a LTG instruction multiple times in a single turn is the following:
- Create a function that:
- Receives a slot number as argument
- Calls one of the attack or defense cards of the game
- Returns the received argument
- Create a Church numeral large enough, pass to it the function defined above, and then pass to it a slot number.
To create a proper Church numeral, one can use the following definitions
_1 = I
SUCC = S(S(K(S))(K))
POW = I
With this, now one can create, e.g., 256 as a Church numeral:
_2 = SUCC(_1)
_4 = POW(_2)(_2)
_256 = POW(_4)(_4)
All of these definitions were taken from here.
Now for the first part of the problem: a function that takes an argument, calls one of the attack or defense cards, and returns the argument received initially:
dec2 = S(dec)(I)
This last function was suggested by the exploratory search woakas programmed.
Now we can call that function multiple times, in the following fashion:
_256(dec2)(0)