Assignment 3
Assignment 3
The algorithm projects will generate .so files (shared objects, library
.files)
The output file does have additions, colored in blue below. An added
“InDock” should have a value of either the text TRUE or FALSE, for
whether the robot is in the docking station when the simulation
.ended (TRUE) or not (FALSE)
>NumSteps = <NUMBER
>DirtLeft = <NUMBER
>Status = <FINISHED/WORKING/DEAD
>InDock = <TRUE/FALSE
>Score = <NUMBER
:Steps
list of characters in one line, no spaces, from: NESWsF – the small s <
is for STAY, NESW are for North, East, South, West. F is for Finished -
>”only if the algorithm actuallya ctually returned “Finished
API
-------------------------------//
common/AlgorithmRegistrar.h //
-------------------------------//
using AlgorithmFactory =
;>)(>std::function<std::unique_ptr<AbstractAlgorithm
{ class AlgorithmRegistrar
{ class AlgorithmFactoryPair
;_std::string name
;_AlgorithmFactory algorithmFactory
:public
name_(name), :
}{ algorithmFactory_(std::move(algorithmFactory))
;}
;std::vector<AlgorithmFactoryPair> algorithms
:public
;algorithms.emplace_back(name, std::move(algorithmFactory))
}
auto begin() const { return algorithms.begin(); }
;}
-----------------------------------//
simulator/AlgorithmRegistrar.cpp //
-----------------------------------//
;AlgorithmRegistrar AlgorithmRegistrar::registrar
AlgorithmRegistrar& AlgorithmRegistrar::getAlgorithmRegistrar()
{ return registrar; }
------------------------------------//
algorithm/AlgorithmRegistration.h //
------------------------------------//
{ struct AlgorithmRegistration
AlgorithmRegistration(const std::string& name, AlgorithmFactory
{ algorithmFactory)
)(AlgorithmRegistrar::getAlgorithmRegistrar
;registerAlgorithm(name, std::move(algorithmFactory)) .
}
;}
Code example:
https://coliru.stacked-crooked.com/a/695a7e8a343ca22b
:Your tasks
>house_path=<housepath-
>algo_path=<algopath-
The two command line arguments may appear in any order, you are
.not required to have support for spaces around the equal sign
For the house files, the program will try to open all files with
suffix .house
For the algorithm files, the program will try to open (dlopen) all files
with suffix .so (make sure to also close them with dlclose at the end
.of the run to avoid leaks)
In case any of the two is missing, the program shall look for the files
.which didn’t get folder location in the current working directory
Error Handling
Additional Requirements
Bonuses
You may be entitled for a bonus if winning one of the first positions
in the class algorithm competition (no need to add a bonus.txt file
.for that)
:IMPORTANT NOTE
In order to get a bonus for any addition, you MUST add to your .1
submission, inside the main directory, a bonus.txt file that will
include a listed description of the additions for which you request for
.a bonus
Q&A
A: The step that the robot cannot perform, as it is DEAD, should not
be counted as a step. In the case where the simulation starts and
the robot is DEAD after one step, NumSteps shall be 1. Note that the
score formula in this case is using anyhow the MaxSteps (as a
.sanction for the algorithm reaching DEAD situation)