This paper presents an algorithm for real-time building of a local grid-based elevation map from noisy 2D range measurements of the Hokuyo URG-04LX miniature laser scanner. The terrain mapping module supports a foothold selection algorithm, which employs a polynomial-based approximation method to create an adaptive decision surface. The robot learns from simple simulations, therefore no a priori expert-given rules or parameters are used. The acquired terrain map and planned footholds enable the robot to walk more stable, avoiding slippages and fall-downs.