December 31, 2016

Books I read in 2016

0 comments
Each year I write a list of books I read during the year. This is the 2016 list:
  1. A Brief Introduction to Neural Networks. A free book that will give you an introduction to artificial neural networks, which is a group of mathematical models behaving similarly to neurons in the brain.  
  2. Clouds of Glory: The Life and Legend of Robert E. Lee. A biography on Robert E. Lee who was an engineer but also a famous general in the US Civil War. 
  3. The Society of Mind. Written by Marvin Minsky, who is famous for his contributions to artificial intelligence, the book describes how he thinks the human brain works. 
  4. Superintelligence. What will happen when our computers are becoming smarter and smarter? Are they going to kill us or are they going to help us? 
  5. The Devil in the White City: Murder, Magic, and Madness at the Fair that Changed America. This book consists of two stories: the first is about the world fair in Chicago and the second is about a serial killer who used the fair to lure his victims to their deaths. 
  6. The way of the superior man. What's the meaning of life? Why are women so strange? This book is trying to answer those questions. 
  7. Omgiven av idioter (Surrounded by idiots). Is a Swedish book on psychology and why it seems like some people around us are idiots. The answer is that humans behave differently, so to handle people who seems like they are idiots you have to handle them in a special way. You might argue that someone who can't take initiative is an idiot, but that's just how that person is, so you have to tell the person what to do.
  8. Fundamentals of computer programming with C#. Is a free book about the basics of the C# programming language. 
  9. .Net Book Zero. Is a free book about the basics of the C# programming language. 
  10. The Pragmatic Programmer. Is trying to summarize the experience of older programmers so new programmers can learn from them. 
  11. The Best of edw519. Is a free book and summarizes the knowledge of the user edw519 (from Hacker News) who is an experienced programmer. 
  12. Game Programming Patterns. Is a free book and it will teach you basic ideas or building blocks related writing software for games. 
  13. Masters of Doom: How Two Guys Created an Empire and Transformed Pop Culture. Is a biography on John Carmack and John Romero, who created the popular games Wolfenstein 3D, Doom, and Quake. 
  14. Getting Real: The smarter, faster easier way to build a successful web application. This book will teach you a better way to develop new products. If you want to develop a Microsoft Word competitor, then you should build a product with less features, get feedback from customers as soon as possible, and try to stay as small as possible. If you do that (and a few other things explained in the book) then you will be able to compete with a larger company that can't be as flexible as you can.  
  15. Production Volume Rendering. Is a free book and is all about volume rendering which is a technique to display volumetric elements such as clouds on the screen. For example, the clouds in the movie Avatar were generated with volume rendering.
  16. Beyond Band of Brothers: The War Memoirs of Major Dick Winters. Is the biography on the leader (with the red hair) in the television series Band of Brothers.
  17. Panzer Leader. Is a biography on and by Heinz Guderian, who was responsible for making the tank an important part of the German war machine during World War 2.
  18. Ivan's War: Life and Death in the Red Army, 1939-1945. Russia lost millions of soldiers during the Second World War. This is the story of them (and those who survived).
  19. Infantry Attacks. In the movie Patton, where Patton on the battlefield is facing the German officer Erwin Rommel's troops, there's a famous line: "Rommel you magnificent bastard, I read your book." This is that book, and it's about Rommel's endeavors as an officer during the first world war. 
  20. The art of game design. A book about how to design games. 
  21. Mud, Sweat, and Tears: The Autobiography. Bear Grylls has a few popular television shows about how to survive in the wilderness. This is his biography. 
  22. Red Storm Rising. What would happen if NATO and Russia decided to fight a war against each other?
  23. A history of mathematics. As the title says: the history of mathematics from before the Egyptians to the middle of the 20th century.
  24. How to solve it. A book about how to solve mathematical problems. It's obviously not a solution to how to actually solve all mathematical problems, but it gives you insights into how to start solving problems and how other mathematicians have solved their problems. You can probably apply it on other problems as well - not just mathematical problems.
  25. Fermat's Enigma: The Epic Quest to Solve the World's Greatest Mathematical Problem. Fermat's last theorem was one of the most famous mathematical problems. This book tells the story of how the problem was solved. It will also give you a brief overview of the history of mathematics.  
  26. The man who knew infinity. A biography on the Indian mathematician Ramanujan (and also to some extent a biography on the British mathematician G. H. Hardy).
  27. The Wisdom of Crowds. Will teach you when you should (and when you shouldn't) listen to a group of other people. 
  28. Sophie's World: A Novel About the History of Philosophy. Is a dramatization of the history of philosophy, so if you want to get an introduction to philosophy you should read it. 
  29. Save the cat! The Last Book on Screenwriting You'll Ever Need. Is a book about how to write stories for movies, but most likely you can also use it if you are writing a book or a story for a game or a book.  
  30. The Great War of Our Time: The CIA's Fight Against Terrorism - From al Qa'ida to ISIS. Includes stories such as why CIA failed to predict 9/11, why CIA failed to find any weapons of mass destruction in Iraq, what are some misconceptions regarding the embassy attack in Libya, some Edward Snowden criticism, and what really happened when President Bush's dog Barney got a piece of plastic stuck in his throat during an intelligence briefing. 
  31. A theory of fun for game design. Why are some games fun and other games boring?
  32. Game over press start to continue. The book covers the history of Nintendo from the birth of the company to 1999, including stories how Mario was created, how Nintendo traveled to Russia to get the game Tetris, and the history of other companies like Atari and Sega.
  33. Moon Lander: How We Developed the Apollo Lunar Module. Tells the story of how the engineers developed the so-called Lunar Excursion Module, which landed mankind on the Moon in 1969.
  34. Swarm Intelligence: From Natural to Artificial Systems. All about artificial intelligence algorithms inspired by our tiny friends the ants and other insects.
  35. Visual Explanations. A book by Edward Tufte and is about pictures of verbs, the representation of mechanism and motion, process and dynamics, causes and effects, explanation and narrative. You will for example learn how the Space Shuttle Challenger disaster could have been avoided if NASA has used other visualizations. Is filled with images so it's a fast read.
  36. Beautiful Evidence. Is about how seeing turns into showing, how data and evidence turn into explanation. It's by the same author as Visual Explanations, so it's filled with images so it's a fast read. You will learn, for example, why you should have images that explain the text close to text so the reader doesn't have to go back and forth as if you collect all images at the end of the book, like some authors do. This is common sense, but you still have to learn it so that it becomes common sense. You will also learn why the Space Shuttle Columbia was destroyed because of a PowerPoint presentation, which by the way you should avoid because they are too summarized. Use technical reports! There's also a saying that "a picture is worth a thousand words," but you have to make sure that your picture is worth a thousand words. Sometimes a picture can be worth less and then you shouldn't use it. 
  37. Envisioning Information. Is the third book by Edward Tufte I've read this year and is about how to display complex data. You will see beautiful examples of how to display both railroad lines and dance movements. And you will learn how to improve your own visualizations, such as that you should add detail to clarify and why 1 + 1 = 3 (if you have two separated colored lines, there's always a third white line between them).
  38. Adventures Among Ants: A Global Safari with a Cast of Trillions. Is a book about ants written by Mark Moffett who is also known as Doctor Bugs.
  39. Ett halvt år, ett helt liv (A half year, an entire life). A Swedish biography by a UN soldier in the Bosnian War.
  40. Chickenhawk. Is a true story written by Robert Mason, who was a helicopter pilot in the Vietnam war. The battle dramatized in the movie We Were Soldiers was one of the battles he participated in.
  41. Deadliest Sea: The untold story behind the greatest rescue in Coast Guard history. Tells the true story of the sinking of the Alaska Ranger and how the Coast Guard were trying to save the people on the boat.
  42. Black Hawk Down. Is about a failed US military mission in Somalia.
  43. Jacked: The Outlaw Story of Grand Theft Auto. Written by the same author as Masters of Doom, it tells the story of the popular game series Grand Theft Auto (GTA), from GTA I to GTA IV. It includes stories like when the GTA team hired a cop to protect them while researching violent neighborhoods in New York for the game. Since GTA is a violent game you will also learn about if you can blame the game for inspiring violence, such as an incident where two teenagers began shooting at cars on a highway after playing the game.
  44. Essential Mathematics for Games and Interactive Applications. Is a super-good book (some nerds consider it a bible) if you want to learn how to apply mathematics to games. You will learn the basics of graphics (including lightning and shaders), interpolation, collisions, and much more.
  45. Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future. Is a biography on Elon Musk. A few years ago I wrote my own biography on Elon Musk, so it was fun to compare the books.     

