Can a neural network learn to play hockey?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
togFox
Party member
Posts: 167
Joined: Sat Jan 30, 2021 9:46 am

Can a neural network learn to play hockey?

Post by togFox »

I've read about a dozen articles on how a NN works. 2 inputs. An optional bias. One output. Hidden layers. Activation function etc but every article so far fails to explain what the inputs are, how they are determined and why a sigmoid function that results in a 0/1 could be remotely valuable.

I'm obviously biting off a lot here, but, as a project and experiment, I'd like to see if a NN can replace the behavioural tree my bot hockey players use.

Can I fed into a single bot brain (a mini NN) the status of things around it (puck location, player proximity, velocity vectors etc) and then output the best course of action?

I have the sports game coded and it works. Bots already play each other with behavioral trees and a big finite state machine.

Time for next level. If I find a way forward I would do this incrementally with a small network and build it up over time to consider an ever increasing range of environment data (virtual world data) and an ever increasing range of outputs (actions).

However, I'm still puzzled over how all these articles talk about inputting 0 & 1 and getting back 0 & 1 and then assuming that means something.

(Also noting this is a Love2d forum and not a NN ) forum.
Last edited by togFox on Mon Feb 22, 2021 12:10 pm, edited 1 time in total.
User avatar
Davidobot
Party member
Posts: 1214
Joined: Sat Mar 31, 2012 5:18 am
Location: Cambridge, UK
Contact:

Re: Can a neural network learn to play hockey?

Post by Davidobot »

Yes, this is doable. Look at reinforcement learning and specifically TD3 or AC3 - it's quite a simple actor-critic model that works on continuous action spaces. If you already have bots, you could task the agent (or a group of them) to play against your bots or against each other.
My projects: Raycaster, love.js v11.3 port
itch page: link
My website: link
My library: LovelyMoon
togFox
Party member
Posts: 167
Joined: Sat Jan 30, 2021 9:46 am

Re: Can a neural network learn to play hockey?

Post by togFox »

Well, on your advice I took a deep dive into AC3 and I can see it is a perfect fit and the next few months will disappear into research, maths and trial and error.

Thanks for removing me from my family and life in general. Lolz. :=) Let's see what comes of it.
User avatar
Davidobot
Party member
Posts: 1214
Joined: Sat Mar 31, 2012 5:18 am
Location: Cambridge, UK
Contact:

Re: Can a neural network learn to play hockey?

Post by Davidobot »

togFox wrote: Mon Feb 22, 2021 9:53 pm Well, on your advice I took a deep dive into AC3 and I can see it is a perfect fit and the next few months will disappear into research, maths and trial and error.

Thanks for removing me from my family and life in general. Lolz. :=) Let's see what comes of it.
Oops, there was a typo. It is A3C, not AC3. My bad!
My projects: Raycaster, love.js v11.3 port
itch page: link
My website: link
My library: LovelyMoon
togFox
Party member
Posts: 167
Joined: Sat Jan 30, 2021 9:46 am

Re: Can a neural network learn to play hockey?

Post by togFox »

Thanks. I worked it out. I couldn't find any meaningful articles that explained how to code this. All articles and blogs talk about the theoretical trainer and asynchronous agents - which is great, but I'll need to sleep on this and hit up some NN forums somewhere.

Thanks.
User avatar
Davidobot
Party member
Posts: 1214
Joined: Sat Mar 31, 2012 5:18 am
Location: Cambridge, UK
Contact:

Re: Can a neural network learn to play hockey?

Post by Davidobot »

There are plenty of implementations online. You can either follow the original paper: https://arxiv.org/pdf/1602.01783.pdf

Or look at the many pytorch implementations: https://github.com/ikostrikov/pytorch-a3c

You'll have to implement a lot of NN functions in Lua though, probably using something like Autograd (https://github.com/twitter/torch-autograd/) as a base.
My projects: Raycaster, love.js v11.3 port
itch page: link
My website: link
My library: LovelyMoon
togFox
Party member
Posts: 167
Joined: Sat Jan 30, 2021 9:46 am

Re: Can a neural network learn to play hockey?

Post by togFox »

Thanks. After reading many many many very high level papers, blogs, articles, and then switching to more articles demonstrating python, I ALMOST gave up.

I then happened across this github: https://github.com/FlamingArr/luann/com ... 988ab7415c

It is a working demonstration that not only works with LOVE - it actually requires LOVE. :)

Now, sadly, it prints a lot of guff to the console that I don't understand yet but I now have working code I can start to unpick and unravel. :)

[also noting the github code is for an ANN - not a A3C. Baby steps]
Post Reply

Who is online

Users browsing this forum: No registered users and 33 guests