tiendil.org/en
3 subscribers
31 links
Essays about game development, thinking and books
Download Telegram
Dungeon generation — from simple to complex

I spent a few evenings testing the idea of generating space bases.. The space base didn't work out, but the result looks like a good dungeon. Since I went from simple to complex and didn't use rocket science, I converted the code into a tutorial on generating dungeons in Python.

By the end of this tutorial, we will have a dungeon generator with the following features:

- The rooms will be connected by corridors.
- The dungeon will have the shape of a tree. Adding cycles will be elementary, but I'll leave it as homework.
- The number of rooms, their size, and the "branching level" will be configurable.
- The dungeon will be placed on a grid and consist of square cells.
- The entire code can be found on github.

There won't be any code in the post — all the approaches used can be easily described in words. At least, I think so.

Each development stage has a corresponding tag in the repository, containing the code at the end of the stage.

The aim of this tutorial is not only to teach how to program dungeon generators but to demonstrate that seemingly complex tasks can be simple when properly broken down into subtasks.

This is a translation of a post from 2020

https://tiendil.org/en/posts/dungeon-generation-from-simple-to-complex
My GPTs and prompt engineering

I've been using ChatGPT almost since the release of the fourth version (so for over a year now). Over this time, I've gotten pretty good at writing queries to this thing.

At some point, OpenAI allowed customizing chats with your text instructions (look for Customize ChatGPT in the menu). With time, I added more and more commands there, and recently, the size of the instructions exceeded the allowed maximum :-)

Also, it turned out that a universal instruction set is not such a good idea — you need to adjust instructions for different kinds of tasks, otherwise, they won't be as useful as they could be.

Therefore, I moved the instructions to GPT bots instead of customizing my chat. OpenAI calls them GPTs. They are the same chats but with a higher limit on the size of the customized instructions and the ability to upload additional texts as a knowledge base.

Someday, I'll make a GPT for this blog, but for now, I'll tell you about two GPTs I use daily:

- Expert — answers to questions.
- Abstractor — makes abstracts of texts.

For each, I'll provide the basic prompt with my comments.

By the way, OpenAI recently opened a GPT store, I'd be grateful if you liked mine GPTs. Of course, only if they are useful to you.

https://tiendil.org/en/posts/my-gpts
New concepts for tracking:

Computational mechanics

Authors minus for tautology. There is computational mechanics, which deals with numerical modeling of mechanical processes and there is an article about it on the wiki. This post is not about it.

This post is about computational mechanics, which studies abstractions of complex processes: how emergent behavior arises from the sum of the behavior / statistics of low-level processes. For example, why the Big Red Spot on Jupiter is stable, or why the result of a processor calculations does not depend on the properties of each electron in it.

ε- (epsilon) machine

The concept of a device that can exist in a finite set of states and can predict its future state (or state distribution?) based on the current one.

Computational mechanics allows (or should allow) to represent complex systems as a hierarchy of ε-machines. This creates a formal language for describing complex systems and emergent behavior.

For example, our brain can be represented as an ε-machine. Formally, the state of the brain never repeats (voltages on neurons, positions of neurotransmitter molecules, etc), but there are a huge number of situations when we do the same thing in the same conditions.

Here is a popular science explanation: https://www.quantamagazine.org/the-new-math-of-how-large-scale-order-emerges-20240610/

P.S. I will try to dig into scientific articles. I will tell you if I find something interesting and practical.
P.P.S. I have long been thinking in the direction of a similar thing. Unfortunately, the twists of life do not allow me to seriously dig into science and mathematics. I am always happy when I encounter the results of other people's digging.
About the book "Piranesi"

"Piranesi" is both a continuation of the magical stories of Susanna Clarke and an independent book.

The book has no direct connection with the world of English magic [ru] from "Jonathan Strange & Mr. Norrell". If desired, one can find a connection and even say that the worlds are the same, only at different times: the events of "Piranesi" take place in the early 2000s. However, the author did not give any hints on this. Therefore, I consider the worlds to be different for now.

Susanna continues to persistently and effectively dig not even in the direction of animism as the basis of world perception but in the direction of extremely holistic view of the world, in contrast to the currently dominant reductionism.

The latter blows my mind. As an engineer, I'm an intuitive reductionist due to professional deformation. Reading "Jonathan Strange" and "Piranesi", I felt how Clarke, like Peter the Great, cuts a window in my brain to another picture of the world, a different world perception. And it's wonderful.