December 14, 2016

Short December Updates

0 comments
Update 1. Self-driving Car
Last year I learned about an algorithm called Hybrid A* (A star), which is what a self-driving car could use to navigate in a confined space like a parking lot. I decided to implement it in Unity, and it became very popular. I've sent the project to several PhD students from schools in US, Sweden, Japan, and Germany, who wanted to use it as well as to other people who have been interested in how to implement the Hybrid A* algorithm.
To display the search tree the algorithm is using, I used Unity's Line Renderer. It turned out that it was those line renderers that had the biggest performance impact on the final product, and I used techniques like object pooling to try to increase the performance without much success. But a few weeks ago I found something called GL which is a low-level graphics library used by Unity. And GL has a line function called GL.LINES which is much faster than line renderers if you want to display a lot of lines! So here's a pro-tip: Use GL.LINES if you want to display a lot of lines!
With that said I think this is the final version of the self-driving car:


Update 2. A New Beginning
Ludum Dare was on this weekend. It's a competition where you are making a game in 48 or 72 hours depending on how hardcore you are. You are not winning anything except fame and honor, so when I participate in the competition I always try to learn something new or experiment with a crazy idea.
Each competition has its own theme, and the theme this competition was "One Room." My idea was to maybe not make a game, but one of those "art installations" where you are in a traditional game, but it's not a game. If you don't know what I'm talking about you should check out Dear Esther on YouTube.
My art installation is called A New Beginning, and I'm not going to spoil it here because you should experience the game because that was the point of it.


