Skip to content

Commit

Permalink
Merge pull request #1 from microsoft/v-chyou-patch-1
Browse files Browse the repository at this point in the history
new set of detect functions
  • Loading branch information
v-chyou authored Oct 2, 2019
2 parents 7d6d117 + a5c7a53 commit 5bf96f1
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,38 @@
//% weight=94 color=#EC7505 icon="\uf1b3"
namespace hourOfCode {
/**
* Checks if the goal is reached by looking for the Gold Block direction down to agent
* True if the agent is not standing on top of the goal (Gold Block)
*/
//% blockId=goal_not_reached block="goal not reached"
//% weight=30
//% weight=40
export function goalNotReached() {
return (!(agent.inspect(AgentInspection.Block, SixDirection.Down) == Block.GoldBlock))
}
/**
* Checks if the agent detects fire in a direction
* @param dir direction to inspect
* True if the agent detects a dead bush block in a direction
* @param dir direction to inspect
*/
//% blockId=agent_detect_fire block="agent detect fire %direction"
//% blockId=agent_detect_dead_bush block="agent detect dead bush %direction"
//% weight=30
export function agentDetectDeadBush(dir: SixDirection) {
return (agent.inspect(AgentInspection.Block, dir) == Block.DeadBush)
}
/**
* True if the agent detects any double_plant (double tallgrass, large fern, sunflower, lilac, peony, rosebush) in a direction
* @param dir direction to inspect
*/
//% blockId=agent_detect_dry_grass block="agent detect dry grass %direction"
//% weight=20
export function agentDetectFire(direction: SixDirection) {
return (agent.inspect(AgentInspection.Block, direction) == Block.Fire)
export function agentDetectDryGrass(dir: SixDirection) {
return (agent.inspect(AgentInspection.Block, dir) == blocks.blockByName("double_plant"))
}
/**
* Checks if the agent detects fire in a direction
* @param dir direction to inspect
* True if the agent detects any dead bush or double_plant in a direction
* @param dir direction to inspect
*/
//% blockId=agent_detect_dead_bush block="agent detect dead bush %direction"
//% blockId=agent_detect_fire_hazard block="agent detect fire hazard %direction"
//% weight=10
export function agentDetectDeadBush(direction: SixDirection) {
return (agent.inspect(AgentInspection.Block, direction) == Block.DeadBush)
export function agentDetectFireHazard(dir: SixDirection) {
return hourOfCode.agentDetectDeadBush(dir) || hourOfCode.agentDetectDryGrass(dir)
}
}
}

0 comments on commit 5bf96f1

Please sign in to comment.