Computers with different software and programming language is necessary to learn about machine learning and artificial intelligence. PhD student Øyvind Sigmundsson Skøyen explains to Jakob, August, Magnus and Jørgen how to program the game Snake so that the snake always survives.

Programming to understand artificial intelligence

Students learning Artificial Intelligence, Machine Learning and Neural Networks

This article was originally published in Norwegian on our School Collaboration website.

How can programming, artificial intelligence and machine learning help us understand the human brain?

Four students from Ullern Upper Secondary School spent two days in the beginning of March on a placement in the Department of Physics at the University of Oslo. Jakob, August, Jørgen and Magnus learned how to program the snake in the game Snake to survive. At the same time, they learned about artificial intelligence, neural networks and machine learning.

Every spring, Professors Anders Malthe-Sørenssen and Marianne Fyhn at the University of Oslo receive eight students from Ullern Upper Secondary School on a placement.

Marianne Fyhn’s research group consists of some of the leading neuroscientists in the world. The four biology students Chiara, Eline, Tora and Eilin from Ullern Upper Secondary School spent the placement training rats and learned how research on rats can provide valuable knowledge about the human brain.

Anders Malthe-Sørenssen is the Director of CCSE (the Center for Computing in Science Education), where the students Magnus Trandokken, August Natvik, Jørgen Hamsund and Jakob Weidel were on another placement.

“There are three PhD students here, who are teaching the Ullern students. At the end of the day, they will gain a better understanding of what artificial intelligence is. We wish to explain the concept to them and give them an insight into what machine learning, neural networks and programming are,” said Malthe-Sørenssen.

  • Scroll to the bottom of this page to read the definitions for machine learning, neural networks and artificial intelligence.

Malthe-Sørenssen and the PhD students tested a new teaching tool on the Ullern students. If it is successful, more students will be able to access it to learn about artificial intelligence. Malthe-Sørenssen and his research group also try to improve the teaching of advanced mathematics, physics and programming in upper secondary schools.

Students learning artificial intelligence, machine learning and neural networks

Øyvind Sigmundsson Skøyen (in the middle) was one of the PhD students that taught the students from Ullern Upper Secondary School. Here, he is helping Jakob Weidel, who is in his first year. To the right is August Natvik, who is graduating this year. Photo: Elisabeth Kirkeng Andersen

Making the snake immortal

Jakob, Magnus, August and Jørgen programmed the game Snake in the programming language Python. This is a programming language that is available for free, an “open source”. You can download it here.

The point of the game Snake is to keep a snake alive for as long as possible. It lives in a square, where it eats candy so that its tail grows. The purpose of the game is to make sure the snake doesn’t crash into itself while it is growing because if it crashes, the snake dies. But it is not that easy. Try it yourself here.

“The students will program the snake so that it can learn where it is smart to move to eat the candy, while at the same time avoiding to crash into its growing tail. It is a good way to understand a little artificial intelligence and machine learning,” said Malthe-Sørenssen.

The three PhD students Sebastian Winther-Larsen, Øyvind Sigmundsson Skøyen and Even Marius Nordhagen were there to teach the Ullern students.

Øyvind had just finished showing the students how to programme the snake when it was Even’s turn to teach.

“What du you already know about machine learning?” Even asked.

“I have seen a little bit on YouTube,” Jakob replied.

“I know the theory, but I haven’t tried it myself,” Magnus said.

Even explained that he would present the theories behind machine learning and neural networks first, and then let the students create a neural network for Snake.

“Linear regression – a theory we often use in mathematics – is a simple form of machine learning. It is about producing a function that gives us the best line between two points. We use something called the method of least squares,” Even said.

Ullern students learning artificial intelligence, machine learning and neural networks.

Espen Marius Nordhagen (to the right) explains to the students from Ullern that regression is a simple form of machine learning. August Natvik is following closely. Photo: Elisabeth Kirkeng Andersen

Even explained that machine learning is used in image analysis. A computer can be taught to recognise and see the difference between several objects in a picture. The objects can be cars, bikes, humans, or other things. The computer can then be taught to create the images, which are then called generative models. Voice recognition, such as the virtual assistant Siri for iPhone users, is also based on machine learning, just like self-driving cars and buses.

