GithubHelp home page GithubHelp logo

joe-mojo / mower-akka Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fagossa/mower-akka

0.0 3.0 1.0 1.04 MB

A simple implementation of the mower scenario using akka and scala

Scala 100.00%

mower-akka's Introduction

License

Mower-akka

A simple implementation of the mower scenario using akka and scala

I need help!

The solution branch could be useful.

Track

TODO 1

Complete MowerActor. Once done, MowerActorSpecs should pass.

TODO 1.1

Complete MowerActor's companion object props() method. The goal is to create a Propos instance with the arguments of the actor class's constructor. See doc on props

What are props ?

Props instance is a memoization of the your business actor class constructor arguments.

What is the use of props ?

Once a Props instance is created, the actor system remembers the arguments needed to build your business actor class.

Thus, it is able to trash it an restart it as many times as the actor's lifecycle need it: the same original arguments are passed to your actor constructor each time it is called.

You will see when thereafter that you never create yourself an instance of your actor class; instead, you tell the actor system its props, and then the actor system create it.

TODO 1.2

You need to have this code compiling. See comments from 1.2.* todos in MowerActor.ready method.

Goal: pattern match the received message to choose what to do.

TODO 2

We want the SurfaceActor to listen for message using ready method; because this is the starting state.

See the "become" doc to see how to change the method that is receiving messages.

Why become ?

become word implies a state change. In he actor model, you can think of the state machine matrix as an UML's state/transition diagram:

  • some message makes your actor to transition to a new state
  • each state is able to receive a specific set of messages

Thus become will be useful elsewhere in the code...

TODO 3: SurfaceActor's ready state

Fill in the missing code to

  • iterate through surface config keys. The keys are Mowers, values are the list of commands Mower as key must execute.
  • for each Mower key, start a MowerActor and send an ExecuteCommands message with the list of commands
  • then switch to working state

TODO 4: SurfaceActor's working state

In working state, SurfaceActor will receive request from MowerActors. It goal is to answer to MowerActor if it can go forward (the requested position on surface is free) or not (the requested position is occupied by another Mower).

This is where collisions are managed.

Finding if next position is free or not is given. You just need to implement

  • what to do if the result is "free"
  • what do to if the result is "occupied"
  • what to do if the result is occupied and we tried it to much time

See help in TODO 4.* comments

TODO 5: Let's try it

See the doc about creating an actor with props to create your actor system, your SurfaceActor and start it.

Ensure that log levels are properly configured to see the system live.

mower-akka's People

Contributors

fagossa avatar joe-mojo avatar njozwiak avatar

Watchers

 avatar  avatar  avatar

Forkers

ikempf

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.