The context of this paper is programmable matter, which consists of a set of computational elements, called particles, in an infinite graph. The considered infinite graphs are the square, triangular and king grids. Each particle occupies one vertex, can communicate with the adjacent particles, has the same clockwise direction and knows the local positions of neighborhood particles. Under these assumptions, we describe a new leader election algorithm affecting a variable to the particles, called the k-local identifier, in such a way that particles at close distance have each a different k-local identifier. For all the presented algorithms, the particles only need a O(1)-memory space.there exists a probabilistic algorithm that determine a leader (and in particular for a ring) with probability 1 [5].Several projects aim to build programmable matter prototypes. One of such projects [20,23], financed by the french National Agency for Research, aims to build cuboctahedral particles able to deform them-selves in order to move. This project can be split in two phases, one consists in manufacturing the hardware of prototype matters, the second consists in proposing algorithms for programmable matter. The final goal of this project is to sculpt a shape-memory polymer sheet with programmable matter. In the continuity of the algorithm phase of this project [20], we propose algorithms for the self-configuration, i.e., in order to create identifiers and spanning trees.In the context of programmable matter [3,4,14,18,23,24], it is supposed that a network can contain several millions of modules and that each module has possibly a nano-centimeter size. These two facts lead us to believe that even a O(log(n))-space memory for each module, n being the number of modules, is not technically possible. Also, because of the large number of modules, it can be very challenging and time consuming to implement a unique identity to the modules when they are created. In this context, we suppose that the modules can not store a unique identity, i.e., that the network is anonymous. In this paper we propose deterministic O(1)-space memory algorithms to determine a leader in the network and to create k-local identifiers of the particles. A k-local identifier is a variable affected to each module of the network which is different for every two modules at distance at most k. Note that leader election [5, 13] plays a significant role in numerous problems of programmable matter.Our contribution is the following: we introduce a leader election algorithm based on local computations and simple to implement. This algorithm works when the structure the particles form has no hole (see Section 3). Also, since the algorithm can be described as a sequence of local computations, its limits (message complexity, required memory-space, etc) are easy to analyze. We present a distributed algorithm to construct a spanning tree in the context of programmable matter and, also, a distributed algorithm to re-organize the port numbers of the particles. Finally, we presen...