Code: Select all
([ON, ON, ON], [OFF, OFF, ON], [OFF, ON, ON])
Code: Select all
([ON, ON, ON], [X, X, ON], [X, ON, ON])
Code: Select all
([ON, ON, ON], [X, OFF, ON], [OFF, ON, ON])
Then its probably much better to create helper functions to do the comparison.
Code: Select all
init python:
def is_matrix_equal(m1, m2, comparer=None):
"""
@param m1: A matrix.
@param m2: Another matrix.
@param comparer: A function that takes argument c1 containing the m1 cell
and argument c2 containing the m2 cell. The function should return a boolean
value. Leaving the comparer as None means the usual comparison (==).
"""
rv = True
if callable(comparer):
if len(m1) != len(m2): rv = False
else:
for i1, r1 in enumerate(m1):
r2 = m2[i1]
if len(r1) != len(r2): rv = False
else:
for i2, c1 in enumerate(r1):
c2 = r2[i2]
rv = comparer(c1, c2)
if not rv: break
if not rv: break
else: rv = m1 == m2
return rv
# the custom comparer that caters what you're looking for.
def comparer(c1, c2):
return (c1 != ON and c2 != ON) or (c1 == c2)
Code: Select all
# The game starts here.
label start:
call screen minigame(3, 3)
$ res = _return # assign the result
# call the function then pass the resulting matrix and another matrix you wish
# to compare it with, then lastly the comparer function that you made.
if is_matrix_equal(res, ([ON, ON, ON], [OFF, OFF, ON], [OFF, ON, ON]), comparer):
"Do something"
"Something"
I feel like using enums and flags would do the trick also but idk.