Virtual Pet
Welcome to the ninth edition of Elixir Quiz. This week we are creating a virtual pet.
What is a virtual pet?
Virtual pets were huge in the 90’s. I remember owning a few, most of which involved a game embedded in a keychain. The game revolved around keeping the pet alive by feeding it, cleaning up after it, and ensuring it got enough sleep.
The toys quickly became popular and gained more advanced features, to the point where the pets could interact with each other. Entire franchises were created around these toys, including television shows, video games, plush toys, and trading card games in addition to the pets themselves.
The problem
Create a virtual pet game in which a player must keep the toy alive for the longest possible time. The pets health should be affected by properties such as
hunger
,cleanliness
andhappyness
. The player should be able to take actions to improve any of these areas.
You can use this problem as a chance to investigate the actor model. The Elixir Getting Started guide covers these topics well, including Agents and the GenServer.
How do I enter?
The virtual pet quiz runs from Saturday October 4th 2014 until Friday October 10th, 2014.
To enter, just complete the problem and post the code to our subreddit. As always, you can host your code anywhere (like Github Gists), or post your solution directly into the subreddit post.
Example solutions
After the quiz period ends on October 10th, I will update this section and talk about some interesting solutions that were posted to our subreddit