January 15, 2019

Computational Geometry - Part 3

0 comments
As said before and before, I've spent some time learning an area called Computational Geometry. One of the algorithms I learned was how to make a Voronoi diagram. The algorithm I implemented suffered from floating point precision issues, so sometimes the Voronoi diagram lost some edges. The reason was that the algorithm was cutting lines to create the diagram, but the more the lines were cut, the worse the precision of the lines became (because of  floating point precision issues) and in the end the algorithm removed lines it shouldn't have removed.

A better way to generate a Voronoi diagram is to use a Delaunay triangulation algorithm. This algorithm doesn't suffer from floating point precision issues and is easier to implement if you know how to implement the Delaunay triangulation algorithm. To create a Voronoi diagram from a Delaunay triangulation you need just 150 lines of code, while the older algorithm needed 600 lines of code.

This is the result. You can also see the Delaunay triangulation (the black lines).


One other area I struggled with last time I studied the area was how to cut triangles in the best way. You may think that there are many algorithms that can cut connected triangles in 2d space in a simple way, but not a single one can be found when searching on Google. The answers on Stack Overflow consists of solutions where you have cases. For example, if a line-segment of one triangle is intersecting two line-segments of the other triangle we want to cut, then we need to create 2 new triangles depending on which lines are intersecting, and the solution becomes more and more complicated.

Perhaps a more elegant way is to use what we used to create a Voronoi diagram: the Delaunay triangulation. But in this case we force the triangulation to include some triangles we want to cut from the triangulation, and we get a Constrained Delaunay triangulation, which looks like this:


You can also use the Constrained Delaunay triangulation if you for example want to make a navigation mesh for your game.

December 28, 2018

Books I read in 2018

