This paper discusses the application of a neural-network scheme for the active control of building structures under seismic excitations. A new training technique is introduced to obtain an efficient control law for the actuation system. This approach provides training for the controller, avoiding the need of an extra neural network to emulate the system, as it is typically done with other training algorithms, mainly backpropagation. A compromising optimization can be achieved between different performance parameters, such as any selected function of the state variables versus the control-force requirements. This is achieved by means of a cost function analogous to those used in optimal control. For each cycle of the training process, the performance of the controller is evaluated in terms of the specified cost function. The neural-network weights are appropriately improved according to the change in the cost function assessed during each cycle. The control strategy is evaluated using a simplified model of a multi-story building equipped with an active tuned-mass damper. Numerical simulations show the effectiveness of the proposed control scheme to reduce the seismically-induced responses.