Coder Social home page Coder Social logo

austinmw312 / treasure-troll-solution Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 44 KB

A solution to the treasure troll challenge.

HTML 29.02% JavaScript 70.98%
bfs challenge graph-algorithms shortest-path-algorithm treasure treasure-hunt troll breadth-first-search maze staircase

treasure-troll-solution's Introduction

Troll Challenge Solution

A solution to the treasure troll challenge. Open index.html in browser for testing interface. See solution.js for solution.

Problem statement:

Summary: Your job is to write the brain of a treasure troll. This troll will start on a randomly generated map with scattered obstacles and stackable blocks. Somewhere on the field, there is a tower, atop which rests a golden treasure. To attain this treasure, your troll must stack blocks and build a staircase. The object is to write a clean and understandable solution that finds the treasure in as few moves as possible.

You can learn the game mechanics with the testing engine (use the arrow keys). The testing engine will automatically pull the file solution.js for automated testing purposes. This will be very helpful later on.

To defeat the challenge you must implement the Stacker class. The Stacker class only has one required method, turn. The simulator will call your turn method once each turn, passing in the JSON object currentCell, containing information about the current cell your treasure troll is on, and the four surrounding cells. Example Stacker Class

		cell = {
			left: {type: someValue, level: someValue},
			up: {type: someValue, level: someValue},
			right: {type: someValue, level: someValue},
			down: {type: someValue, level: someValue},
			type: someValue,
			level: someValue
		}

There are three types of tiles on the map. All are traversable except walls.

0 (empty) 1 (wall) 2 (block) 3 (gold) All tiles also have an associated non-negative integer level (elevation off the ground). Empty cells are always at ground zero. Your troll can only move up or down by one level at a time.

Your turn method must then return a string representing one of six possible actions.

"left" "up" "right" "down" "pickup" "drop" The simulator will only count a turn if the action you specified was legal. So if you try to pickup a non-existent block, it simply won't do anything.

Solution in solution.js

treasure-troll-solution's People

Contributors

austinmw312 avatar

Watchers

 avatar

Forkers

vithirun

treasure-troll-solution's Issues

Inquiry to make solution private.

Hi Austin,

I'm reaching out to inquire about making your solution to this problem private. The original programming challenge is a great exercise, and it'd be great to let newcomers to approach the problem naturally.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.