SFourmi – Super Ant

SuperFourmi (SuperAnt)

a multi-agent ant simulator from the last millenium (!) – Github link

History

It was the first C++ project I developped in highschool (Michel Tran Ngoc, Manik Bhattacharjee for conception and code, graphics by Tristan Millner and some code refactoring by François Leiber) – between 1998 and 2002.

Its old website is still online, last updated 18 years ago !

We did read books about ants from the national library, observe ants in nature and take pictures.

 

 

 

 

The project was a learning opportunity for object-oriented programming in C++, graphics programming in Windows and Linux, using DirectX, GTK and finally SDL.

Basic explanation

Ants explore their 2D world in search of food that they bring back to the anthill.

Each ant independently assesses its situation and environment, and according to its class (worker, queen, nurse, warrior) does the appropriate task. They leave pheromone trails (blue arrows for food tracks, red dots for danger), move on the map, get food (yellow patches) and breed new ants (from larva) underground in their anthill. They can kill other insects and ants from other anthills (small colored dots for dead insects).

The interface shows both a minimap with all ants (on the left), and a local view (right). An ant can be selected to see its characteristics (on the left) and the ant’s image changes when it is carrying food.

Worker ants retrieving food and leaving/following pheromone tracksWarrior ant next to a dead insect and danger pheromones Underground, nursing ants feed the larva next to the queen while workers bring food in

Current status

I recently (february 2020) tried to make it run again, and I was able to compile it using old librairies still distributed on linux.

The latest 2D version was compiled after some code tweaks (it turns out that 64 bits computing and badly coded C++ 98 don’t work together that well). It runs pretty well, even though there is no hardware acceleration for the 2D display.


Cleaning up the source code would be a lot of work, but it would be nice to see it running with newer libraries such as SDL2 with hardware acceleration, with a clean C++-20 code and taking advantage of parallel processes through multithreading (or even GPUs) !

The 3D version that Michel developped in the last year does compile but crashes and does not seem to work.

All source code was uploaded to Github, the new licence is GNU Affero GPL v3.

Posted in software project | 1 Comment

Tracing an old train track in OpenStreetMap’s Umap

From 1901 to the beginning of the 1950’s there was a train line between the french village of Egreville and the larger city Sens. Because I have some with a village on the track I wanted to learn more about it. The tracks were removed but amateurs gathered a lot of data about the surviving buildings and the path. I was also able to use satellite and aerial images (IGN for historical and recent ones, Bing Maps and Google Maps).

This is the result of this work, but there might still be some mistakes.

See full screen

Sources :

http://www.inventaires-ferroviaires.fr/hd77/77168.a.pdf
– Google maps, Bing maps with some traces (limits of fields and dark shapes in the fields marking the old track)
– historical and modern aerial pictures and maps from french IGN https://remonterletemps.ign.fr/comparer/basic?x=3.257303&y=48.221596&z=15&layer1=ORTHOIMAGERY.ORTHOPHOTOS.1950-1965&layer2=GEOGRAPHICALGRIDSYSTEMS.MAPS.SCAN50.1950&mode=doubleMap
– Data from online forum http://www.passion-metrique.net/forums/viewtopic.php?f=2&t=7647&hilit=CFY&start=45

Posted in Misc. | Leave a comment

setGID, ldd and library not found

Today I was bewildered by a very unusual problem. Maybe this will help someone else with the same problem !

I was running an executable as myself and it was working perfectly. I had to run it as root to access some protected directories, so I used sudo:

sudo myprogram

I got

error while loading shared libraries: libsomething.so: cannot open shared object file: No such file or directory

Ok, this must be because sudo won’t use the LD_LIBRARY_PATH that I defined, so I try:

sudo -E myprogram

Same error… Ok, I will try to check what’s going on as root, with ldd.

sudo bash
export LD_LIBRARY_PATH=/path/to/my/lib/
ldd myprogram
      libsomething.so  -> /path/to/my/lib/libsomething.so
# Ok ! Everything works as expected, I can run the program
./myprogram
error while loading shared libraries: libsomething.so: cannot open shared object file: No such file or directory

ldd finds all necessary libraries, but the executable still fails to run because it cannot find a library ??

Ok, maybe I don’t have the rights to read or execute the library or the directories in its path ?

chmod -R a+rX /mydirectory does not change anything, even though any user can now access the libsomething.so file.

After a LOT of searching around, I found an explanation : if your executable or library is setuid or setgid, because of security implications, LD_LIBRARY_PATH won’t be used !

