<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jack Turpitt on Medium]]></title>
        <description><![CDATA[Stories by Jack Turpitt on Medium]]></description>
        <link>https://medium.com/@jackturpitt?source=rss-1922cb40092------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*j0ajgSo8nsTULgphbh2CRw.jpeg</url>
            <title>Stories by Jack Turpitt on Medium</title>
            <link>https://medium.com/@jackturpitt?source=rss-1922cb40092------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 11:57:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jackturpitt/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Solving my Kitchen Nightmares with an AI Cookbook]]></title>
            <link>https://medium.com/@jackturpitt/solving-my-kitchen-nightmares-with-an-ai-cookbook-a61802a5ee50?source=rss-1922cb40092------2</link>
            <guid isPermaLink="false">https://medium.com/p/a61802a5ee50</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Jack Turpitt]]></dc:creator>
            <pubDate>Thu, 29 Feb 2024 05:19:16 GMT</pubDate>
            <atom:updated>2024-03-02T05:00:31.886Z</atom:updated>
            <content:encoded><![CDATA[<p>Dish Up is an AI powered cookbook. You take a photo of whatever groceries you have laying around and it writes you a recipe to cook with them. It also helps you keep track of what ingredients you need to buy to cook this week’s meals. Here’s how it works:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FyjA6pr_3zZI%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DyjA6pr_3zZI&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FyjA6pr_3zZI%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/22ce255f7b146dffc8529f020bedd78e/href">https://medium.com/media/22ce255f7b146dffc8529f020bedd78e/href</a></iframe><p>Dish Up is available on the <a href="https://apps.apple.com/nz/app/dish-up/id6478479791">iOS App Store</a>.</p><h3>Introduction</h3><p>I’ve been quite awestruck with the recent wave of advancement in consumer facing AI. I have strong concerns about how these companies license the training data that they end up profiting from, but I can’t deny that tools like ChatGPT have had a more significant impact on my day-to-day life than most technologies that I can remember. Except maybe the iPod Nano. I haven’t been able to shake the feeling that by using ChatGPT as a glorified search engine I might be underutilizing its potential. With that in mind I spent some time brainstorming ways that I could use these AI tools as building blocks in a project of my own.</p><p>That project eventually became Dish Up. This is a break down of how I tackled the project, from initial conception, to development, to release.</p><h3>Prototyping</h3><p>The first step was to prove the idea as quickly as possible. If I couldn’t get the core features of ingredient scanning and recipe generation to work then the idea was a bust from the start. I took a picture of my fridge and set a goal to generate a recipe from it by the end of the evening. I opted for Python for the initial prototype because its lends itself well to quick and dirty work. I spent some time deciphering the <a href="https://platform.openai.com/docs/api-reference/introduction">OpenAI API spec</a> before loading up my developer account with $10 to get started. OpenAI has different models for different purposes. I was able to use thegpt-4-vision-preview model to get a list of ingredients from an image and the gpt-4 model for generating recipes from that list. After a few hours of cracking away at it we had a working prototype and our very first recipe! I happened to be moving house at the time so the fridge was a bit barren, but the program tried its best.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fitTn6H_31kK-ttNLYCHYg.png" /><figcaption>The First Generated Recipe</figcaption></figure><p>With the prototype complete it seemed that the project would be viable. I was confident that all of the remaining hurdles would be surmountable even if I didn’t know exactly how to tackle them yet.</p><h3>Moving to Mobile</h3><p>The first hurdle was getting the project running on mobile, something I ‘d never done before. The technology of this project is only a few small building blocks on top ChatGPT, but I felt that I could add a lot of value by solving a specific problem in a convenient way. That convenience starts by making it accessible from your pocket. After a bit of research I landed on the <a href="https://ionicframework.com/">Ionic Framework</a>. It’s a framework that allows you to export a web design to native apps on both iOS and and Android. This was perfect as it would allow me to develop for the major mobile platforms <em>and </em>let me leverage my existing experience with ReactJS. Getting the project setup for web was very straightforward and after a few evenings of wrestling with the XCode ecosystem I was able to get something running on my iPhone for the first time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*swDYI9pMCe-gXH8irByePQ.png" /><figcaption>Boilerplate Project Running on Mobile</figcaption></figure><p>The move to mobile also required a separation of backend and frontend. I knew that the backend would need to make a lot of API requests and manipulate a lot of arbitrary JSON data. To make sure that I could keep iterating quickly on stuff like this I decided to stick with a python backend until I was ready to tighten up the codebase for production a bit further down the line. Using the Flask library I could put some small wrappers around the work that we’d already done in the initial prototype and BOOM! We had an HTTP server that our mobile app could use to to generate recipes.</p><h3>Feature Development</h3><p>With an application running on my phone it was time to start fleshing out some features. I had initially intended to just package up the recipe generation feature with some nicer UI and call it a day, but as I got deeper into the project it became clear that a bit more would be needed to make the app a useful a tool instead of an interesting toy.</p><p>The first step was the recipe generation feature. I followed along with some of the Ionic tutorials to get access to the camera and photo library so users could load photos into the app and preview them before submitting. Once an image has been submitted it is scanned for ingredients which are then displayed to the user. The user submits their ingredients once they are happy with them and a generated recipe is displayed. The backend parses the plain text output that it receives from the AI into a structured JSON format before sending it to the app. This allows us to structure the recipe page however we like on the frontend.</p><p>Notably, the user is able to edit the ingredients before generating the recipe. Although the AI generated content, such as the ingredient list, is quite good, it is prone to mistakes. If the user is trapped in a closed system where they can’t correct these mistakes it can be very frustrating. Throughout the app I tried to allow for user intervention wherever we relied on AI generated content. This acts as a kind of pressure release valve for inaccuracies in the AI and I think it’s a necessary step for applications that use AI in this way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/1*clJ3ZUmJ90rV3fr46L1a1w.gif" /><figcaption>Recipe Generation Feature</figcaption></figure><p>With the recipe generation feature in place I spent a few days using it around the house. This helped me to notice a couple of quirks about how I was interacting with it. Firstly, I was taking screenshots of recipes that I really liked and referring to them later. Secondly, I kept feeling the urge to tweak things about the recipes — sometimes the ingredients were too vague(beans instead of kidney beans, etc), sometimes there was an extra step that I wanted to note down, and sometimes I just wanted to rearrange the steps so that they were easier to follow. Both of these issues could be solved by a feature that lets you save generated recipes and edit them later on.</p><p>I chewed on this idea for a while, and the more I thought about it the more it began to creep into a larger and larger feature. If the recipes are stored in the backend then we need to have a deployed and resilient database, which means users need accounts to access their recipes, which means we need a login page, which means we need a way to reset passwords, and the list goes on and on. After I’d gotten sufficiently stressed about this I realised that there’s a much easier way. Because we’re developing a mobile app we already have user specific, resilient, free storage: the storage on the phone! This dramatically simplified the feature and, using Ionics&#39;s local storage capabilities, I had something up and running quite quickly. The editing feature was also straightforward. I’d already built quite a generic “editable list” component that I’d used for the ingredient list earlier. A bit of tweaking allowed me to repurpose this component for so users could edit the ingredients and method of a recipe.</p><p>With all of the infrastructure in place to edit recipes it was a very small hop to allow users to create recipes. All I needed to do was add a button that created an empty recipe in the “editing” state and the feature was basically done. This seemed quite valuable because it would allow users to have both generated recipes and recipes that they already loved from outside of the app stored together. I personally found that it made it much easier to integrate the app into my existing cooking routines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/1*_EBUj6I5iAvb6n5UOI03Jw.gif" /><figcaption>Saving and Editing Feature</figcaption></figure><p>The two features so far had made the app a nice addition to my life but I still had a glaring problem. I couldn’t get my mum use it. Mum is the best chef that I know. I’ve seen her come up with something to cook from a pantry that, to me, looks completely empty. She just doesn’t have a use for something that creates recipes for her. I figured that if the app could be useful to both me and her then it would cover almost the whole spectrum of cooking expertise.</p><p>We had a chat about what kinds of things would make her life easier. It ended up being a discussion about managing groceries and meals for a household. She likes to plan meals a week or two in advance and buy all of the groceries for the meals in one go, however she often runs into a couple common problems. Sometimes she’ll buy stuff that she already has, and sometimes she’ll assume that she already has an ingredient only to find it missing when she gets back from doing the shopping.</p><p>This seemed like a problem that we could solve! We already have a list of recipes which could be grouped together into a meal plan and we have a way to figure out what ingredients a user already has. I strung these existing features into a flow where the user selects some of their saved recipes, uses the image scanning to find out what ingredients they currently have, and are given a shopping list of all of the ingredients that they’d still need to buy to be able to make those meals. Users can then copy the shopping list to their clipboard to be used elsewhere like the notes app or a to-do list tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/1*hjbz-Ok5IzqVmU4kMkkAKw.gif" /><figcaption>Shopping List Feature</figcaption></figure><p>Although help text is provided for all of the features, this one is still not as intuitive as I’d like it to be. I think in the future it could use some more work on the UX to make sure that users are properly guided through the process.</p><h3>Design</h3><p>I’m sure it’s obvious if you’ve interacted with the app at all, but graphic design is not really my forte. Unfortunately, there’s no way to get better except to try.</p><p>I was building the app for quite a while before I decided to move away from the default Ionic colour scheme. I knew that it wasn’t going to cut it in the long run so I thought that it would be good to get some kind of visual identity in place early on. I only had a rough idea of what I was looking for — I wanted the app to feel like an old rustic cookbook. To me this meant off-whites for backgrounds and sticking to fairly desaturated colours for highlights. I used the website <a href="https://coolors.co/">Coolors</a> which helps you find pleasing colour palettes with a bit of randomness. I started with my cream background colour, and generated different palettes until I found something that fit what I was looking for.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o8hS8pRLElg3BDZqMPv2Bg.png" /><figcaption>The Dish Up Colour Palette</figcaption></figure><p>Ionic is quite good at running with a limited palette like this. It fills in a lot of the blanks by creating gradients between the different colours.</p><p>I briefly experimented with overlaying a coffee stained texture on the app to really double down on the “homely” feeling we were going for. This ended up just making my screen look dirty which drove me insane so I scrapped the idea.</p><p>The other aesthetic problem that I ran into was the design of the logo. Because it was a mobile app the logo was a necessity and there was really no getting around it. I decided to give it a go so I booted up GIMP(a free image editing software) and got cracking with the paintbrush tool (my apologies to any professional designers out there that are tearing their hair out reading this). The first iteration looked like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nwvt_2pYGl-qp8lDg2Tfpw.png" /></figure><p>Thankfully I had someone close to me let me know, very gently, that this doesn’t look good. I decided that trying to free hand this kind of thing with no experience probably wasn’t going to get me anywhere so I swapped to GIMPs path tool which uses much more manageable bezier curves. In my opinion the second pass came out a bit better, but the jury’s still out on if that constitutes “good”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BRyPYFcep44GfqqTAHy_FA.png" /></figure><h3>Revenue</h3><p>Now that I’d been using OpenAI’s API for a while the bill was starting to add up. I’d only been charged two or three dollars for all of the testing that I’d done, but it was clear that if the app was going to be openly available <em>and </em>financially sustainable then it would need to generate some kind of revenue. As much as I would love to, I can’t stretch my budget to the kitchen’s of an uncapped number of strangers. Several revenue models jumped to mind: up front purchases, premium subscriptions, or ads.</p><p>I quickly disqualified the up front purchase model. I wanted to create something convenient and accessible and putting up a pay wall as the first contact with the app worked against those goals.</p><p>The premium subscription model addressed that issue and I spent quite a while considering it, although in the end I decided against it as well. To make premium subscriptions worthwhile for users there would have to be a set of features that were off limits to them until they paid. This meant that I would need one feature set valuable enough to get people to download the app, and additional feature set valuable enough to get people to pay for it. It would also be a careful balancing act where I would need to ensure that there were enough premium users to pay for all of the OpenAI API requests from the free users. There were technical considerations too. A subscription model requires users accounts, customer support, and automated billing. In the end it seemed that a premium subscription model introduced the potential for financial liabilities and ballooned the scope of the project, however it’s definitely a path that might be worth exploring at some point in the future.</p><p>Eventually I settled for an ad-based model. Ads could be run without the logistical overhead of user accounts or recurring billing. Ads could also be specifically assigned to areas of the app that incurred costs by making OpenAI API requests. This would ensure that the revenue of the app would scale alongside its expenses, helping me sleep better at night.</p><p>I opted for <a href="https://admob.google.com/home/">Google’s AdMob</a> for serving ads. It seemed to be a widely used solution and after perusing through the documentation for a while it all seemed quite intuitive. It also has a <a href="https://github.com/capacitor-community/admob">nice library</a> that makes it convenient to integrate with Ionic and ReactJS. I was very excited to start racking up the ad revenue by testing the app hundreds of times on my own phone, but unfortunately AdMob has cottoned on to this kind of behaviour and makes you register your own phone as a “test device”. Once we had all of this set up we could display ads in the app. I then had to tackle when and where we should be displaying ads. In the end I went for the obvious choice. When we do operations that rely on requests to OpenAI two things happen. There is a small delay while the request is processed, and we are charged a small amount for the request. If we play an ad to user during this time then we should recoup the costs of the request and give them something to look at while they wait.</p><p>Now that I knew the app could generate revenue I wanted to double check that it could generate <em>enough </em>revenue. It could not. Because we show ads whenever we make OpenAI requests we can directly compare the income generated by an ad impression to the expense of the OpenAI request. This tells us if the app is going to make or lose money. With a bit of number crunching I found that we’d spend about $15 on OpenAI API requests for every 1000 ad impressions we generated. AdMob gives some estimates about how much revenue you can expect per 1000 impressions, and the higher end of this range was about $10. This means that we would be spending $15 to make, at most, $10. I’m certainly not an accountant but those numbers didn’t add up for me.</p><p>I wouldn’t be able to drive the revenue up without riddling the app with ads so my option was drive the cost of the OpenAI API requests down. There ended up being several interesting ways to do this.</p><p>The first was to change with OpenAI model we were using for generating recipes. I had been using gpt-4 to generate all of the recipes because it was the shiniest, newest model. By swapping to the gpt-3.5 model instead I was able to make the recipes roughly 40 times cheaper to generate and I wasn’t able to notice a difference in the quality of the recipes. My understanding is that as well as being less powerful than gpt-4, gpt-3.5 is also limited to information from before 2021. Luckily recipes haven’t changed much between 2021 and now so gpt-3.5 serves our needs well enough for a fraction of the price.</p><p>The second improvement was more technically interesting. Most of the cost of the API was being incurred by the image recognition, specifically gpt4-1106-vision-preview. I spent some time researching how the pricing was calculated for this model and it ended up being based on the size of the images you submit. It splits the image up into 512x512 tiles and charges you extra for each additional tile you use. This meant that the smaller the image, the cheaper the API requests. By shrinking the users images so that they fit into a set number of 512x512 tiles we were able to reduce the cost of the image recognition and also resolved an exploit that I was unaware of until now, where users could submit exceptionally large images to incur exceptionally large OpenAI costs for the service. I was expecting this loss of resolution to destroy the app’s ability to tell what ingredients were in an image but the difference was not that noticeable. It&#39;s not quite as good at spotting small or far away items but it&#39;s still perfectly usable and if the expenses don’t end up being too high in production we can look at increasing the resolution to improve the image recognition capabilities.</p><p>After these two improvement we’d reduced the average cost per 1000 impressions from $15 to around $3. If we expect somewhere between $4 and $10 of revenue per 1000 ad impressions it looks like the app should be able to keep itself afloat.</p><h3>Production Deployment</h3><p>Now that the feature development of the app was approaching completion it was time to get a bit more serious about our backend situation.</p><p>Until this point I’d been using the prototype backend written with Python and Flask. It had served us well but it’s days were numbered. Flask is single threaded by default, so it processes requests one by one. This meant that although it was perfectly responsive while I was testing it on my own, once it was being hit by any significant amount of traffic it would slow down to a crawl and might eventually start timing-out requests. Although the interpreted and loosely typed nature of Python made it great for quickly iterating on the idea at first, it makes me a bit antsy in production environments. I think a part of this comes down to personal development preference but I would much rather have a bit less flexibility and catch as many issues as possible at compile time than to get surprised by them at runtime. Nothing makes me feel more embarrassed than having my server crash because of a misspelled variable name. I spent an evening re-writing the backend in Go and, with a mournful farewell, deleted the python backend from the repository.</p><p>I’d also been running the entire stack off of my development laptop. To ensure that people would be able to use the app from places other than inside my house and at times other than when my laptop is open I would need a more reliable and accessible deployment. I spun up an instance on AWS and assigned it a domain name that I’d purchased for the app. I created a small packaging script that would create a systemctl service from my backend executable and bundle the service up into an rpm package. This let me easily deploy the backend to the instance and ensured that it could restart itself in the case of a crash or power failure. Now that the backend was expecting network traffic from outside of my local network I would want that traffic to be encrypted, so I enabled SSL and acquired an SSL certificate from a signing authority to prevent warnings on the client side. With all of this stuff up and running the app could now talk to the backend from anywhere with internet access.</p><p>There are many improvements that can be made here, largely around reliability and scalability. If the backend starts needing to serve heavy traffic then it may be worthwhile to increase the resources of the instance and set up load balancing between multiple instances.</p><h3>Stress Testing</h3><p>It was time to figure out how much of a beating the system could take. If we don’t find the limits ourselves then eventually the users will. I set up a quick flood test using Postman, a powerful HTTP client. The endpoint that scans the images for ingredients deals with the most data so that’s where I started. This initial flood test simulates 100 concurrent users sending requests to the system continuously for 3 minutes. The results are shown below, where the red line is the number of failing requests and the blue line is the average response time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*yMEaaOE5wl35eh6sH0-hUg.png" /><figcaption>Initial Stress Test</figcaption></figure><p>Almost all of the requests started failing immediately. It probably goes without saying but that’s not good! I did some investigating in the backend logs and it looks like we were hitting the OpenAI rate-limits by trying to process too much data too quickly. This turned out to be a problem that had to be solved with a wallet instead of a brain. OpenAI increases your rate limits with how much credit you’ve added to your account. By adding a bit more credit onto my account the rate limits were increased. I was going to need to add some more funds before the app was released anyway, so this wasn’t too much of a fuss. With that sorted out we were ready to run the test again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*UHv3tdHTGtri0RQuv7yxBQ.png" /><figcaption>Revised Stress Test</figcaption></figure><p>We see some significant improvement here. The server bears the load for almost a minute before it starts producing rate-limit errors. This still isn’t ideal but I think its something that we can work with as it shows that we can handle short bursts of high traffic. If we are in a position where we regularly have 100 concurrent requests for a sustained period of time then the app will be doing well enough that I can add more credit to the OpenAI account, increasing the rate-limit further. The rate-limits get exponentially higher so as the app scales this problem should eventually solve itself.</p><p>With that being said, I did want to know what kind of traffic we’d be able to sustain with our current configuration. With that in mind I reduced the number of concurrent requests from 100 to 20 and ran the test again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*hizmI6aw2tME5YUWSVKCcQ.png" /><figcaption>Sustainable Stress Test</figcaption></figure><p>This time we had no large error spikes, and the response times remained consistent. You can see that we did have 5 failed requests over the course of the run. These turned out to be OpenAI server errors. This is a handy thing to have caught and lets us know that we may need to implement some kind kind of retry behaviour to prevent them from being passed on to the user.</p><p>Overall I was quite pleased with these results. Our backend never crashed or experienced big latency spikes. Any errors that we did see originated from the OpenAI API and were handled gracefully. If we ever saw this kind of traffic in reality then I would consider the app to be a roaring success, and that success would give us the tools(i.e. the funds) to increase the rate-limits and reliability of the system.</p><p>Speaking of funds, this stress test also served as a valuable test of our assumptions about the revenue versus expenses of the app. Over the course of these stress tests I submitted roughly 3000 successful requests to the backend. This incurred a cost of about $16 from OpenAI. We’d expect somewhere between $20 and $30 in ad revenue from that number of requests, which should allow the app to be profitable.</p><h3>AI Fine Tuning</h3><p>Something that had been bugging me more and more over the course of the project is that the recipes were just… not very good. Sometimes you would get a banger recipe that sounded delicious, but more often than not the recipes had horrendous formatting, used ingredients that the user didn’t have, and missed essential steps like making sure chicken was cooked. I’ve heard rumours that salmonella is not a good time so I wanted to address these issues.</p><p>I started by trying to improve the prompts that I was giving to the OpenAI APIs. I listed out rule after rule, gave several examples, wrote with an authoritative tone, and even begged. Each of these additions moved us roughly in the direction that we were looking for, but as the prompts became more complex the results became less consistent.</p><p>In the end I looked for other solutions. OpenAI provides a feature called fine-tuning that ended up being exactly what we needed. Fine-tuning is quite simple in principle, you give the AI some example prompts and the kind of output that you would expect those prompts to produce. It will then, over several iterations, tweak its model until it’s producing results that are more in line with your expectations. The only catch is that you need quite a large number of examples for fine-tuning to be effective. I spent some time writing out about 20 recipes by hand. I made sure to use the structure that was expected by the backend, align the ingredients in the recipes with those given by the user, and use a consistent voice across the recipes. With the fine-tuning dataset ready I ran the job and updated our backend to point to the fine-tuned model instead of the base gpt-3.5 model. I had been expecting this to take several tries and much more data to get correct but after the first run almost all of the issues with the recipes had been resolved. A project-threatening problem had been solved!</p><p>The fine-tuning also had some unexpected results. I had created the sample recipes to solve specific functional problems such as formatting or ingredient use. After running the job I noticed that much more information than that had leaked into the model; the results began to echo my writing style and vocabulary. It was a bit uncanny seeing so much of myself represented in the results after providing so little information. When solving problems with traditional programming every issue must be handled explicitly. The program is a loyal soldier that follows orders to the T. When solving problems using AI things are much more implicit. It’s a bit like working with a child. It can be quite tricky to wrangle them into completing specific tasks but they’re always picking up much more information than you’d expect them to and that information rears its head in interesting ways.</p><h3>Distribution</h3><p>By this point the app was far enough along that I wanted to get it into some user’s hands.</p><p>To test the app with production ads, instead of the test ads that I’d been using, it needed to be listed on the App Store. Because production ads were the feature that I was most uncertain about I opted straight for the App Store instead of using Apple’s Test Pilot service for something like a closed beta. I had been dreading the App Store review process but with the exception of some tedious paperwork it was fairly painless. The app was approved on its first pass with no feedback.</p><p>After some testing with close friends and family, the app was now accessible to the general public!</p><h3>Wrap Up</h3><p>The development of this project has been very fun. It pushed me to learn areas of the software stack that I’d never used before and it was a good exercise in thinking about products in their totality, not just as a codebase. Its given me a deeper understanding of the new wave of AI tools that have been emerging, and how these tools can be used as a part of software development instead of as a replacement for it.</p><p>If you’ve made it this far I’d like to thank you for reading. If you have any thoughts or feedback about this development break down or the app itself don’t hesitate to flick me an email at jackturpitt@gmail.com.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a61802a5ee50" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dipping a Toe with Name Generation]]></title>
            <link>https://medium.com/@jackturpitt/dipping-a-toe-with-name-generation-268118f7d5de?source=rss-1922cb40092------2</link>
            <guid isPermaLink="false">https://medium.com/p/268118f7d5de</guid>
            <category><![CDATA[procedural-generation]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[creative-coding]]></category>
            <category><![CDATA[name-generators]]></category>
            <dc:creator><![CDATA[Jack Turpitt]]></dc:creator>
            <pubDate>Tue, 10 Mar 2020 02:48:55 GMT</pubDate>
            <atom:updated>2020-03-10T04:33:48.557Z</atom:updated>
            <content:encoded><![CDATA[<h3>Dipping a Toe in with Name Generation</h3><p>I find myself enraptured every time I come across a project that uses procedural generation to drive the art of world building.</p><p>The first project that really scratched this itch was <a href="http://www.bay12games.com/dwarves/">Dwarf Fortress</a>. Dwarf Fortress is a game that tells stories so elaborate, in a world so intricate, that the hardest part of the game is not missing the dwarven character arcs and narrative beats as they go whizzing past you.</p><p>Another masterpiece in the making of procedural world building is the project going on over at <a href="https://forhinhexes.blogspot.com/">for h in hexes</a>. This is a project of such immense breadth and depth that it boggles the mind. From what I can tell the aim of the project is to create a world to run DnD campaigns in. In pursuit of this goal the creator has generated landmasses from underlying tectonic plates, wind currents from the temperatures over the globe, nautical trade routes from the wind currents over the oceans, and probabilities of piracy for certain areas of the ocean based on the kinds of trade routes that pass through it. This alone would be enough to get my heart racing, and it hardly scratches the surface of the project.</p><p>One of the things that intrigues about <a href="https://forhinhexes.blogspot.com/">for h in hexes</a> is that the idea is not to create a tool that can pump out infinite worlds of slightly varied content, but rather to create a single world the scale of which exceeds the capabilities of traditional authorship. I find this kind of creation exciting because it allows you to use the craft of software development to create tools that can be used in the art of world building.</p><p>This kind of approach was used in the <a href="https://www.youtube.com/watch?v=4aw9uyj9MAE">PS4 Spiderman game</a>. The developers were able to use procedural generation to fill in the majority of the content<em> </em>of Manhatten. This allowed them to have a city that was both massive in scale and interwoven with detail.</p><p>It is projects like these that have me excited to begin cobbling together some procedural generation tools of my own creation. Hopefully in time I can have a suite of tools that enable me to do some software assisted world building.</p><p>What is a world without good names? For everyone except mathematicians “x going to y” is much less interesting than “The Fellowship of the Ring going to Mordor”. To produce interesting content in most user facing aspects of world building I felt that it was important to have a name generator. Name generation also seemed like a nice small scale way for me to dip my toe into procedural generation without getting lost along the way.</p><p>I have implemented some very naive name generators in the past. Most of these worked as follows. You write down a bunch of small syllables that you think could be mish-mashed together in any order without looking too weird, for example “ro”, “ja”, and “sha”, and then you do just that — randomly mish-mash them together and hope that it doesn’t look too weird.</p><p>This worked at the time in the sense that it gave me unique names like “roja” and “sharo” for whatever it was that I wanted to name. My problem with it was that there were blatant patterns with very little variation between the names. It was almost like just by looking at the names you could figure out how they had been generated.</p><p>Instead I looked around for some existing solutions to name generation that were out there. What I stumbled on was the <a href="https://en.wikipedia.org/wiki/Markov_chain">Markov chain</a>. A Markov chain defines a set of states, and the probability of moving from one state to another. This ends up being very useful for name generation, because we can treat each letter in the alphabet like a state, and have a probability of moving from every letter in the alphabet to every other letter. You can then generate a name by continually picking the next letter based on the letter you just chose.</p><p>“But how do you get those probabilities?” you may ask. Well, we first pick a bunch of existing words that we like the look of, and set the probabilities for each letter transition based on the actual probabilities that are in our sample words. One of the properties of this approach is that your generated words approximate the structure of your sample data whilst producing unique results. For example, in my sample set the letter “q” was <em>always </em>followed by the letter “u”. Because of this any time a “q” showed up in a generated word it was followed by a “u”.</p><p>This is one of the remarkable things about the Markov chain, it is able to abide by certain rules of word structure without ever being explicitly told them. This does have limitations however. Because my current implementation is only ever looking 1 character ahead certain rules are unable to be observed. For example it is pretty unlikely that I want the string “oooo” showing up in any of the names. Unfortunately, because the string “oo” showed up in the sample set the Markov chain is happy to put an “o” after another “o”, and will proceed to do so several times in a row.</p><p>This particular issue could be solved by looking at several of the previous characters and basing probabilities on that, but I fear that this may reduce the variation of the words. On top of this I would like to be able to specify some other rules that the Markov chain may not be able to pick up on just through observation, such as that every word must contain a consonant and a vowel, or that most words should be of a certain length(one character names are a bummer). For this reason the generator can be passed a predicate function that verifies whether a name is desirable or not. If the name isn’t desirable then we just re-roll a new one.</p><p>This combination of Markov chain generation with some light validity checking seems to work well for now. Here are the results of a run in which I generated 50 names based on a sample set of ~4000 female first names.</p><pre>Otiarbi, Calinde, Branirery, Bromaus, Diana, Reletesyax, Cena, Karurrorra, Tcabie, Lara, Innevidene, Riena, Frole, Hriviesy, Jory, Arin, Boba, Merusauga, Audisine, Nacastilin, Carittah, Cate, Narra, Hamidin, Farelaly, Eleres, Anaye, Ialietole, Chidra, Issatagin, Alosi, Jarierra, Mobeejee, Hetrarinne, Brikka, Jowid, Redargida, Fliseleve, Masuicca, Dadall, Anelemm, Zaia, Stemia, Vele, Viols, Jaray, Jonanie, Oryeleaba, Kabre, Dadegeinne</pre><p>Admittedly they are all quite… exotic, but most of them are at least pronounceable.</p><p>I think that modifying the sample set and the validity predicate based on the kind of names that you want to generate will give the author significant freedom of expression.</p><p>There are several things that I’d like to improve moving forward with this project. Firstly, I’d like to tighten up the API a bit. Its currently very brittle in the face of invalid sample data. It would also be great to have the option to do all of the training and generation in memory without having to produce output files. I’d like to have a look at giving the Markov chain a longer memory as well, so that it can look back several characters instead of just one. This memory length could be a configurable value that allows an author to choose between name variety and adherence to the sample set.</p><p>The source code for this project can be <a href="https://github.com/turpitron/word-generator">found here</a>. I invite you to check it out if you’re ever running low on creative juices and in need of some names(or words in general).</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=268118f7d5de" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>