Yes, there is a much better way visually of writing this code.
start by factoring out your: player_gy = bomb_gy (i), and player_gx = bomb_gx (i)
(note that two of your conditions are actually the same! im gonna assume you meant for one to be the corresponding missing one)
Turing: |
(player_gx = bomb_gx (i) and player_gy = bomb_gy (i))
(player_gx = bomb_gx (i) and player_gy = bomb_gy (i) - 1)
(player_gx = bomb_gx (i) and player_gy = bomb_gy (i) + 1)
(player_gx = bomb_gx (i) and player_gy = bomb_gy (i) + 2) and up_condition = true
(player_gx = bomb_gx (i) and player_gy = bomb_gy (i) - 2) and down_condition = true
(player_gy = bomb_gy (i) and player_gx = bomb_gx (i))
(player_gy = bomb_gy (i) and player_gx = bomb_gx (i) - 1)
(player_gy = bomb_gy (i) and player_gx = bomb_gx (i) + 1)
(player_gy = bomb_gy (i) and player_gx = bomb_gx (i) - 2) and right_condition = true
(player_gy = bomb_gy (i) and player_gx = bomb_gx (i) + 2) and left_condition = true
% Which Creates
if ((player_gx = bomb_gx (i)) then
if (player_gy = bomb_gy (i)) or
(player_gy = bomb_gy (i) - 1) or
(player_gy = bomb_gy (i) + 1) or
((player_gy = bomb_gy (i) + 2) and up_condition) or
((player_gy = bomb_gy (i) - 2) and down_condition) then
alive := false
end if
end if
if ((player_gy = bomb_gy (i)) then
if (player_gx = bomb_gx (i)) or
(player_gx = bomb_gx (i) - 1) or
(player_gx = bomb_gx (i) + 1) or
((player_gx = bomb_gx (i) + 2) and left_condition) or
((player_gx = bomb_gx (i) - 2) and right_condition) then
alive := false
end if
end if |
And there is also other ways to simplify this even more using absolute function and other methods that actually may look nicer, this is just an example of how to deal with big messy if statements.
Also depending on your context, and what you want it to do, their may even be an easier way to simplify based on the problem you are trying to accomplish by these boolean statements.
Side Notes:
Turing: |
if (a = true) then ...
% Is Same As
if (a) then ... |
For Small Conditions:
Turing: |
if (a) then
b := false
end if
% Is Same As
b := (not a) |