Can a neural network learn to play hockey?

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

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.
Current project:
https://togfox.itch.io/backyard-gridiron-manager
American football manager/sim game - build and manage a roster and win season after season
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, 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.
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
togFox
Party member
Posts: 764
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

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.
Current project:
https://togfox.itch.io/backyard-gridiron-manager
American football manager/sim game - build and manage a roster and win season after season
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, 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!
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
togFox
Party member
Posts: 764
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

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.
Current project:
https://togfox.itch.io/backyard-gridiron-manager
American football manager/sim game - build and manage a roster and win season after season
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, 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.
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
togFox
Party member
Posts: 764
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

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]
Current project:
https://togfox.itch.io/backyard-gridiron-manager
American football manager/sim game - build and manage a roster and win season after season
User avatar
knorke
Party member
Posts: 237
Joined: Wed Jul 14, 2010 7:06 pm
Contact:

Re: Can a neural network learn to play hockey?

Post 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 )
Post Reply

Who is online

Users browsing this forum: No registered users and 24 guests