By the way, don't confuse holism with, say, an engineering view of the world, a-la systems engineering [ru] or even science. The latter is about decomposing reality into isolated parts with clear boundaries and synthesizing "pure" models of the world [ru], while in holism, the parts have no clear boundaries and penetrate each other.

https://tiendil.org/en/posts/about-book-piranesi
Created new GPT: https://chatgpt.com/g/g-T1xz0gAMI-ontology-master

Input a term, get a tree of its ontological neighborhood/classification.

Convenient when studying a new area and wanting to understand its structure.
If you are interested in procedural generation and cellular automata, check out this project: https://github.com/mxgmn/MarkovJunior

Developers made a cool DSL for describing cellular automata and a system for its interpretation. See the pictures in the repository.

A couple of years ago, during my last sabbatical, I made a prototype of something similar, but more for internal use and learning (I was studying Julia at the time), and here is a full-fledged product. Glad to know I was digging in the right direction.

In my opinion, cellular automata and, in general, the ideas of topology and topological proximity, will say their own word in procedural generation and AI (in general, convolutional networks work on topological proximity). Therefore, it is better to keep an eye on them.
Concept document for a space exploration MMO

As a hobby, I write concept documents for games. This is first in English. I have a few more in Russian and will eventually translate them.

Title: Lords Captains MMO

https://tiendil.org/en/posts/concept-document-space-exploration-mmo
Our world is complex, and the events that happen in it usually don't have a single clear cause or story.

But we, humans, are not that complex. Or rather, we are complex, but we are not good at managing this complexity.

To explain what is happening around us we create stories — narratives that we use as a base for understanding reality and making decisions.

Generally, we can work with a spectrum of reasons in our heads. But when we want to explain the situation to others, for example, a team, we usually can't pass the full picture. People are in completely different contexts and have less motivation to bother themselves with "someone else's problems", etc. And sometimes it's just not ethical :-D

That's why we usually have to choose which story to tell. There are many variants, and each will affect the effectiveness of the work, morale, relationships between teams, etc.

Narratives can be different; Aaron Suggs, a technology leader in Chapel Hill, NC, provides a good example of their diversity.

https://ktheory.com/3-ways-to-construct-a-narrative/
Review of the book "The Signal and the Noise"

Nate Silver — the author of "The Signal and the Noise" — is widely known for his successful forecasts, such as the US elections. It is not surprising that the book became a bestseller.

As you might guess, the book is about forecasts. More precisely, it is about approaches to forecasting, complexities, errors, misconceptions, and so on.

As usual, I expected a more theoretical approach, in the spirit of Scale [ru], but the author chose a different path and presented his ideas through the analysis of practical cases: one case per chapter. Each chapter describes a significant task, such as weather forecasting, and provides several prisms for looking at building forecasts. This certainly makes the material more accessible, but personally, I would like more systematics and theory.

Because of the case studies approach, it isn't easy to make a brief summary of the book. It is possible, and it would even be interesting to try, but the amount of work is too large — the author did not intend to provide a coherent system or a short set of basic theses.

Therefore, I will review the book as a whole, provide an approximate list of prisms, and list some cool facts.

https://tiendil.org/en/posts/review-of-the-signal-and-the-noise
Migrating from GPT-3.5-turbo to GPT-4o-mini

Recently OpenAI released GPT-4o-mini — a new flagship model for the cheap segment, as it were.

- They say it works "almost like" GPT-4o, sometimes even better than GPT-4.
- It is almost three times cheaper than GPT-3.5-turbo.
- Context size 128k tokens, against 16k for GPT-3.5-turbo.

Of course, I immediately started migrating my news reader to this model.

In short, it's a cool replacement for GPT-3.5-turbo. I immediately replaced two LLM agents with one without changing prompts, reducing costs by a factor of 5 without losing quality.

However, then I started tuning the prompt to make it even cooler and began to encounter nuances. Let me tell you about them.

https://tiendil.org/en/posts/migrating-from-gpt-3.5-turbo-to-gpt-4o-mini
The Rust community introduces the formation of annual goals through RFCs.

- Base RFC: https://github.com/rust-lang/rfcs/pull/3614
- Motivation post: https://smallcultfollowing.com/babysteps/blog/2023/11/28/project-goals/

Why it's interesting to follow:

