[Speaking of brains, I recently made an ebook version of Steve's cancer blog, available on Google and Apple! /shameless plug]
This week's post isn't exactly about Physics, but instead an interesting technique that can be used for data analysis, and I've used to make a card game. First some background: During my first semester at Swarthmore, I took a class on Jane Austen's novels. In one of the books, the characters played a card game called Piquet, which I had never heard of. I looked it up, and invited my friend Kevin to try playing it, which turned into a fierce tournament spanning many years. One summer, I developed an Apache Tomcat version of the game that could be played in your browser against various computer players, which I called WebPiquet. It's no longer functional, but all the code is here.
Skip ahead ~10 years, and I've become a fan of the blog AI Weirdness. It's written by a research scientist, Janelle Shane, who applies a program called a neural network to various tasks, and shows the results. You may have heard about neural nets in the news recently, thanks to GPT-2. The way they work is by imagining a set of neurons that are activated to different degrees by inputs. Those neurons are then combined to create a set of outputs.
As the name "neural network" suggests, the neurons are laid out in a network:
Moving from left to right, each neuron in one layer connects to the ones in the next. The connections between neurons specify different weights to tell how the first affects the next.
The key to getting a useful neural net is training. They're such a general tool that to get them to work for a specific job, you need a large amount of training data. By giving the network input data and tuning the weights according to the output data, we can try to find the best set of weights for a job.
The downside of neural nets is that without proper design and training, their results can be nonsense. Shane's blog features many of these, and there are Twitter accounts like @normalcatpics that feature particularly funny and/or nightmarish examples.
Getting back to cards, I thought it would be interesting to make a Piquet bot that took advantage of neural networks. I wrote an entirely new version in Python, which I naturally named Pyquet. I've only trained it for 10 or so hours, so some of the decisions it makes are still pretty bonkers, but the training was improving it slowly:
I alternated between making it play against itself, and a bot that simply made random choices. You can see above the score against the random bot is trending upward.
If you'd like to try it yourself, there are instructions and references at the link above. Feel free to post questions (or high scores!) below.
No comments:
Post a Comment