This is a placement policy for the KDE window manager of an old version of KDE. This code will not work with the newer versions of KDE, at least not without some modifications.
The idea behind such a placement policy is to train a simple neural network on the behaviour of the 'Smart' placement to start with. When a new window is placed, if the user isn't happy and moves it to a new position, the network is trained on this new input!
We might then hope the network will be able to adapt itself and predict the prefered positions after some time.
The source code is provided here for information and archive only. It will not work with the newest versions of KDE, but you may still have fun trying to adapt it if you wish :)
The network used is a 2-layer MLP with 10 hidden units. There are 23 inputs; the number of windows on this desktop (1), the position and size of the 5 largest windows (20), and the size of the window to place (2). There are 2 outputs, the coordinates of the window to place. All the position and size are scaled by the desktop geometry, so as to achieve resolution independancy.
The initial training was done mainly by simulated annealing, and stochastic gradient descent is used for the online training.
All this was done just to implement practically some stuff from the lectures I received in Aston university back in 1999. This was both a simple and fun way to do neural networks :)
I would now certainly not choose a multi-layer perceptron to do the job, as these beasts deal badly with discontinuities. At the time, one of my teachers later commented on that possible reason for the poor performances.
I'm now back to doing research, and actually I think that using an AI algorithm for a window placement policy was both a fun and an innovative idea. Even all these years later, nobody has done such a thing yet!
If anyone feels like implementing an AI algorithm, I'd now recommend not using an MLP. Some recent advances in artificial neural networks would suggest using a spiking neural network for that task, tough the results might still no be really on par with the "smart" placement policy. Other possible AI algorithms that may work for such a situation could be the classical and simple decision trees. They are much less fun to work with, and barely qualify as AI anymore, but at least they could provide a decent job compared to the smart placement.
However, I think that something really innovative and fun would be much better than something that just emulates another "smart" algorithm. A large random recurrent spiking neural network might just prove to be fun enough to watch, or perhaps a voting system based on the collective behaviors of ants, or whatever.
Please let me know if you would like to work on this project or another related one, there are probably many areas of desktop systems that would be nice to hack with AI!