- The RFC approach is cool.
- It is an example of an open-source approach to goals and decision-making: not directivly from the top, but via consensus from the bottom.
Rust is a big, serious project. It is young and not ossified. A lot of smart people move it forward. This activity can become a good source of best practices.

To top it off, I'll remind you about my post on the results of introducing RFCs in a team: https://tiendil.org/en/posts/two-years-writing-rfc-statistics
Grainau: hiking and beer at 3000 meters

For her vacation, Yulia decided to show me the beautiful German mountains and took me for a couple of days to Grainau — it's a piece of Bavaria that's almost like Switzerland. At least, it is similar to the pictures of Switzerland that I've seen :-D

In short, it's a lovely place with a measured pace of life. If you need to catch your breath, calm your nerves, and enjoy nature, then this is the place for you. But if you can't live without parties, you'll get bored quickly.

What's there:

- The highest mountain in Germany plus a couple of glaciers.
- There's skiing in winter. If you really need it, you can find a place to ski in summer, but the descent is short, and the lifts are turned off.
- A large clean lake and a couple of smaller ones.
- A huge number of trails for hiking.
- A huge number of waterfalls, streams, and a couple of mountain rivers.
- Restaurants with beer.
- Beautiful fallen trees in the forests, private property, fences, cows with bells, and "racing tractors" (I don't know how to name this phenomenon better, - but tractors are moving fast there :-D).

This is briefly, see details in the post.

https://tiendil.org/en/posts/grainau-hikes-and-beer-on-3000-meters
Preparing a business plan for a game on Steam

When I posted my final presentation for World Builders 2023, I promised to tell how I made a roadmap and a financial model for the game. So, here they are.

At the end of this post, we will have:

- A brief strategy of our company: what we do, how, and why.
- A table with our beacons — successful games roughly similar to what we want to make. Similar in gameplay, team size, budget, etc.
- A composition of the team we need to assemble.
- A roadmap — a development plan for our game.
- An outline of our marketing strategy.
- A financial model — how much we will spend, how much we will earn.
- A large number of my caveats throughout the post.
- Jokes and witty remarks.

All the final documents are shared.

https://tiendil.org/en/posts/world-builders-2023-business-plan-example
I continue developing my news reader: https://feeds.fun

To gather information and people together, I created several resources where you can discuss the project and find useful information:

- Blog: https://blog.feeds.fun
- Discord server: https://discord.gg/C5RVusHQXy
- Reddit: https://www.reddit.com/r/feedsfun/

So far, there is no one and nothing there, but over time, there will definitely be news and people.

If you are interested in this project, join! I'll be glad to see you and will try to respond quickly to all questions.
Recently, I unexpectedly encountered a justice system in the USA.

- In 2017-2018, when there was a crypto boom, I invested a little in a mining startup: I purchased their tokens and one hardware unit.
- The startup went up and began to build a mega farm, but it didn't work out — the fall of Bitcoin coincided with their spending peak, the money ran out, and the company went bankrupt. It's funny that a month or two after filing for bankruptcy, bitcoin played back everything. Sometimes you're just unlucky :-)
- I had already written off the lost money, of course. I acted on the rule "invest only 10% of the income you don't mind losing."
- Since everything legally happened in the USA, people gathered there and filed a class action lawsuit.
- I received a letter stating that I would be automatically among the plaintiffs if I did not refuse. I did not refuse; when else would I get an opportunity to participate in a class action?
- Everything calmed down until 2024.
- In the spring, another letter came: "Confirm the ownership of the tokens and indicate their quantity. We won and will share the remaining among all token holders proportionally, minus a healthy commission to the lawyers."
- But how do I confirm? More than five years have passed. The Belarusian bank account is closed, the company's admin panel is unavailable, and there was no direct transaction in the blockchain—I paid in Bitcoin directly from some exchange (although it is not recommended to do so).
- I found an email from the company confirming I bought tokens (without the amount) and printed it as a PDF. I attached it to the application with screenshots of the transactions from the exchange for the related period. I gave the address of my current wallet, where these tokens lie dead weight. I sent everything.
- Today, I received $700 in my bank account. Of course, this is not all the lost money, nearly 25%, maybe slightly more.

What conclusions can be drawn from this:

- Sometimes, you just don't get lucky in your business.
- Keep all emails. You never know what and when will come in handy.
- Class action lawsuits work and do it in an interesting way.
- Justice in the USA works slowly but, apparently, inevitably and unexpectedly (for me) loyally to minor participants in the conflict. At least sometimes.

https://tiendil.org/en/posts/experience-in-class-action-lawsuit-in-the-usa
Top LLM frameworks may not be as reliable as you think

Nearly a month ago, I decided to add Gemini support to Feeds Fun and did some research on top LLM frameworks — I didn't want to write my own bicycle.

As a result, I found an embarrassing bug (in my opinion, of course) in the integration with Gemini in LLamaIndex. Judging by the code, it is also present in Haystack and in the plugin for LangChain. And the root of the problem is in the Google SDK for Python.

When initializing a new client for Gemini, the framework code overwrites/replaces API keys in all clients created before. Because the API key, by default, is stored in a singleton.

It is death-like, if you have a multi-tenant application, and unnoticeable in all other cases. Multi-tenant means that your application works with multiple users.

For example, in my case, in Feeds Fun, a user can enter their API key to improve the quality of the service. Imagine what a funny situation could happen: a user entered an API key to process their news but spent tokens (paid for) for all service users.

I reported this bug only in LLamaIndex as a security issue, and there has been no reaction for 3 weeks. I'm too lazy to reproduce and report for Haystack and LangChain. So this is your chance to report a bug to a top repository. All the info will be below, reproducing is not difficult.

This error is notable for many reasons:

1. The assessment of the criticality of the error depends a lot on taste, experience, and context. For me, in the projects I worked on, this is a critical security issue. However, it seems that this is not critical at all for most current projects that use LLMs. Which leads to some thoughts about mainstream near-LLM development.

2. This is a good indicator of a low level of code quality control: code reviews, tests, all processes. After all, this is an integration with one of the major API providers. The problem could have been found in many different ways, but none worked.

3. This is a good illustration of the vicious approach to development: "copy-paste from a tutorial and push to prod". To make such a mistake, you had to ignore both the basic architecture of your project and the logic of calling the code you are copying.

Ultimately, I gave up on these frameworks and implemented my own client over HTTP API.

My conclusion from this mess is: you can't trust the code under the hood of modern LLM frameworks. You need to double-check and proofread it. Just because they state that they are "production-ready" doesn't mean they are really production-ready.

Let me tell you more about the bug and suggest a theory of why such bugs could happen.

https://tiendil.org/en/posts/top-llm-frameworks-may-not-be-as-reliable-as-you-may-think
Notes on backend metrics in 2024

Once in 2-3 years, I start a new project and have to "relearn" how this time to collect and visualize metrics. It is not a single technological thing that changes over time, but it is guaranteed to change.

I sent metrics via UDP to Graphite, used SaaS solutions like Datadog and New Relic, aggregated metrics in the application for Prometheus, and wrote metrics as logs for AWS CloudWatch.

And there were always nuances:

- The features of the project technologies and architecture impose sudden restrictions.
- Technical requirements for metrics completeness, correctness, and accuracy collide with business constraints on the cost of maintaining infrastructure.
- Specialized databases for storing time series emerge, with which backend developers rarely deal directly.
- Not to mention the ideology and personal preferences of colleagues.

Therefore, there is no single ideal way to collect metrics. Moreover, the variety of approaches, together with the rapid evolution of the entire field, has produced a vast number of open-source bricks that can be used to build any Frankenstein.

So, when the time came to implement metrics in Feeds Fun, I spent a few days updating my knowledge and organizing my thoughts.

In this essay, I will share some of my thoughts on the metrics as a whole and the solution I have chosen for myself. Not in the form of a tutorial but in the form of theses on topics I am passionate about.

https://tiendil.org/en/posts/notes-on-backend-metrics-in-2024
I found an excellent in-depth analysis of Goodhart's Law (when a measure becomes a target, it ceases to be a good measure).

Cedric Chin breaks down the law into its components and provides examples from Amazon's practice on how they work with them.

In brief: everything is not so straightforward and not so bad.

Short version in my blog: https://tiendil.org/en/posts/goodharts-law-not-useful
Full version by the author: https://commoncog.com/goodharts-law-not-useful/
Notes on AI in 2024: industry transparency

Nearly a year and a half ago, I published a major forecast on artificial intelligence.

Recently, I've decided to expand on the prognosis, but a sizeable comprehensive post isn't coming together, so there will be a series of smaller notes.

I'll start with industry transparency: the current AI movement has several impressive aspects that I'd like to discuss.

https://tiendil.org/en/posts/ai-notes-2024-industry-transparency