Page 1 of 1

Can a neural network learn to play hockey?

Posted: Mon Feb 22, 2021 9:26 am
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.

Re: Can a neural network learn to play hockey?

Posted: Mon Feb 22, 2021 11:31 am
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.

Re: Can a neural network learn to play hockey?

Posted: Mon Feb 22, 2021 9:53 pm
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.

Re: Can a neural network learn to play hockey?

Posted: Tue Feb 23, 2021 3:08 pm
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!

Re: Can a neural network learn to play hockey?

Posted: Tue Feb 23, 2021 6:17 pm
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.

Re: Can a neural network learn to play hockey?

Posted: Wed Feb 24, 2021 5:11 pm
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.

Re: Can a neural network learn to play hockey?

Posted: Thu Feb 25, 2021 10:21 am
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]

Re: Can a neural network learn to play hockey?

Posted: Thu Oct 14, 2021 3:48 am
by knorke
This is not about NN but I read the posts about your sports game and was reminded of this project:
https://sourceforge.net/p/podball/wiki/Home/
It is also a 2D sports game with programmable AI-teams. Not my project.
But I once made a state-machine-AI for it. ( https://www.youtube.com/watch?v=tG7mHW9sIKQ )