Not everyone liked the game because some players didn't have the patience to play it through. Some players are used to those fast-action games and become bored if they don't get it after the first few seconds. But some players liked it:
I survived, don't give up!   This game made me feel something, stuck in a room, facing an unavoidable threat.  And I tried to move everything around in despair, soon the room was a mess, and soon it was to late. The narrator caught my attention about a second chance. That is interesting!   
I don't know what to think about the narrator that teaches me life. Ok, and I didn't do anything to deserve surviving, or to deserve to die. To conclude this game creates emotions, well done. Thanks for making this game!    

Update 3. Learn how to optimize your Unity project
If you are making a game you need to make a fast game, especially if you are making a game for mobile phones. Something you might not first think about from a performance perspective is how much battery your game is using, and you can actually optimize the game so it's using less of your precious mobile phone's battery. All this is a bottomless pit and everything about how to actually optimize is spread out across the Internet. So to solve this problem I decided to try to collect all links in one page, and you can find the collection here: Learn how to optimize your Unity project.

October 28, 2016

If you read one article about Rectangle-Rectangle Intersections read this one

0 comments

I've made an autonomous traffic intersection in which self-driving cars can find their way through the intersection faster than if the intersection had traffic lights. How much faster you might ask? The answer is about 10 seconds according to my simulations. The problem is that if you add pedestrians and bikes to the equation, everything will break down, but that's a later problem!

To be able to know if a self-driving car can drive through the intersection without colliding with another car, you approximate each car with a slightly larger rectangle (to be on the safe side) and then you predict where the rectangle will be in the future with your favorite integration method. Each integration step you test if the (pink) rectangle is intersecting with any of the other (pink) rectangles. It looks like this:


Using a fast rectangle-rectangle intersection method is important to make the algorithm as fast as possible. But how can you find out if two rectangles with orientation in 2d space are colliding? The first idea I had was to divide the rectangles into two triangles and then detect if any of the four triangles are intersecting. If you google 2d triangle-triangle intersection, you will find that one way of doing this is:
  1. Approximate the triangles with rectangles and check if they intersect with an AABB-AABB intersection algorithm. These approximated rectangles have no rotation (they are called OBB if they have rotation) so you can't use this algorithm to solve the main problem, but you can use it to speed up the algorithm.
  2. If the approximated AABB rectangles are intersecting, then test if any of the edges of each triangle is intersecting with any of the edges of the other triangle with a line segment-line segment intersection algorithm.
  3. If the above fails, but the approximated rectangles are intersecting according to the first test, it means that one of the triangles could be inside the other triangle. To find out if that is true, you test if one of the corners of the triangle is inside the other triangle (and vice versa) with a point-in-triangle intersection algorithm