0 comments
Each year I write a list of books I read during the year. This is the 2018 list:
  1. Nothing Like It In the World: The Men Who Built the Transcontinental Railroad 1863-1869. Tells the story of how the railway between the US west- and east coast was built. 
  2. The Internet of Money. Is a transcription of talks by Andreas Antonopoulos. These talks are about Bitcoin and are also available on YouTube, so if you don't want to buy the book you can watch them for free.
  3. Digital Gold: Bitcoin and the Inside Story of the Misfits and Millionaires Trying to Reinvent Money. Is telling the history of Bitcoin from the earlier attempts to make a digital currency up to year 2014. If you feel that you missed the Bitcoin hype you should read this to catch up with what has happened.
  4. Blockchain Revolution: How the Technology Behind Bitcoin Is Changing Money, Business, and the World. As the title says, the blockchain is the technology behind bitcoin, but the blockchain also has other applications than a currency, and this book is trying to give you a vision of a world with the blockchain.
  5. The Illusion of Life: Disney Animation. Tells the story of how Disney made their first movies.
  6. Swarmwise: The tactical manual to changing the world. Is a free book which tells you how to create a distributed organization that works towards a common goal. 
  7. The Last Full Measure: A Novel of the Civil War. You can divide the US civil war into three parts, and this book is about the third part and is about what happened after the famous Gettysburg battle. 
  8. Spitfire Pilot: A Personal Account of the Battle of Britain. Is a short book consisting of notes written by a pilot who was killed so he could never write a real book. 
  9. With Wings Like Eagles: A History of the Battle of Britain
  10. 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. I tend to read this book once a year. 
  11. Armageddon: The Battle for Germany, 1944-1945
  12. Retribution: The Battle for Japan, 1944-45
  13. Why We Sleep: Unlocking the Power of Sleep and Dreams. If you want to read one book this year you should read this one because it explains why you have to "waste" 30 percent of your life sleeping.
  14. Inside the Third Reich. Is written by the architect Albert Speer who at age 28 found himself responsible for redesigning Berlin and during the Second World War responsible for the industrial production. The book answers the question how Germany, despite being bombed by allied aircraft, could continue building tanks.
  15. Savage Continent: Europe in the Aftermath of World War II. Most books written on the Second World War ends when the war ends. But what happened after the war ended? Where did people live when everything had been bombed into pieces? 
  16. Bomber Command. Tells the story of the British bombers in Europe during the Second World War. 
  17. Blood, Sweat, and Pixels: The Triumphant, Turbulent Stories Behind How Video Games Are Made. Each chapter is a story of how a video game was made, including those games that failed. 
  18. Fire Strike 7/9. Is written by a guy who worked as a JTAC in Afghanistan, which is the soldier who's coordinating aircraft, telling them where to drop bombs to support the troops. 
  19. Krigare (Warriors). Is a Swedish book about soldiers in Afghanistan. Is available for free here.
  20. Raid on the Sun: Inside Israel's Secret Campaign that Denied Saddam the Bomb. Tells the history of when Israel bombed a nuclear power plant in Iraq.  
  21. The Army Air Forces in World War 2. Immediately after the end of World War 2, the US Army Air Force decided to write a summary of what had happened. The result consists of seven volumes and each volume is like 800 pages and you will learn everything about how to develop new planes to logistics. I didn't read all of it, but chapters I was interested in. 
  22. Spitfire at War. Consists of several small stories about people related to the famous World War 2 plane. 
  23. Royal Air Force Logistics During the Second World War: Transformation, Sustainment and Flexibility. Is actually not a book but a 400 pages research report so it is available for free.
  24. Fighter Command 1939-45. Tells the story of the British fighters, such as the Spitfire, in Europe during the Second World War. Includes many photos from the time, so it's a fast read. 
  25. Aviation Classics: de Havilland Mosquito. Maybe not as well-known as the Spitfire, the "Mossie" was actually one of the best aircraft of World War 2 because it was made of wood and could thus fly faster than those made of metal. 
  26. The Bomber Command Handbook 1939-1945. Is similar to the book Bomber Command above, but is also describing aspects like airfield construction. 
  27. The Dam Busters. During World War 2, they came up with a new type of bomb which could destroy German dams. This new bomb also needed skilled bomber crews so they created a special unit. This book will tell you about the dam raid and what the unit was doing after the raid. 
  28. Avro Lancaster: Britain's Greatest Wartime Bomber. The Lancaster was the most successful British bomber during the Second World War. 
  29. Vertex 1-3. Vertex is a free book series where each book consists of articles written by professionals in the graphics industry. You will learn about textures, modeling, etc. 
  30. The Quake III Arena Bot. Books on AI describe many algorithms but not what actual games are using and how to combine the algorithms. This book (is actually a 100+ pages research report) does exactly that, so if you want to read about applied AI, then read this free book.
  31. Boyd: The Fighter Pilot Who Changed the Art of War. Tells the story of John Boyd who was first a pilot and then an engineer. He was responsible for transforming the design of aircraft and how to fight a war.  
  32. Viper Pilot: A Memoir of Air Combat. One of the aircraft Boyd (the book above) helped to design was the F-16, also known as the Viper because it looks like the snake. This book is written by a pilot who flew the F-16 on both Iraq wars.  
  33. Skunk Works: A Personal Memoir of My Years at Lockheed. Is written by Ben Rich who worked on aircraft like the F-117 stealth attack aircraft and the U-2 spy plane. 
