The present source code was used to test for the influence of matching habitat choice on species response to climate change. All the simulations presented in the paper "Matching habitat choice promotes species persistence under climate change" by F. Pellerin, J. Cote, E. Bestion and R. Aguilée in Oikos 2018 (doi: 10.1111/oik.05309) were run with this code. The code is encoded in C++, using the GNU Scientific Library for random numbers generation. It is composed of the following files: - map: it contains all functions to generate a two dimensional landscape with thermal gradient. It also allows to increase temperature at each location during climate change - indiv: it contains functions to generate individuals, set and get their characteristics and produce new individuals during reproduction - popul: it contains functions to generate populations on each cell of the map. These populations could be empty or made of individuals. It also contains functions of dispersal, reproduction and survival. Lastly, all the functions to get information about population compositions are provided here. - functions: functions to calculate dispersal probabilities, survival probabilities and fitness are provided here. - dyna: it contains population dynamics loops. It is the final code allowing simulations to run. - constants: a file summarizing all parameters. These parameters can be change. The parameters provided now are the default parameters. - Makefile: a file to compile all the previous files together in a "dyna.sh" executable file. You can use it by running "make -f Makefile" line code in a terminal The code can be run through the "./dyna" command in a terminal.