If the above sounds complicated I've written a more detailed explanation (with C# code in Unity) here: Are two triangles in 2D space intersecting? And maybe this image explains it better:


The problem with testing if two rectangles are intersecting by using the triangle-triangle intersection algorithm is that you maybe have to do the above four times. What if there is a better way? One other way to test if two rectangles are intersecting is using the Separating Axis Theorem, or SAT

SAT is a little bit more difficult to understand, but when you have understood the basic ideas (and have repeated both the dot product and vector projections), you will be able to apply the intersection algorithm to all convex polygons. So it's possible to test if both triangles and rectangles are intersecting with SAT, because a rectangle is a polygon with four sides. If you want a more detailed explanation of the SAT algorithm, I've written a longer article here: Are two rectangles with orientation in 2D space intersecting?

But what I found is that even though SAT includes fewer steps, it's actually slower. The reason is that the triangle-triangle intersection algorithm doesn't always need to go through all steps to see if the triangles are intersecting. So an important lesson is to take out your timer and test how fast each algorithm is. But as today's Momentum quote said: "Live as if you were to die tomorrow. Learn as if you were to live forever" at least I've learned something new!

October 22, 2016

No more red traffic lights!

0 comments

Waiting for a traffic light turning green is never fun! But what if there was a world without any traffic lights? Well, when all cars on our roads are self-driving then it's possible to create an intersection without any traffic lights. This idea is called Autonomous Intersection Management. The basic idea I've used here originates from the report A Multiagent Approach to Autonomous Intersection Management. The authors of the report released this video so that's what we are aiming for here:


But the version you can test here is more complicated as each car is simulated in Unity, which makes it more realistic, so a car is not just a mathematical model of a car as they are in the report mentioned above. So each car in my simulation has an engine torque, braking torque, realistic wheels, drag force, and much more. This makes it much more difficult to simulate future positions of the car, which we have to do to check for collisions in the intersection.

The basic idea is that each car knows where it is going, such as driving forward or turning left, so it has a path through the intersection with waypoints. It can't change lane, and it can drive forward and turn left in one lane and drive forward and turn right in the other lane. To get a smooth curve between the waypoints I used a spline interpolation method called Bezier curve. The intersection looks like this:


When the car is close to the intersection, the intersection checks if the path through the intersection is clear by using the car's velocity and acceleration. To simulate the future positions of the car, I approximate each car with a rectangle and then I'm using an integration method called Forward Euler. At each integration step, I check for rectangle-rectangle collision with the other rectangles that are stored at this future time step which are approximations of other cars. This is happening until the car is outside of the intersection. The rectangles are also a little bit larger than the car to be on the safe side:


If the first car that has arrived to the intersection can't find a clear path, the intersection checks if next car in the queue can find a clear path, and so on until there are no-more cars to check. The problem now is that the first car in the queue might wait for a path for an infinite amount of time. To solve this, there's a timer saying that if the first car in the queue has waited for 10 seconds, then the intersection should prioritize this car until it finds a path through the intersection.

But what if an emergency vehicle arrives? In that case the intersection will prioritize all cars in the same lane as the emergency vehicle until the emergency vehicle has entered the intersection. It will at the same time prioritize all cars in the lane next to the lane the emergency vehicle is in, because those lanes will never cross in the intersection.


The simulation is not yet 100 percent good, so some collisions will happen, but that's just a matter of fine-tuning all the parameters. Anyway, the version described above looks like this:


But is an autonomous traffic intersection faster than traffic lights? It's easy to add traffic lights to the simulation and then calculate the average time it takes for a car to drive through the intersection. According to my studies, the average time it takes a car to drive through an intersection with traffic lights is about 1 minute. You can compare this with the average time it takes a car to drive though an autonomous traffic intersection, which was about 50 seconds.

