How Do I Detect Swamps in Screeps

//ads -- adsterra.com -- native banner
?>
In screeps, I can see swamps using my browser window. However, I can find no way for my script to detect if the terrain is a swamp except for having my creeps walk around marking swamps they encounter as they go. Are there any other ways to detect swamps?
Best Answer
You can use Room.lookForAt
method:
var terrain = creep.room.lookForAt('terrain', creep.pos.x+1, creep.pos.y);
if(terrain != 'swamp') {
creep.move(RIGHT);
}
If you want to find all terrain tiles from the entire room, check this SO question.
Pictures about "How Do I Detect Swamps in Screeps"



Taking on Spawn And Swamp | Screeps Arena Gameplay
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: 光曦 刘, 光曦 刘, 光曦 刘, Brett Jordan