DEV Community

Srividya Mysore Venkatesh
Srividya Mysore Venkatesh

Posted on

Chapter 7: Project: A Robot

This is the 7th Blog in the series of 21 blogs that put together my learnings from the book eloquent js.
The seventh chapter has yet another beautiful quote which says:
"[...] the question of whether Machines Can Think [...] is about as relevant as the question of whether Submarines Can Swim"

A very important point driven in this chapter is that Theory is necessary to learn to program, but reading and understanding actual programs are just as important.

Our project in this chapter was to build an automaton, a little program that performs a task in a virtual world. Our automaton will be a mail-delivery robot picking up and dropping off parcels.

So the chapter goes about explaining tasks in order to do so.

The first step was to mark all the roads and buildings to form a graph of sorts. This graph is the world that our robot moves through.

The list of roads is converted to a data structure that, for each place, tells us what can be reached from there.

It uses the split method to go from the road strings, which have the form "Start-End", to two-element arrays containing the start and end as separate strings.


Our Aim is that: Our robot will be moving around the village. There are parcels in various places, each addressed to some other place. The robot picks up parcels when it comes to them and delivers them when it arrives at their destinations.

The automaton must decide, at each point, where to go next. It has finished its task when all parcels have been delivered.

Solution: To be able to simulate this process, we must define a virtual world that can describe it. This model tells us where the robot is and where the parcels are. When the robot has decided to move somewhere, we need to update the model to reflect the new situation.

What is persistent data?
Data structures that don’t change are called immutable or persistent. They behave a lot like strings and numbers in that they are who they are and stay that way, rather than containing different things at different times.

Further Pathfinding and simulation is carried out to conduct tasks and accomplish the feat of making a robot.

Refer to the link above to find out the practical aspect of it!

Happy Reading!

Top comments (0)