Looks interesting? You can test it here: Automatic traffic intersection.

October 18, 2016

Why Gamification Beats Peanut Butter on Pancakes

0 comments
The 21-day Gamification Course is a free e-mail course by Yu-kai Chou, who has written the book Actionable Gamification. But what on earth is gamification? According to Wikipedia, gamification is:
...the application of game-design elements and game principles in non-game contexts to improve user engagement, organizational productivity, flow, learning, crowd-sourcing, employee recruitment and evaluation, ease of use and usefulness of systems, physical exercise, traffic violations, and voter apathy, among others. A review of research on gamification shows that a majority of studies on gamification find positive effects from gamification. However, individual and contextual differences exist.

If you are making a game it's obviously a good idea to understand the game-design elements and game principles. But if you are not making a game, you may also need to apply the ideas behind gamification. Last year I read the book Superbetter, which is promising to give you a framework so you can apply the ideas behind gamification to improve your own life. The book says: "Playing SuperBetter for 30 days improves mood, reduces symptoms of anxiety & depression and increases belief in the ability to successfully achieve goals."

One of the interesting ideas from the book Superbetter is what you should do if you have experienced a traumatic event. If you, within a few hours after that event, play a game like Tetris, then you will minimize the risk of getting post-traumatic stress from the traumatic event. So as in Wikipedia's definition, gamification can be applied to many more areas than just traditional games. With that in mind, let's learn more about gamification.

Introduction

Gamification is the art of stealing all the fun and addicting elements found in games and applying them to real-world or productive activities. But why is it called gamification if it can be applied to so many other areas? The reason is that the game industry was the first to focus on human-focused design because games have no other purpose than to please the user playing the game. This is actually not entirely true because there are games with a purpose other than to be fun, such as a game helping victims with burn injuries heal their wounds, but you get the idea.

Human-focused design is a design process which is trying to optimize for the human in the system and not the efficiency of the system. You can compare it with the iPhone, which didn't have a stylus because Steve Jobs focused on the human and not the technology, which is called function-focused design. Games have to focus on the human because a game is not a game if not a human is playing it. But if you are building something else, like a nuclear reactor, then you can focus on designing an efficient system.

The game industry might not be old, but it has spent a lot of time to master motivation and engagement, so you can now learn something from games, such as why the game World of Warcraft is addicting? I personally had a classmate who disappeared from school because he became addicted to World of Warcraft. What if there was a way to make school as fun as games? This is what you will learn here!

You can argue that it is the challenges and limitations, such as rules and obstacles, that makes a game fun. A game like soccer has a challenge (win the game against the opposing team) and limitations (you can only kick the ball with your feet), but everyone, including me, doesn't enjoy playing soccer. So a game needs more than just challenges and limitations to be fun.

Why do you want to do something?

Why do you like to play soccer, and why do I hate to play soccer? There are 8 fundamental reasons (called core drives, or CD) why you and me want to do something:
  1. Meaning. You want to do something because you feel it has a purpose.
  2. Accomplishment. You want to do something to overcome challenges.
  3. Empowerment. You want to do something because you like to be creative and test different strategies.
  4. Ownership. You want to do something if you feel like you own what you are doing.
  5. Social influence. You want to do something because other people around you are doing it. 
  6. Scarcity. You want to do something now because you think the opportunity may be lost if you are not doing it now.
  7. Unpredictability. You want to do something because you want to see what's happening after you have done it. 
  8. Avoidance. You want to do something to avoid something negative happening if you are not doing it. 
The difference between these core drives is not always clear! For example, being part of an exclusive shopping network is:
  • 1. Meaning - You want to be a part of the elite.
  • 2. Accomplishment - You made it into the club.
  • 4. Ownership - You get to buy the best stuff!
  • 5. Social influence - Now your friends are jealous of you.
  • 6. Scarcity - You are part of this 1 percent ultra exclusive club!

A summary of each core drive

1. Meaning. You believe you are doing something greater than yourself or that you were "chosen" to do something important. Examples:
  • Spend your spare time updating Wikipedia. You believe that by updating Wikipedia your work will affect millions of people around the world in a positive way.
  • Being a member of a limited network, such as "an exclusive, member-based online shopping site for clothing and accessories, which runs time-limited sales which can only be viewed by its members." 