Finally, I did a find /mydirectory -type f -exec chmod g-s {} \; to remove the setGID bit on all files (but keeping it on directories). SetGid bit was set to force new files to  belong to the directory’s group : it was only necessary to setgid the directories, not the files !

 

 

 

Posted in TechTips | Leave a comment

Virtual tour of Louis-le-Grand high school (1996-1998)

Project LLG

I decided to dig up an old project, a virtual tour of my highschool in 1997-1998 and to convert it to a html5/javascript/css web project to learn more about these languages.
At the beginning, this was about visiting the highschool from picture to picture in a Visual Basic 6 software.facadeDeCote

Project team

  • Idea, conception & programming: Manik Bhattacharjee
  • photo : Manik Bhattacharjee and Michel Tran Ngoc
  • GCD compressed image format and C library : Laurent Demonet
  • icons, 3D modeling of a classroom : Tristan Millner

Making of

Pictures were taken with analog manual SLR cameras, digitized using a flatbed scanner and converted to GCD by myself on a Pentium 133 MHz computer. I then used a small program to define click zones for each image. A few pictures were taken using a low-res digital camera lended by a friend (Habib Shoukry), a Sony that stored the pictures directly on a floppy disk.

Tristan Millner created the UI design, some icons and a 3D model of a classroom (I just have a screenshot left of that). 3D modeling was done to create a 3D game, doom-style, in our highschool. But the project stopped there…

We were given access to the scientific museum and the old library, but I did not find those pictures yet.

HTML5 conversion

This project dating from 17 years, I lost some data in the mean time. I don’t have the digitized JPEG files (deleted probably because the hard drive was full, and maybe on some old CD-R somewhere), the original film is probably in a cellar and I still miss a number of pictures in the version I recovered. If I find better data on old CD-R or ZIP disks, I will update the online version.

En 1997, Visual Basic could not display JPEG images, only BMP. But those files needed so much space that it was not possible to store all files in BMP and having the whole project on one CD. Laurent Demonet offered to design a file format and C library using similar principles as GIF, with an OCX element to be inserted in Visual Basic UI. Image quality seemed ok at the time (reduced color palette and resolution sufficient at the time).
Fortunately I found the source code of the OCX control, so I wrote a C++ program to convert the old GCD files back to JPEG (thanks to Qt library).

The labels of images were saved in simple text files, but character encoding was windows 95 french encoding – CP1252. I thus converted these to UTF8 using iconv.

I did not recreate the original UI, but just wrote a simple HTML5 page using AJAX to get images and click zone data.

I still haven’t put the small highschool map with active points to start on different places… yet !

Posted in software project | Leave a comment

Ubuntu 15.04 : Adding a ppa behind a proxy

To install a new PPA (for example the KDE backports to have the latest stable KDE on Kubuntu 15.04) on a connection using a proxy for http/https access :

export http_proxy=http://myProxy:port
export https_proxy=http://myProxy:port
sudo -E add-apt-repository ppa:kubuntu-ppa/backport

The “-E” allows sudo to keep the environment variables defined for the proxy access.

To get apt to use the proxy, create a file /etc/apt/apt.conf.d/50proxy :
Acquire::http::Proxy "http://myProxy:port";
Acquire::https::Proxy "https://myProxy:port";

Posted in TechTips | Leave a comment

Gitlab behind a reverse proxy with SSL termination

I needed to install a git server with a web interface. I decided to install Gitlab Community Edition. But I had some trouble using it behind a reverse proxy that does SSL termination

  • I added a new virtual machine (VM) called GIT to my virtual machines server SERV. It contains a Debian minimal installation.
  • I installed the debian package Omnibus Gitlab 7.9 in GIT.
  • The VM GIT is connected to a (virtual) private network which allows SERV to access all its VMs.
  • Using iptables, SERV redirects port 1212 to port 22 of GIT. This gives me SSH access to GIT. In /etc/iptables/rules.v4
    -A PREROUTING -i eth1 -p tcp –dport 1212 -j DNAT –to-destination 172.16.0.5:22 -m comment –comment “Redirect port 1212 to GIT”
  • SERV serves multiple websites using a number of DNS names. For example, mysite.eu and mygit.eu will redirect to SERV’s IP address.
  • SERV runs NGINX as a reverse proxy with SSL termination. This just means that each request to https://mygit.eu is received by nginx which decrypts the https request and forwards it to GIT as an HTTP request. Thus, the outside address is HTTPS but from the viewpoint of gitlab, the coming request is HTTP. In /etc/nginx/sites-enabled/default for each server :
    server {
       listen 443;
       root /var/www/;
      server_name mygit.eu;
      index index.html;
      include /etc/nginx/include/basicsslconfig;
      ssl_certificate /etc/nginx/httpskeys/mygit.eu.pem;
      ssl_certificate_key /etc/nginx/httpskeys/mygit.eu.key;
      location / {
        proxy_set_header Host mygit.eu;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto http;
        proxy_set_header X-Forwarded-Ssl on;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://172.16.0.5:80/;
      }
    }
  • To access gitlab website, I just use https://mygit.eu
  • SSH access for git : to get this to work, I just set in /etc/gitlab/gitlab.rb gitlab_rails[‘gitlab_shell_ssh_port’] = 1212
    and the SSH URL displayed for a repository is ok and works.
  • HTTP access for git : if I set
    external_url ‘http://mygit.eu’
    The lack of https means that the url won’t work.
    But if i use https, gitlab will configure its own nginx as https server and the forwarded http request won’t work.