So, a little Bitcoin (thank god I didn't buy any bitcoins after reading the books in the beginning of the year :)), some books on AI and computer graphics, and many books on aircraft? Why? Well, you might see why next year... And don't forget to read the book about sleep because it's really good!

December 27, 2018

Lessons learned from the Paradox podcast - Season 3

0 comments
Paradox Interactive is a company that's both making and publishing games. In their podcast they talk about the business of video games, and if you want to listen to it on your own, you should search for The Paradox Podcast on iTunes or wherever you can find popular podcasts. I've earlier summarized season 1 and season 2, and this is season 3:

S03E01
  • Strategy/simulation/management games are not that common on consoles like Playstation. But Paradox has released their city-builder Cities: Skylines on the Xbox and now they release the Stellaris game. But you will most likely have to redesign the game's UI. 
  • Paradox is working with an external developer to transform the game from PC to console. This is also what they did with Cities: Skylines. 
  • Paradox believes in function over form, meaning that the backend is more important than the frontend. Some developers spend too much time developing cool graphics but their games are boring. Paradox argues that a fun game is more playable than a game with better graphics. 
  • Going to an event like E3 or Gamescom has some value even though it's difficult to quantify this value. How many people will buy the game because you showed it at E3? It's impossible to tell! Reaching out to potential customers at these events takes time and money (400,000 people visit Gamescom over 4 days), so if you are small you should work with someone who has resources, like Paradox has. 
  • People have different motivations why they want to play a game. Some want to explore the world and others want to have a realistic experience, etc. You should focus on why a player wants to play your game, which needs does the player have? This is more important than making a game for a certain age group or a certain group with a specific education. Someone who is 16 and someone else who is 64 may have the same reason why they want to play your game. But when you start marketing the game you might focus on a specific age group - younger people tend to watch YouTube and older people tend to watch television.  
S03E02
  • All games released by Paradox has a product team. Each team has a product manager who can best be described as the CEO of the product and takes care of the overall direction of the product. The game is NOT the product, but is included in the product together with how the game is sold, the price of the game, etc. In the product team, you can also find a producer, who makes sure the game is released on time and within budget, and a product marketing manager, who takes care of the selling and marketing of the game. 
  • As a product marketing manager, you will study who's writing about the game, is what they are writing positive, and have they understood the message from the marketing manager? For example, have they understood that Paradox is bringing strategy games to console? 
  • It's more difficult to market a game for console than for PC. In the console case, you have to do in-store advertising, such as in the PlayStation store. 
S03E03
  • Cities: Skylines is out on Nintendo Switch! What Paradox didn't do was that they didn't announce they would release the game on the Switch until the day it was released. The reason was that CS is a well-known game and if they had announced it before it was released they wouldn't have had anything to talk about when it was released. 
  • What is the job of a product manager? As said in the last episode, the product manager is the CEO of the product so the CEO of the company can focus on the overall direction of the company and not micromanage the products. The product manager is responsible for the financial results, budget control, and the product team to make sure everyone has the same vision, ideas, and goals. 
  • A product manager at Paradox can also be responsible for a segment. Segments at Paradox are strategy, management, and rpg, and each segment includes one or more games. 
  • It often happens that Paradox is cancelling a game they have been working on - they are killing 50 percent of the games before they are announced. The main reason is that the vision of the game is no longer shared by everyone and the game doesn't have any meaningful choices. Even though you have experienced game developers it's still impossible to know if the game idea is going to work before you have a playable version of the game. And if it doesn't work it is important to kill it as soon as possible because it will be more difficult the longer you work on the game.   
  • The game development process at Paradox can be divided into the following steps: signing, proof-of-concept (this is where most games a cancelled), alpha, launch. 
S03E04
  • What's the job of a community manager? The basic idea is that the community manager should represent the company among the players and represent the players within the company. 10 percent of the job is social media, they come up with strategies for creating communities, how to make the game appealing for people who have never heard of it before, and how to bring the community back into the game to make the game better. 
  • Players love to talk about games on social media. But should you listen to them or should you listen to the people who are not talking about the game because the spend all time playing it? You should listen to everyone but you should also try to find trends among the feedback you are given. If you can't solve the problem (maybe it's not technically possible) then you should tell them why and they will most likely accept the answer and be happy. 
  • You can measure how good a community manager is by looking at the engagement rate: how many people interact with the content, how big are the discussions on services like Reddit. An engaged community will buy mores stuff. 
S03E05
  • When you have a big company you need an Event Manager who is responsible for organizing events such as PDXCON. 
  • Paradox is preferring to organize their own events instead of attending major events, such as E3, even though they are doing that as well. The reason is that they have realized it's easier to reach out to the media when organizing their own events because your own news tends to get lost among the noise at major events. 
  • There's a saying that it's a waste of time (if you are a small developer) to attend major events because it will not help you to sell more games. A better way is to instead of spending money on aircraft tickets, invest the money in your game. But what events can do is to create a long-term relationship with your players because they will like you more when you meet them face-to-face. But then you need a finished game so you should attend these events when the game is released. One of the first Minecraft events was when Notch met some players in a park, so it doesn't have to be expensive. 
  • One new type of event is role-playing where people are pretending they are in your game. 
  • Some time ago when Paradox was less successful, Paradox pretended they were in Los Angeles for E3 by changing the name on the press releases from Stockholm to Los Angeles. This got them coverage on news sites who were doing roundups about what was going on at E3. If someone wanted to meet them in Los Angeles, they pretended their schedule was full. 