“In order to understand artificial intelligence, you have to know what a neural network is. The concept is inspired by biology, neuroscience, and how human beings learn and remember. A neural network is a simplification of the human brain. The brain is in reality much more complicated,” Even explained.

“What is actually the difference between machine learning and artificial intelligence?” Jørgen asked.

Even explained that regression is machine learning, but not artificial intelligence.

“If you have a neural network with several layers, a so-called ‘deep neural network’, it is artificial intelligence. Then you will observe that something is happening with the data you receive from the neural network, it will be something you do not understand and cannot model, but it is consistent with reality,” Even said.

Learned new subjects

Magnus, August and Jørgen are all in the third year and have specialised in the natural sciences, with different combinations of mathematics, physics, technology, research, programming and computer modelling.

After graduating, all three of them will go to military school. Afterwards, Jørgen and Magnus are tempted to study at NTNU.

“The Industrial Economics programme at NTNU seems really good. Maybe I will combine it with the Entrepreneurship Programme, which is also at NTNU. Then I can start my own company after I finished studying. I am also thinking about a career in the military,” said Magnus.

The Ullern students agreed that the placement at the Department of Physics had been difficult, but fun and educational too.

“They are really good at teaching here. It has been difficult, because we haven’t studied these subjects before and everything new is always difficult,” said Jørgen.

Jakob Weidel is still in his first year and is thinking about studying the same subjects as the other three Ullern students. He was asked to participate in the placement after he helped Tom Werner Halvårsrød, the IT administrator at Ullern Upper Secondary School, to programme Excel sheets, which are used in the school.

“I have made a few apps and developed a few websites and used different types of programming languages. I have never used Python before, so it has been fun to learn something new,” said Jakob.

(image caption) Anders Malthe-Sørenssen is a professor at CCSE (the Centre for Computing in Science Education) at the University of Oslo. He and his research group are active in many different areas of research, including improving how physics is taught and understanding how the brain works through advanced mathematical models. Photo: Elisabeth Kirkeng Andersen.

Anders Malthe-Sørenssen is a professor at CCSE (the Centre for Computing in Science Education) at the University of Oslo. He and his research group are active in many different areas of research, including improving how physics is taught and understanding how the brain works through advanced mathematical models. Photo: Elisabeth Kirkeng Andersen

Neural networks and neuroscience

Malthe-Sørenssen’s and Fyhn’s research groups collaborate in a field of biology and physics, which is about research into how the human brain works and neural networks, in the projects DigiBrain and CINPLA. CINPLA is an acronym for Centre for Integrative Neuroplasticity.

“Here at the Department of Physics, we create computer models of neural networks. Then, we compare our models with Marianne’s discoveries about how the brain works from her studies on rats and mice. So far, we have seen that our models give a good picture of what is actually happening in the brain, but we are far from finished,” says Malthe-Sørenssen.

His popular research group receives over 1 000 job applications every year, but they want to keep prioritising student placements.

“We are dedicated to contributing to improving the programming skills in schools. One of our employees has developed the new subject and the syllabus for programming and computer modelling, which will be implemented in upper secondary schools by autumn 2020. Programming will then be used to teach several subjects, including mathematics,” Malthe-Sørenssen says.

He thinks it is good to contribute to raising the level of skills in the local schools around the Department of Physics at the University of Oslo.

What is a placement?

Oslo Cancer Cluster and Ullern Upper Secondary School have an active school collaboration project. The collaboration gives students at the school the opportunity to take part in work placements at different companies and research groups at Oslo University Hospital, at the University of Oslo and with members of Oslo Cancer Cluster.

On the placements, the students get to learn about different subject areas directly from experts and they get the opportunity to do practical laboratory work. The purpose of the placements is to give the students an insight into the practical everyday life of different professions and what career opportunities that different academic degrees hold.


Neural Networks: A neural network is a group term for data structures, and their algorithms, that has been inspired by the way nerve cells in the brain are organised. Neural networks are among the key concepts in machine learning and artificial intelligence.

Machine learning: Machine learning is a special area within artificial intelligence, where you use statistical models to help computers to find patterns in large data quantities. The machine “learns” instead of being programmed.

Artificial intelligence: Artificial intelligence is information technology that adapts its own activity and therefore seems intelligent. A computer that is able to solve assignments without instructions from a human on how to do it, has artificial intelligence.

Sign up to our monthly newsletter