2. Accomplishment. You have an internal drive to make progress, develop skills, and overcome challenges. This is the core drive that is the easiest to design for because you can simply add leaderboards, points, and trophies. But don't forget the challenge, because you don't want to get rewards for free. Examples:
  • I wrote a book about Elon Musk (the challenge) and my "leaderboards, points, and trophies" is the book's Goodreads rating. Each time I get a good rating I feel proud and sometimes I take a print-screen of the rating and attach it to a tweet.
  • When you buy something on the auction site eBay, you feel that you won. So even though you might have paid more compared to what you initially wanted to pay, you feel that you won against the other guy who were bidding against you.  

3. Empowerment. You need ways to express your creativity by repeatedly trying to figure things out and try different combinations. This makes you feel good and you take action because you find the action enjoyable on its own. You also need to be able to see the result of your creativity by receiving feedback so you can improve what you have done. Examples:
  • The game Minecraft is popular because you can be creative in it and do whatever you want. Other people can join the map and give you criticism, but you can also give yourself criticism because you see what you've created.   
  • Websites that let you play around with your personal economy so you can test different strategies. What's happening if you invest 20 percent in stocks and save 30 percent in your savings account?   


4. Ownership. You are motivated when you feel like you own something, and you want to make what you own better. Besides being the major core drive for wanting to accumulate wealth, this deals with many virtual goods or virtual currencies. If you in a game spend a lot of time to customize your profile or avatar, you automatically feel more ownership towards it. This is also the core drive that makes collecting stamps or puzzle pieces fun (for some). Examples:
  • In Pokemon the player has to catch all Pokemons.
  • McDonald's had a physical game where you had the chance to get a piece of the game when you bought a hamburger. When you accumulated all the pieces McDonald's gave you a reward. 
  • You've spent a lot of time writing blog posts on your blog (you now own it) and you want to improve it by increasing the number of readers.


5. Social Influence. This drive incorporates all the social elements that drives you, such as mentorship, acceptance, social responses, companionship, competition, and envy. When you see a friend who is amazing at some skill or owns something you also want to own, you become driven to reach the same level. This also includes your drive to draw closer to people, places, or events that you can relate to. If you see a product that reminds you of your childhood, the sense of nostalgia would likely increase the odds of you buying the product. Examples:
  • The online game Parallel Kingdom has mentors that spend time with you when you've just started the game. They give you items and a push in the right direction. Players who get help tell themselves: "I can't possibly quit this game now and let my mentor down. He/she just gave me his valuable items! I can't let his/her effort go to waste." So they continue playing because someone else has done a favor for them. 
  • A hotel wanted to persuade their guests to reuse their towels, so they tested two different signs: "Please help us save the environment by reusing your towel," and "80 percent of the guests that stayed in this room reused their towels." It turned out that the second sign was most effective because we humans tend to do what other humans do. If you are told other people are reusing their towels, then you will also reuse them.  


6. Scarcity. This is the drive of wanting something because you can't have it and you want it immediately. Many games can say "come back in 2 hours later to get your reward." The fact that you can't get something right now motivates you to think about it all day long, so you might pay to have it at once. Examples:
  • Facebook started at a small scale for just Harvard students. When Facebook opened up to everyone, you wanted to join because you previously couldn't.
  • Until the mid 20th century, diamond engagement rings were a small and dying industry in America. But then someone came up with the idea to restrict the supply of diamonds to make them a status symbol. The diamonds themselves aren't actually that rare.
  • The game Candy Crush gives you the opportunity to either pay to get something now or wait sometime. Some pay because they want it immediately. 
  • You are more motivated to buy a product with a limited edition, even though you don't know how many "limited" is. 100 products? 1 million products? It doesn't matter to you! 

7. Unpredictability. You want to know what's happening next. If you don't, your brain is engaged and you think about all the time. This is why you watch movies or read books. However, this drive is also the primary factor behind gambling addiction. There are experiments showing how rats continuously press a lever because of unpredictable rewards. What if the next press will result in cheese? Examples:
  • What if the next lottery ticket will make you rich?
  • What if the famous person on Twitter is finally replying to your tweets?

