Logistics

This is an individual assignment, so you should complete it on your own, though you are able to get help from many sources as detailed in the syllabus.

This assignment is due on Friday Oct 14th at 10pm. As with all assignments, you will have the opportunity to revise this assignment based on the feedback that you get.

Goal

The goal of this assignment is to demonstrate your understanding of digital evolution. You’ll be making a digital evolution project that runs in the web browser using the SignalGP-Lite framework, which is built with the Empirical framework.

Setup

The setup process will at first be the same as for the previous assignments, except you’ll use the Digital Evolution Github Classroom link on Moodle. Follow the same steps as described in the previous assignments after that.

Getting Web to Work

Once you are ready to build the web version of your assignment, you’ll need to add a few things to your repository.

  1. Make sure that you’ve initialized all your submodules:

     git submodule update --init --recursive
    
  2. You’ll then be able to go in to the emsdk folder and do the usual emsdk setup:

     ./emsdk install 3.1.2
     ./emsdk activate 3.1.2
     source ./emsdk_env.sh
    
  3. You’ll also need to make your own compile-run-web.sh file in the top level of your repository. Make a file with that name exactly (the grader will rely on that name!) and add the following lines to it:

     emcc -std=c++17 -IEmpirical/include/ -Isignalgp-lite/include/ -Os --js-library Empirical/include/emp/web/library_emp.js -s EXPORTED_FUNCTIONS="['_main', '_empCppCallback', '_empDoCppCallback']" -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'cwrap']" -s NO_EXIT_RUNTIME=1 web.cpp -o de_web.js
     python3 -m http.server
    
  4. Your web animation C++ code should all go into a file named web.cpp since that is what is specified in the compile-run-web.sh line above.

  5. Finally, you’ll also need to make your index.html, which should have the Javascript files from the Config lab:

     <head>
     <!-- styles -->
     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/styles/default.min.css" integrity="sha384-s4RLYRjGGbVqKOyMGGwfxUTMOO6D7r2eom7hWZQ6BjK2Df4ZyfzLXEkonSm0KLIQ" crossorigin="anonymous">
     <link rel="stylesheet/less" type="text/css" href="https://cdn.jsdelivr.net/gh/devosoft/Empirical@26dbbe3/include/emp/prefab/DefaultPrefabStyles.less" integrity="sha384-sq4+UmPTB19bGYpxuyAuWqL98Vu3/sP0K189i4Q9YjtoT75W6Y8SSaAE1hfsMfVq" crossorigin="anonymous">
    
     <!-- scripts -->
     <script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script>
     <script src="https://cdnjs.cloudflare.com/ajax/libs/less.js/4.1.3/less.min.js" integrity="sha512-6gUGqd/zBCrEKbJqPI7iINc61jlOfH5A+SluY15IkNO1o4qP1DEYjQBewTB4l0U4ihXZdupg8Mb77VxqE+37dg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
     <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/highlight.min.js" integrity="sha384-lSDOH2m65GTr3YMjQmtQouX6jV/Xb6y1HNztdW5HsGrpSXTLt6CL/BesSu+6M0ow" crossorigin="anonymous"></script>
    
     <!-- feature specific scripts -->
     <script src="https://cdn.jsdelivr.net/gh/devosoft/Empirical@26dbbe3/include/emp/prefab/HighlightJS.js" integrity="sha384-Zfh3BfaS9t0VPODZ8NapeEOmrLkeT64Q28jbnxFLJ6ebS23iYWGoydQTNkp1qLUl" crossorigin="anonymous"></script>
     </head>
    

    Yourbody with whatever containers you want (see the config lab for details) and the Javascript generated by emscripten:

     <script type="text/javascript" src="de_web.js"></script>
    

Fixing Version Issues

These are the steps needed to fix your repository to have the versions of Empirical and SGP-Lite that are needed.

First, you need to checkout and pin the new version of SGP-Lite with all the recent changes that have been made:

cd signalgp-lite
git pull origin master
cd ..
git add signalgp-lite

Then you need to add a submodule for the new version of Empirical and get it all pulled down at the top level of your repository:

git submodule add https://github.com/devosoft/Empirical.git
git submodule update --init --recursive

Now you need to change your compile-run-web.sh so that it has the correct include paths (just remove what you have and put this in):

emcc -std=c++17 -IEmpirical/include/ -Isignalgp-lite/include/ -Os --js-library Empirical/include/emp/web/library_emp.js -s EXPORTED_FUNCTIONS="['_main', '_empCppCallback', '_empDoCppCallback']" -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'cwrap']" -s NO_EXIT_RUNTIME=1 web.cpp -o de_web.js
python3 -m http.server

Finally, you need to define two macros to tell the compiler that you want to use the vendorizing version of SGP-Lite and to ignore the 2000+ warnings that causes. These two defines need to be the absolutely FIRST thing in your web.cpp file:

//in web.cpp at the VERY top
#define UIT_VENDORIZE_EMP
#define UIT_SUPPRESS_MACRO_INSEEP_WARNINGS

That’s it! You should now be able to run compile-run-web.sh without errors and using the latest and greatest GUI tools.

Supplemental info

As you are working on this project, you may find the supplemental material section F of this paper a helpful reference for what operations are available and what they do, as well as the SGP-Lite lab.

Assignment Specification

For this assignment, you need to add on to the code that I’ve provided so that, when the new compile-run-web.sh file is run, a browser-based digital evolution system runs in the browser. This will require you to write code for tasks that the organisms can do to gather resources and the visual interface of the system. This project is somewhat constrained so that you don’t have to implement most of the pieces of a digital evolution system and can focus on what tasks you want the organisms to be rewarded for and how you want to visually represent your system.

Assessment

To demonstrate proficiency for this assignment, your submission should:

  • Run and display a digital evolution system when the compile-run-web.sh script is run, using the web-browser, SignalGP-Lite, and Empirical libraries
  • Handle the toroidal spatial structure correctly (i.e. organisms reproduce and/or move correctly across the edges of the grid when using a grid spatial structure)
  • Have at least two tasks that organisms evolve to perform within a reasonable amount of time (running your code for about 10 minutes) which are visually represented in your GUI
  • Have well-documented and styled code
  • Specify in a file README.md what your tasks are and how they are visually represented in your GUI

To demonstrate mastery for this assignment, your submission should do everything from the proficiency category, as well as:

  • Have at least five tasks that organisms can evolve to perform
  • Have a configuration panel on the GUI that allows the user to change at least two settings that impact the evolution of the population
  • Have text on your webpage explaining the tasks and what the user is seeing

Submitting

You will submit your assignment by pushing your code to the GitHub Classroom repository that you start from. If you are unsure how to use Git to push your code, please ask!

Getting Help

Remember that you can and should ask for help on everything from annoying C++ bugs to Git to “is this a reasonable artificial ecosystem to implement?” The CampusWire is probably the best place to ask, as long as you don’t have to share too much of your code to do so, because you’ll get faster responses on average. You are also welcome to come to drop-in hours, Zev’s help hours, and schedule a one-on-one meeting if that works better for you.

Acknowledgements

Most of the starter code was implemented by Sylvie Dirkswager, thanks Sylvie!