S03E06
  • Paradox has a Twitch channel and their employees are streaming their games for 20 hours each week. They are also streaming other stuff such as when the company is releasing a new quarterly report. But they say it's difficult to measure if people who watch the stream is buying the game they stream. Most people tend to open a new tab and google the game and this is impossible to measure. 
  • People have stopped trusting game trailers because they know a trailer is picking only the best parts of a game - so they want to see actual gameplay so they watch someone streaming the game. 
  • The problem with streaming is that you have to be entertaining all the time while you are streaming. When you make a YouTube video you can edit the bad parts - but streaming is live. 
S03E07
  • What is a producer? A producer is keeping track of the game. Paradox is in Sweden and some of their games is being developed in other countries, so a producer can be said to be the main point of contact between Paradox and the studio developing the game. 
  • Paradox argues that metacritic and user scores by themselves don't have a correlation with how profitable a game is. Not everyone is reviewing the game and some groups may hate a game because it includes something they don't like and give a bad review. But they also say that it's easier to get new users for a game if the reviews are good, but users who already play Paradox games don't care about reviews if they buy a similar game from Paradox. 
  • A successful producer is also a producer who's identifying if the game being developed is not going to be a good game. Cancelling a bad game is sometimes the best alternative because then you have time to work on a good game. 
  • To make a successful game you need an experienced studio with the right attitude and relationship with Paradox, and you also need enough time to develop the game.
...and that's the end of season 3!

Lessons learned from the Paradox podcast - Season 2

0 comments
Paradox Interactive is a company that's both making and publishing games. In their podcast they talk about the business of video games, and if you want to listen to it on your own, you should search for The Paradox Podcast on iTunes or wherever you can find popular podcasts. I've earlier summarized season 1 and this is season 2:

S02E01
  • What many people forget is that game companies want everyone to be happy because then people will buy their game. 
  • As said before, Paradox is trying to find a balance between free updates and dlc you have to pay for. Free updates includes stuff like tech-systems, improved AI, and new UI that makes it easier to play. Paradox actually made some research to discover what people wanted to pay for: new UI features, things that gives you more power to control things, and "flavor" that makes something unique so you can go to another area in the game you haven't been able to see before. 
  • You can't look 12 years into the future when trying to predict where the game industry will be. 
  • Limited time and money is actually good when making games because it forces you to actually release a game. More time and money will not necessarily make a better game. 
  • Paradox has failed making games. For example, when they realized that the game Runemaster wasn't fun, they stopped developing it. 
S02E02
  • Paradox is trying to release a Linux version of their games. The Linux version is not making money because it costs money to also support Linux and not that many Linux users are buying the game. But they argue it's good to always have your "doors open." By saying that I think they mean that if Linux becomes a big gaming platform in the future, the know how to make games for Linux.  
  • The CEO of Paradox argued that one of the reasons Paradox is successful is because of their relationship with the players. 
  • Paradox will soon get a new CEO who has experience from the gambling industry, but no experience from the game industry. The current CEO argues that Paradox will still make the same games but they will try to reorganize the company to make it more efficient to develop those games.   
  • Don't interfere with people in creative industries. When Paradox is buying a game company, they stay away from those companies and let them do their special thing. 
  • Don't forget that you also need to sell your game to someone. Everyone in the organization should understand where the money should come from to be able to make better decisions.
