Will the ability to code in Python get you a technology job in financial services? Yes. When we last looked at our CV database, there were ‘only’ 7 Python CVs for every Python job advertised on the site – fewer than for any other coding language.
If you want to be assured of success, however, you’ll need to be good, preferably exceptional. And one Oxford University student has shown just what exceptional Python coding skills look like.
Alex Hamed Ahmadi, a graduate student at Oxford University who previously worked as a core strategist at Goldman Sachs and assistant vice president at Barclays Capital, is the winner of Man Group AHL’s coding competition. When the competition was launched last year, Man invited students of any age and level to write code to control a player on ‘Hexplode,’ an old-school computer game in which two players take place counters in cells on a hexagonal board. When the number of tokens in each cell reaches a critical level, the cell ‘hexplodes’ and distributes them to adjacent cells. The winner removes all the other player’s counters from the board, or forces the other player to make an invalid move, or has to wait more than five seconds for the other player to make a move. You can read the full rules here.
Ahmadi’s winning solution is shown in the code below (click on the image for the whole thing). What makes it special? “At its core my algorithm is an iterative deepening Alpha-Beta NegaScout search, with a transposition table and a decent move-ordering system,” he tells us.
Ahmadi says being a good coder is about more than attending a four month coding bootcamp. “The ability to “just write code” is easily learned, but learning to write high quality code with few or no bugs is something that can takes years of experience,” he says. “There are elements of discipline: The ability to force yourself to do things you may not want to do such as write tests, read and re-read code to check for errors, and to learn new methodologies that improve the way you work. Finally you have skill sets specific to certain situations: For example, the ability to quickly read and modify somebody else’s code.”
Accordingly, Ahmadi didn’t take the most obvious approach to the Hexplode challenge. “I experimented with various methods for pruning, sorting of moves, aspiration windows, and of course the evaluation function,” he says. “One of the fundamental design choices of my algorithm was to drop a highly complicated evaluation function I had developed, in favour of a simplistic function that was fast enough to allow the algorithm to search 1-2 levels deeper. I also used a bit of machine learning to tune the coefficients used in scoring. Finally, I had a number of “support” programs such as a reference implementation, a database of positions for benchmarking, and unit testing in order to test and verify the correctness of performance optimizations.”
Think you’re an expert at coding in Python? Look at Ahmadi’s code below (click on the image, or here, for the full text), and think again.
The code bundle (the “Code”) has been provided for information purposes only and AHL Partners LLP retains full ownership of any and all intellectual and industrial property rights in the Code. Insofar as permitted by law, neither AHL Partners LLP nor any person or entity associated with it shall in any circumstances be responsible or liable to any individual or entity or accept any liability for any loss incurred or damage howsoever caused to any individual or entity as a result of downloading or using the Code in any way.