Implementation of random snakes generation logic