S02E03
    • GDC is more about the meetings and less about the talks. 
    • It's easier to sell a game based on a known intellectual property, like Star Wars, than to invent a new IP. Included in IP are also brands, themes, and code like the Unity game engine. Example of a theme is World War 2, which is not a protected IP so Paradox can use it to help people understand what to expect from a game. It's common in the game industry to license an IP, like using Unreal game engine when making the game or making a game based on the Mad Max movies.
    • It's a challenge to create your own IP. Cities: Skylines is a successful game where you build your own city. But what defines CS? You can argue that the blue bird telling people what's going on in the game is an IP. One test you can use to see if you have an IP is to ask yourself: Can I cosplay my game? You can cosplay as the bird, but you can't really cosplay as a building or a road. 
    • Paradox is generally not licensing IPs because they want to focus on the long-term, and using someones IP is short-term because the other guy might stop you from using the IP. But they published Battletech which is a licensed game based on the MechWarrior universe. 
    • When you have an IP it's important to manage the IP to not destroy it. Each time a bad Star Wars movie is released, the value of the IP is diluted. If you release different games based on an IP where each game is doing its own interpretation of what the IP is, the IP is also diluted. This is also why free fan-games are generally not allowed. The value of the IP might be diluted if you make a Star Wars game even though no money is involved. 
    S02E04
    • Even though Paradox has made many games they haven't really figured out how to teach the players how to play the games. For example, the older generation who has played SimCity will think it's easy to play Cities:Skylines, but the younger generation will find it harder because CS doesn't have a real tutorial - only small boxes with text appearing above the buttons you should press when you have just started the game. Also the new game Surviving Mars got criticism for being too hard to learn. 
    • To make sure the game is easy to play you can release it as an "early access" at a lower price so people can buy it and give you feedback before the final release. But Paradox is instead releasing their games with a full price and then give you free updates based on the feedback, which is similar to "early access" because no-one knows what "early access" actually is. 
    • Users who review your game are sometimes doing it for political reasons. So a game can sell well even though it has a low score. 
    S02E05
    • Paradox has its own convention called Pdxcon. The con is nearly profitable because you have to pay a ticket to be able to attend, but Paradox has seen that they get a boost to the announcements they are making at the con compared to if they had had the show at E3 where many other games are announced and what you announce is lost in the noise. 
    • Because many games are updated over time, it becomes harder and harder to judge them by looking at reviews. 
    • Good reviews generate more sales if the game is new, but good reviews don't matter if the game is a part of an established series of games. 
    • Newly released games should get a score above 80 to sell well. 
    • Some are giving reviews for political reasons and some are giving "odd" reviews. For example, I read a review where someone gave Pubg a bad review despite having played it for hundreds of hours. If you've played something for hundreds of hours and just paid $30 for it, was that game really bad? Paradox argues that a good idea is to give trusted members a larger part of the final review score. This is not a new idea because many people have earlier trusted larger magazines, but now these magazines have been replaced by individuals like you and me.  
    S02E06
      • As said before, intellectual properties are important, and now Paradox has decided to make more money by licensing their ips to physical board game publishers. According to their research, they realized that their fans wanted to give them more money and you can only add so and so much to a computer game, so they needed to come up with something else.  
      • Let your players create the game they want because they will do it for free and you can spend your time doing something else. You accomplish this by giving them the ability to mod the game. Out of the top 5 games on steam, 4 started out as mods. Counter-strike is one of them! 
      • Paradox doesn't encourage people to pirate their games, but they will not chase them. They argue that if people play their games, it will strengthen the eco-system around their games so more people might in the end buy their games.
      • Other medias Paradox might be interested in are movies and television series. But their previous idea to extend their games into books failed.   
      S02E07
      • Paradox is not only developing games, they are also publishing games. One of the games they published is BattleTech, and now Paradox has decided to acquire the studio behind the game: Harebrained Schemes. 
      • This was not the first game company Paradox bought. Other recent acquisitions/investments include White Wolf, Triumph Studios, and Hardsuit Labs.
      • Today you not only need to be able to make a game, you also need to be able to market the game because so many games are released each day. Yes, most games are not worth playing but it's still difficult to show the players that your game is worth playing. This is why Harebrained Schemes decided to sell the company so they can focus on making games and Paradox can focus on marketing their games. 
      • Acquisitions in the game industry have a bad reputation. One of my favorite games was Command & Conquer developed by Westwood Studios. When Electronic Arts acquired Westwood Studios the game series went downhill and now Westwood Studios doesn't exist anymore. 
      • Paradox is acquiring companies to grow and they want to grow by adding more IPs, which has been discussed before. Since it's difficult to come up with your own IP, it's easier to acquire someone else's IP. Harebrained Schemes's IPs are the BattleTech universe and Shadowrun. 
      S02E08
      • The focus of E3 is mainly on AAA games, so if you are making a smaller game it will fall between the cracks. But E3 gives you a good chance to meet other people, and you don't have to meet them at the main event - you can meet them at the hotel.
      • When you announce a new game it's also important to tell people what they can expect from the game. This is why game companies show gameplay and not a movie when they announce a new game because it's easier to show what people can expect from a game by showing gameplay. But there are exceptions to this rule, such as Cyberpunk 2077, which doesn't show any gameplay. 
      • Even though prices are discounted when the Steam summer and Christmas sales are happening, game companies make a lot of money from the sales. But Paradox also has other sales during the year, such as when their convention is happening and when they release a new expansion pack for an existing game. 
      • Yes, profit per sold game during a discount will be lower but more people will play their games and Paradox will thus get more long-term customers. These customers will buy new games from them at full price and new expansion packs for the game they bought at discount. So you have to think long-term and not focus on a single game.  
      • Some argue that discounts are a bad idea because people will see the product as something bad because it's always so cheap to buy it. 
      • If your game is selling, then why should you lower the price of the game? For example, the game Pubg ignored the Steam summer sale the first year because it was the top-selling game on Steam, so why should they lower the price? The next year, Pubg participated in the summer sale because it was no-longer a top-selling game. 
      • When Paradox during a weekend decided to give away a six year old game for free, it ended up on the top-ten list on Steam. What they could see was that more people also bought the expansion packs for the game they got for free. 

      November 19, 2018

      Tesla Motors Simulator - 2018 update

      0 comments
      I've spent some time updating a Tesla Motors Simulator I originally made to learn Unity. It's free so I will not make money from it - but people are playing it so I will learn a lot about what can go wrong when releasing a game. For example, after uploading the latest update some Mac and Linux users reported that the game was pink so I had to come up with a fix for that which was disabling fancy post-processing-effects and change from Linear to Gamma color space. If they had bought the game, they would have demanded a refund and given me a bad review. Anyway, this is the difference between the old and new versions - and a comparison with the real thing:

      Update 1. New Supercharger model. The reason the cable in the old version looks strange was because you could move the cable and attach it to a car and animating cables are kinda tricky, but I disabled that in the new version.


      Update 2. New Factory model. If you wonder how I made the trees and bushes, I've written an article about it here: How to make stylized "The Witness" trees in Blender.


      Update 3. New Test-track model. Behind the factory, Tesla has a small test-track where they test new cars and let customers test their cars, which you can see on YouTube. When creating the first version I used Google maps as a reference, and when texturing it I used two large textures which is a really bad idea to texture terrain because the result is blurry. To improve the textures I used a method called Tri-Planar Texture Mapping


      Update 4. New Model S model. When making a car in 3d you need blueprints to make it easier to get the correct shape. What I learned now is that blueprints are not always accurate. I've always thought there was something strange with the old Model S model even though it matched the blueprint. Then I realized that the blueprint was of an old prototype Model S so when I added new blueprints the shape was different, so I had to remake it for this update.


      Update 5. New Model 3 model.

      Update 6. New Semi model. About one year ago, Tesla revealed that they were making a truck, so I had to add it to the 2018 update. It's not 100 percent complete, it's missing some details in the back, but the overall shape is correct.


      Update 7. New Roadster 2020 model. At the same time as when Tesla revealed the semi, they also revealed a new Roadster. The old Roadster was in the game and I've decided to retire it because maintaining five models is more work than enough. But I've added the new model - and YES! it can do 0-100 km/h in 2 seconds.


      And if you want to play it, you can download it here: Tesla Motors Simulator.