极客战记-逻辑之路
1、选择英雄和编程语言

2、选择装备

3、写中文注释

1、写代码
# 从巫师那得到两个秘密的真假值
hero.moveXY(14, 24)
secretA = hero.findNearestFriend().getSecretA()
secretB = hero.findNearestFriend().getSecretB()
# 如果 secretA 和 secretB 都为真,走上面的路;否则,走下面。
# 查看提示,学会写逻辑表达式。
secretC = secretA and secretB
if secretC:
hero.moveXY(20, 33)
else:
hero.moveXY(20, 15)
hero.moveXY(26, 24)
# 如果 secretA 和 secretB 中有一个为真,走上面。
secretC = secretA or secretB
if secretC:
hero.moveXY(32, 34)
else:
hero.moveXY(32, 15)
hero.moveXY(38, 25)
# 如果 secretB 不是真的,走上面。
secretC = secretB
if not secretC:
hero.moveXY(44, 33)
else:
hero.moveXY(48, 15)
hero.moveXY(51, 24)

2、运行

1、写代码
// 从巫师那得到两个秘密的真假值
hero.moveXY(14, 24);
var secretA = hero.findNearestFriend().getSecretA();
var secretB = hero.findNearestFriend().getSecretB();
// 如果 secretA 和 secretB 都为真,走上面的路;否则,走下面。
// 查看提示,学会写逻辑表达式。
var secretC = secretA && secretB;
if (secretC)
hero.moveXY(20, 33);
else
hero.moveXY(20, 15);
hero.moveXY(26, 24);
// 如果 secretA 和 secretB 中有一个为真,走上面。
var secretC = secretA || secretB;
if (secretC)
hero.moveXY(32, 34);
else
hero.moveXY(32, 15);
hero.moveXY(38, 25);
// 如果 secretB 不是真的,走上面。
var secretC = secretB;
if (secretC!=true)
hero.moveXY(44, 33);
else
hero.moveXY(48, 15);
hero.moveXY(51, 24);

2、运行

1、写代码
# 从巫师那得到两个秘密的真假值
hero.moveXY(14, 24)
secretA = hero.findNearestFriend().getSecretA()
secretB = hero.findNearestFriend().getSecretB()
# 如果 secretA 和 secretB 都为真,走上面的路;否则,走下面。
# 查看提示,学会写逻辑表达式。
secretC = secretA and secretB
if secretC
hero.moveXY(20, 33)
else
hero.moveXY(20, 15)
hero.moveXY(26, 24)
# 如果 secretA 和 secretB 中有一个为真,走上面。
secretC = secretA or secretB
if secretC
hero.moveXY(32, 34)
else
hero.moveXY(32, 15)
hero.moveXY(38, 25)
# 如果 secretB 不是真的,走上面。
secretC = secretB
if not secretC
hero.moveXY(44, 33)
else
hero.moveXY(48, 15)
hero.moveXY(51, 24)

2、运行

1、写代码
-- 从巫师那得到两个秘密的真假值
hero:moveXY(14, 24)
local secretA = hero:findNearestFriend():getSecretA()
local secretB = hero:findNearestFriend():getSecretB()
-- 如果 secretA 和 secretB 都为真,走上面的路;否则,走下面。
-- 查看提示,学会写逻辑表达式。
local secretC = secretA and secretB
if secretC then
hero:moveXY(20, 33)
else
hero:moveXY(20, 15)
end
hero:moveXY(26, 24)
-- 如果 secretA 和 secretB 中有一个为真,走上面。
local secretC = secretA or secretB
if secretC then
hero:moveXY(32, 34)
else
hero:moveXY(32, 15)
end
hero:moveXY(38, 25)
-- 如果 secretB 不是真的,走上面。
local secretC = secretB
if not secretC then
hero:moveXY(44, 33)
else
hero:moveXY(44, 15)
end
hero:moveXY(51, 24)

2、运行