8. Avoidance. This core drive is based upon the avoidance of something negative happening, such as avoiding losing previous work or avoiding admitting that everything you did up to this point was useless because you are now quitting. The problem is that you are much more likely to change your behavior to avoid a loss than to make a gain. Examples:
  • It's much harder to sell a stock if you have lost money on the stock than it is to sell a stock with a profit. This is why so many people are losing money in the stock market! What you should do is to sell the losers and hold on to the winners. 
  • When spending time on an auction on eBay you don't want to lose the auction. 

The Octalysis framework

You can summarize the 8 fundamental reasons (core drives) why you want to do something in the co-called Octalysis framework:


You can connect the different sides of the octagon to the different parts of your brain. But that's boring so let's see examples of the framework in action:

Twitter



Farmville



Example: Blogging

Why do you want to have a blog? As said before, there are 8 fundamental reasons (core drives) why you want to blog:
  1. Meaning. You believe that by writing articles you can help people and make the world a better place. You will also become a better writer. 
  2. Accomplishment. It's a challenge to write a blog: you have to come up with new ideas about what you are going to write, and you have to update frequently.
  3. Empowerment. By experimenting with the blog design and different types of articles you can be creative and see how many readers you can get.
  4. Ownership. You've spent a lot of time with the blog so now you feel like you own it, so you want to improve it.
  5. Social influence. It's more fun to blog when you see that people are reading the blog, and it's fun to compete with other people who are writing similar articles.  
  6. Scarcity. Writing a blog is a long-term investment. You don't know which articles will become popular, so you have to wait and see. 
  7. Unpredictability. It's fun to see which articles will become popular. 
  8. Avoidance. You measure how many people are visiting your blog and it's painful to see when the trend line is down. If the trend line is down, you want to write more articles to avoid the fact that all the hard work up to this point has been a waste of time.  

Example: Selling video games

While writing this article I read the book Game Over: How Nintendo Conquered The World. It explained how Nintendo used gamification to sell more video games:
...it was wise to market video games like movies - released cautiously, rationed so that demand outpaced availability, and then withdrawn from circulation as soon as interest began to wane. This rationing tactic, treading games like priceless objects (Scarcity), worked. After all the hyper about a new game took hold (Meaning), kids dragged their parents to stores, but outlets couldn't keep the games in stock. A kid who was absolutely dying to get "Link" [a game] would arrive at the store, only to find it sold out. Maybe he would try a few other stores without success (Empowerment and Unpredictability), but then he would buy another Nintendo game. Then, a week or month later, a new supply of "Link" would come in. The kid wanted "Link" more than ever then, and unless his were the most iron-willed of parents, they would succumb.
The Atari wave (the competing game company) had floundered in large part because of a flooded market. By design, Nintendo did not fill all of the retailers' orders, and it kept half or more of its library of games inactive.

I also suspect that the kid's friends, and those around him who had found a copy of the game, were influencing the kid to buy the game (Social influence). When the kid finally bought the game, the kid had overcome the challenge to find the game (Accomplishment and Avoidance as in not finding the game at all). Now when the kid has spent a lot of time to find the game, the kid now feels like the kid owns the game (Ownership) and will thus enjoy it more.

But why is Nintendo's share of the market today much lower than Nintendo's share of the market in the 1990s if they have figure out the secret to how to sell games? The answer is that today it's much more difficult to create a hype about a new game (Meaning) because so many good games are being produced each year. Nintendo is also doing their best to avoid creating a hype about a new game because they are preventing YouTubers from playing their games, and since many gamers are buying the games the YouTubers are playing (Social influence), no-one is buying Nintendo games.    

Summary

This was just a short summary of the 21-day Gamification Course. If you want to learn more you should take the course yourself. I learned a lot, even though I had studied the area before by reading books like Influence, Yes!, and Superbetter. So I will continue to study the area because a good product is not good unless you have users who are actually using the product. And since you can use gamification in other areas as well, such as avoiding post-traumatic stress, you now see why gamification actually beats peanut butter on pancakes.