Workaround : the reverse proxy replies to http requests by redirecting to the https address. So even if the wrong (http) address is displayed, it will still work. In /etc/nginx/sites-enabled/default

server {
listen 80;
server_name mygit.eu;
# Temporary redirect while keeping the same request -> 307. Permanent redirect -> 301
return 301 https://mygit.eu$request_uri;
}

Real solution : there is a new setting (still not available in the debian package) to allow for this according to https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/nginx.md
nginx[‘listen_https’] = false

This should force the GIT nginx server to accept http and not https requests, even if external_url contains https.

Posted in TechTips | Leave a comment

Sciences en Marche 2 : Grenoble-Lyon

On october 4th 2014, Sciences en Marche militants from Grenoble went biking from Grenoble to Lyon.

Sciences en marche – Grenoble -> Lyon par m_b_38
Here is a map of what I did :
– In red, Grenoble-Rives on my bike. The bike was sent back to Grenoble on a train with a colleague.
– In blue, the sweep vehicle that started long after the bikers gets lost then goes to Eclose to meet the bikers
– In red, the sweep vehicle follows the bikers to Lyon’s ring road. The bikers ride alone to the city center, avoiding the ring road. The car parks near the river.
– In green, going on foot to the meeting point.

Link to the map

Same map (but small)

Voir en plein écran

Posted in Politics & society | Leave a comment

GpxPlot : first glimpse

GpxPlot software is a project to:

  • Display GPS tracks in 3D (from .gpx files)
  • edit them (cutting a link, moving or removing a point,  merge tracks, edit waypoints…)
  • Display a digital elevation model (DEM) for the map
  • Display satellite/aerial images mapped onto the DEM
  • Display OpenStreetMap vector data on the DEM (maybe also Mapnik-style OSM tiles)

GpxPlot is a follow-up of my OSM and SRTM data test using Python.

GpxPlot-2014-09-21GpxPlot-2014-09-21b

This is a 3D image of  Mount Rachais (near Grenoble, France) including:

  • 3D DEM from NASA SRTM data
  • Satellite/aerial (Bing Maps) image mapped onto the surface, but larger. Altitude is 0 outside SRTM data; this explains the “walls” all around the 3D surface. There is still a bug that creates an offset between the image and the surface (look at the shape of the Isère river crossing the roads on the left)
  • In red, a GPX track recorded while going up the moutain
  • Other tracks are roads and paths from OpenStreetMap.

The tools used are not ideal yet (3D display is a little slow and not always easy to use…), but here they are:

Python, PyQt4 for the GUI, Mayavi Mlab for 3D display, gpxpy to read GPX files, OpenStreetMap Python API, Bing Maps API, SRTM data

Here’s hoping I will have some time to continue this, and add open data from the city and region, thanks to the work of the GreLibre groups for around Grenoble (hoping for better DEM and images…)

Posted in Misc. | Leave a comment

Sciences en Marche

Le mouvement Sciences en marche est parti !

Voici la carte finale pour le trajet en vélo Grenoble-Lyon samedi 4 octobre :

Voir en plein écran

Posted in Politics & society | Leave a comment

Drobo after power cut : mstatus 98304

After an unexpected power cut during the weekend, both Drobo FS at work restarted (21 hours later when the power was restored) but the samba/windows shares could not be accessed.

When I tried my droboStatus script, everything was displayed normally, except for one line:

Overall status of the device 98304 = 11000000000000000b -> UNKNOWN STATUS – please see http://code.google.com/p/drobowebdashboard/wiki/ESATMUpdate#ESATMUpdate/mStatus

As the linked page does not give an answer, it seems that it means that everything is ok after a file system check (fsck) but the shares do not work.

A simple reboot with the button at the back of the Drobos was enough to get everything on line again.

Posted in TechTips | Leave a comment