Erstes Spiel mit Achievements? Activisions Aufnäher ab 1980
Die frühesten Achievements, die wir belegen können, steckten nicht im Spiel, sondern in der Post. Ab 1980 bat Activision Spieler, einen Highscore auf dem Fernseher zu fotografieren und einzuschicken, angefangen mit Dragster, und schickte einen Aufnäher zurück. Achievements als ein Punktestand über alle Spiele einer Konsole begannen 2005 mit der Xbox 360. Die Antwort hängt also davon ab, ob die Belohnung im Gerät leben muss.
Wer behauptet was?
| Quelle | Aussage |
|---|---|
| Game Informer (Kyle Hilliard, 2013) | Activisions Aufnäher seien „the original, tangible equivalent of today's digital Achievements and Trophies“, angeboten „from the very first games Activision published for the Atari 2600, and until around 1983“ |
| Atari Archive (Kevin Bunch, 2025) | Dragster, August 1980, „is the first of Activision's games to offer up a commemorative patch“, für eine Zeit unter 6 Sekunden |
| Wikipedia, Achievement (video games) | Datiert die Idee mit Activisions Aufnähern auf 1982 und nennt Gamerscore der Xbox 360 das erste leicht zugängliche System über mehrere Spiele |
| Microsoft auf der E3, 16. Mai 2005 | J Allard: „We've also a new concept called Achievements“, „a record of everything you've accomplished across your library of games“ |
| Game Developer (Mary Jane Irwin, 2009) | Abzeichen habe es auf Websites mit Gelegenheitsspielen gegeben, als täglichen Grund für einen Besuch, „before Microsoft co-opted them for Xbox Live“ |
Bei den Aufnähern sind sich die Quellen einig, beim Jahr nicht. Wikipedias 1982 steht nicht im Artikel von Game Informer, einer der beiden Quellen, auf die es sich stützt; dort heißt es, die Aufnäher kamen mit Activisions allerersten Spielen, und das Atari Archive datiert Dragster auf August 1980. Die Anleitung zu Dragster selbst, mit 1980 gekennzeichnet, verspricht jedem, der unter 6 Sekunden bleibt, die Aufnahme in den „World Class Dragster Club“; den Aufnäher nennt sie nicht.
Was gab es vor den Aufnähern?
Bevor Designer Ziele setzten, hielten Maschinen Highscores fest. Ben Medlers Geschichte der Spielanalyse von 2009 nennt Sea Wolf, ein Arcade-Spiel von Midway aus dem Jahr 1976, als „the first instance of a high score being recorded in a video game“. Es hielt die Punktzahl fest, aber nicht, wer sie erzielt hatte; Namen kamen 1979 mit Star Fire. Ein Highscore ist eine Marke zum Schlagen, kein Ziel, das ein Designer setzt, also ein Vorläufer.
Wie haben sich Achievements über die Jahre verändert?
| Wann | Spiel oder System | Was sich änderte | Quelle |
|---|---|---|---|
| 1976 | Sea Wolf | Ein Vorläufer: Die Maschine zeigt die bisher beste Punktzahl | Medler (2009) |
| August 1980 | Dragster | Ein vom Designer gesetztes Ziel, eine Zeit unter 6 Sekunden, belegt mit einem Foto und per Post belohnt | Atari Archive, Anleitung zu Dragster |
| Bis etwa 1983 | Activisions Spiele | Mehr als 40 Aufnäher auf mehreren Konsolen, jeder für ein Ziel wie 20.000 Punkte in Pitfall! | Game Informer |
| 1990 | E-Motion | Wikipedia nennt es eines der frühesten Spiele mit „some form of achievements“, fünf geheimen Boni im Spiel. Die Quelle dafür ließ sich nicht prüfen | Wikipedia |
| 16. Mai 2005, im Handel ab 22. November | Xbox 360 | Achievements und ein Gamerscore über alle Spiele der Konsole, sichtbar im Profil des Spielers | Microsoft, Wikipedia |
| 2007 | Steam | Wikipedia nennt Valve das zweite Unternehmen mit einem Achievement-System über mehrere Spiele. Der Artikel bei Game Developer von 2009 merkt an, dass Websites mit Gelegenheitsspielen schon vor beiden Abzeichen hatten | Wikipedia, Game Developer |
| 02.07.2008 | PlayStation-3-Trophäen | Trophäen in Bronze, Silber und Gold und eine Platin-Trophäe für alle Trophäen eines Spiels. Anfangs entschieden die Entwickler, ob sie sie einbauen | PlayStation Blog, Engadget |
| 07.05.2009 | Steam | Jedes Achievement zeigt, wie viel Prozent der Spieler es freigeschaltet haben | Steam-Neuigkeiten |
| 12.06.2013 | Xbox One | Achievements lassen sich nach dem Erscheinen eines Spiels hinzufügen, dazu neue „Challenges“ ohne Gamerscore. Microsoft schreibt: „Xbox blazed the trail back in 2005“ | Xbox Wire |
| 10.11.2016 | Xbox | Ein seltenes Achievement bekommt eine eigene Meldung und ein Diamant-Symbol | Xbox Wire |
Was zählt als Achievement?
- Eine Marke zum Schlagen. Ein Highscore, 1976. Die Maschine hält ihn fest, aber niemand hat ihn als Ziel gesetzt.
- Ein vom Designer gesetztes Ziel, belohnt außerhalb des Spiels. Activisions Aufnäher, ab 1980.
- Ein Ziel, das ein einzelnes Spiel festhält. E-Motion, 1990, ist die früheste Behauptung, die wir fanden, auf einer Quelle, die wir nicht prüfen konnten.
- Ziele, die die Plattform über alle Spiele festhält. Xbox 360, 2005.
Ein Aufsatz von Juho Hamari und Veikko Eranti von 2011 beschreibt Achievements als Ziele in einem Belohnungssystem, das ein „different system than the core game“ ist, und merkt an, dass sich der Name durchsetzte, weil Xbox Live und Steam ihn übernahmen. Nach dieser Definition passen die Plattformsysteme am besten, und die Aufnäher sind ein System außerhalb des Spiels im wörtlichsten Sinn.
Was lässt sich sicher sagen?
Activisions Aufnäher per Post sind die frühesten vom Designer gesetzten Achievements, die wir belegen können, laut Atari Archive ab Dragster 1980, laut Wikipedia ab 1982. Die Xbox 360, auf der E3 im Mai 2005 vorgestellt und ab November verkauft, ist das früheste belegte System, das Achievements für jedes Spiel einer Plattform festhielt, und mit ihr setzte sich das Wort durch. Beide Antworten stimmen, für verschiedene Definitionen.
Heute selbst bauen
Unser Blueprint für Achievements hält auseinander, was diese Geschichte auseinanderzuhalten gelernt hat. Die Liste der freigeschalteten Ziele ist die Wahrheit und wächst nur: Ein Ziel wird einmal freigeschaltet, wenn ein Zähler sein Ziel erreicht oder eine Gruppe anderer Ziele erledigt ist, so wie eine Platin-Trophäe funktioniert. Zähler steigen nur, und ein Bestwert-Zähler behält den höchsten Wert, statt zu addieren, wie ein Highscore. Die Einblendung ist nur Dekoration: Sie zeigt eine nach der anderen, und wenn ein alter Spielstand viele auf einmal freischaltet, werden die übrigen zu einer Meldung „und mehr“ zusammengefasst, sodass keine Freischaltung verloren geht. Die Prozentangaben von Steam und die Seltenheitsmeldung der Xbox brauchen Zahlen von allen Spielern, die ein einzelnes Spiel nicht kennen kann, deshalb sind sie nicht dabei.
- 25 Tests bestehen auf dem Referenzcode.
- Das Zustandsdiagramm wurde gegen den Code geprüft, mit den Standardwerten und mit jedem niedrigsten und höchsten Wert der Liste.
- Geprüft mit TLA+, Z3 und Lean, mit dem, was die Werkzeuge ausgaben
Baue „Erfolge“ in mein Spiel ein.
Das soll es bewirken: Erfolge geben dem Spieler zusätzliche Ziele neben dem Hauptziel und einen Grund, Dinge auszuprobieren, die die Geschichte nie verlangt. Das Hinweisfenster lässt einen kleinen Sieg bemerkt werden, und die Liste der Ziele zeigt, was noch aussteht.
Baue es genau nach diesem Automaten. Prüfe zuerst, ob er zu meinem Spiel passt, und bau ihn dann so:
```mermaid
stateDiagram-v2
[*] --> quiet
quiet: Ruhig
showing: Fenster zu sehen
backlog: Fenster warten
complete: Alles geschafft
quiet --> showing: ein Ziel wird frei
quiet --> backlog: mehrere zugleich frei
showing --> backlog: ein weiteres wird frei
showing --> quiet: Fenster endet
showing --> complete: letztes Fenster endet
backlog --> showing: Fenster endet, nächstes
complete --> [*]
```
Nimm diese Startwerte:
- toastTime: 3 s
- queueLimit: 5 items
Achte auf diese typischen Fehler:
- Es wird bei jeder Gelegenheit neu freigeschaltet: Sag deiner KI: Schalte nur Ziele frei, die noch nicht in der Liste der freigeschalteten stehen, und füge ein Ziel im selben Schritt zur Liste hinzu.
- Eine negative oder kaputte Zahl nimmt Fortschritt weg: Sag deiner KI: Zähler gehen nur nach oben. Ignoriere jede Zahl, die null, kleiner als null oder keine echte Zahl ist.
- Ein alter Spielstand überschwemmt den Bildschirm: Sag deiner KI: Prüfe beim Laden des Spiels einmal alle Ziele, zeige ein paar Hinweisfenster und bündle die übrigen in einem Fenster „und mehr“.
- Ein gestrichenes Fenster verliert die Freischaltung: Sag deiner KI: Die Liste der freigeschalteten Ziele ist die Wahrheit. Schreibe sie zuerst und behandle das Fenster als Zierde, die entfallen darf.
- Ein geheimes Ziel zeigt seinen Fortschritt: Sag deiner KI: Schicke für ein verstecktes Ziel, das noch gesperrt ist, keinen Zählerwert, kein Ziel und keinen Fortschritt an den Bildschirm.
- Ein Bestwert-Zähler wird aufsummiert: Sag deiner KI: Lege für jeden Zähler fest, ob er aufsummiert oder den besten Wert behält, und behalte bei Bestwert-Zählern den höheren.
- Ein Ziel mit dem Zielwert null oder weniger: Sag deiner KI: Ein Ziel mit dem Zielwert null oder weniger gilt als schon erreicht, und sein Fortschritt wird als voll angezeigt.
- Ein Sammelziel nennt ein Ziel, das es nicht gibt: Sag deiner KI: Prüfe beim Start des Spiels, dass jedes Ziel, das in einem Sammelziel genannt wird, existiert, und melde jedes, das fehlt.
Ändere nichts anderes im Spiel. Behaupte nichts, ohne es zu belegen: Modelliere, was dafür nötig ist, und zeig mir, worauf deine Lösung beruht und woran ich sehe, dass sie klappt. Wenn du etwas nicht zeigen kannst, sag, dass du es nicht weißt. Sag mir danach in einfachen Worten, wie ich es ausprobiere.
Der Code, von https://spielerando.com/de/mechanics/achievements (TypeScript, tested):
```ts
/* Achievements: goals that unlock once, when a counter the game keeps reaches a target, or when a
group of other achievements is done. Two things are kept apart on purpose. The list of unlocked
achievements is the truth and only ever grows. The pop-up that tells the player is decoration: it
shows one at a time, waits in a short line, and when too many pile up the rest are folded into one
"and more" pop-up. Dropping a pop-up never drops an unlock.
Counters only go up. A "total" counter adds what it is given, a "best" counter keeps the highest
value it has seen. Time comes in as a value (`dt`). */
export interface Params {
/** How long one pop-up stays on screen, s. */
toastTime: number;
/** How many pop-ups may wait behind the one on screen; more are folded into one summary. */
queueLimit: number;
}
export const DEFAULT_PARAMS: Params = { toastTime: 3, queueLimit: 5 };
/** A timer counts as run out below this: summing dt leaves rounding error. */
const TIMER_EPSILON = 1e-9;
/** The id of the summary pop-up. */
export const MORE = "more";
export type Condition = { kind: "stat"; stat: string; target: number } | { kind: "all"; of: string[] };
export interface Achievement {
id: string;
/** Shown as a mystery until it is unlocked. */
hidden?: boolean;
when: Condition;
}
export interface Defs {
/** Every counter and how it grows. */
stats: Record<string, "total" | "best">;
achievements: Achievement[];
}
export const EXAMPLE_DEFS: Defs = {
stats: { jumps: "total", coins: "total", "best-combo": "best" },
achievements: [
{ id: "first-jump", when: { kind: "stat", stat: "jumps", target: 1 } },
{ id: "jumper", when: { kind: "stat", stat: "jumps", target: 100 } },
{ id: "combo-5", hidden: true, when: { kind: "stat", stat: "best-combo", target: 5 } },
{ id: "rich", when: { kind: "stat", stat: "coins", target: 500 } },
{ id: "all-rounder", when: { kind: "all", of: ["first-jump", "jumper", "combo-5", "rich"] } },
],
};
export type Outcome = "ok" | "ignored";
export interface State {
defs: Defs;
stats: Record<string, number>;
/** Unlocked achievements, in the order they unlocked, each once. */
unlocked: string[];
/** The pop-up on screen, or null. */
toast: string | null;
/** Seconds the pop-up has left. */
left: number;
/** Pop-ups waiting behind it. */
queue: string[];
/** Unlocks that did not fit in the line and wait to be folded into one summary. */
more: number;
outcome: Outcome;
}
export type Action = { type: "record"; stat: string; value: number } | { type: "check" } | { type: "tick"; dt: number };
export function initialState(_params: Params = DEFAULT_PARAMS, defs: Defs = EXAMPLE_DEFS, stats: Record<string, number> = {}): State {
return { defs, stats: { ...stats }, unlocked: [], toast: null, left: 0, queue: [], more: 0, outcome: "ok" };
}
export const valueOf = (state: Pick<State, "stats">, stat: string) => state.stats[stat] ?? 0;
function met(a: Achievement, state: Pick<State, "stats" | "unlocked">): boolean {
if (a.when.kind === "stat") return valueOf(state, a.when.stat) >= a.when.target;
return a.when.of.every((id) => state.unlocked.includes(id));
}
/** Puts one unlock on screen, in the line, or in the summary. */
function announce(state: State, id: string, params: Params): State {
if (state.toast === null) return { ...state, toast: id, left: params.toastTime };
if (state.queue.length < Math.max(1, Math.floor(params.queueLimit))) return { ...state, queue: [...state.queue, id] };
return { ...state, more: state.more + 1 };
}
/** Unlocks everything whose condition holds, again and again, so a "collect them all" goal unlocks in
the same moment as the last goal it waits for. */
export function unlockWhatIsMet(state: State, params: Params): State {
let s = state;
for (let pass = 0; pass <= s.defs.achievements.length; pass++) {
const next = s.defs.achievements.find((a) => !s.unlocked.includes(a.id) && met(a, s));
if (!next) break;
s = announce({ ...s, unlocked: [...s.unlocked, next.id] }, next.id, params);
}
return s;
}
export interface Progress {
id: string;
/** False while a hidden goal is still locked: the screen shows a mystery. */
revealed: boolean;
unlocked: boolean;
have: number;
target: number;
/** From 0 to 1. */
fraction: number;
}
/** What the achievements screen shows for each goal. */
export function view(state: State): Progress[] {
return state.defs.achievements.map((a) => {
const unlocked = state.unlocked.includes(a.id);
const revealed = unlocked || !a.hidden;
const target = a.when.kind === "stat" ? a.when.target : a.when.of.length;
const have = a.when.kind === "stat" ? valueOf(state, a.when.stat) : a.when.of.filter((id) => state.unlocked.includes(id)).length;
const fraction = unlocked ? 1 : target <= 0 ? 1 : Math.min(1, Math.max(0, have / target));
return { id: a.id, revealed, unlocked, have: revealed ? Math.min(have, target) : 0, target: revealed ? target : 0, fraction: revealed ? fraction : 0 };
});
}
/** Which state of the diagram the pop-ups are in. */
export function phase(state: State): "quiet" | "showing" | "backlog" | "complete" {
if (state.toast === null) return state.unlocked.length === state.defs.achievements.length ? "complete" : "quiet";
return state.queue.length > 0 || (state.more > 0 && state.toast !== MORE) ? "backlog" : "showing";
}
export function reduce(state: State, action: Action, params: Params): State {
switch (action.type) {
case "record": {
const kind = state.defs.stats[action.stat];
// A counter never goes down and a broken number counts for nothing.
if (kind === undefined || !Number.isFinite(action.value) || (kind === "total" && action.value <= 0)) return { ...state, outcome: "ignored" };
const now = valueOf(state, action.stat);
const value = kind === "total" ? now + action.value : Math.max(now, action.value);
if (!Number.isFinite(value)) return { ...state, outcome: "ignored" };
return { ...unlockWhatIsMet({ ...state, stats: { ...state.stats, [action.stat]: value } }, params), outcome: value === now ? "ignored" : "ok" };
}
case "check":
return { ...unlockWhatIsMet(state, params), outcome: "ok" };
case "tick": {
if (state.toast === null) return { ...state, outcome: "ignored" };
const left = state.left - (Number.isFinite(action.dt) ? Math.max(0, action.dt) : 0);
if (left > TIMER_EPSILON) return { ...state, left, outcome: "ok" };
// The pop-up is done. Next in line comes up with a full time of its own. A summary that ends
// has told all it held, those folded in while it showed included, so its count goes.
const more = state.toast === MORE ? 0 : state.more;
if (state.queue.length > 0) return { ...state, toast: state.queue[0], queue: state.queue.slice(1), left: params.toastTime, more, outcome: "ok" };
if (more > 0) return { ...state, toast: MORE, left: params.toastTime, outcome: "ok" };
return { ...state, toast: null, left: 0, more: 0, outcome: "ok" };
}
}
}
```
Baue „Erfolge“ in mein Spiel ein.
Das soll es bewirken: Erfolge geben dem Spieler zusätzliche Ziele neben dem Hauptziel und einen Grund, Dinge auszuprobieren, die die Geschichte nie verlangt. Das Hinweisfenster lässt einen kleinen Sieg bemerkt werden, und die Liste der Ziele zeigt, was noch aussteht.
Baue es genau nach diesem Automaten. Prüfe zuerst, ob er zu meinem Spiel passt, und bau ihn dann so:
```mermaid
stateDiagram-v2
[*] --> quiet
quiet: Ruhig
showing: Fenster zu sehen
backlog: Fenster warten
complete: Alles geschafft
quiet --> showing: ein Ziel wird frei
quiet --> backlog: mehrere zugleich frei
showing --> backlog: ein weiteres wird frei
showing --> quiet: Fenster endet
showing --> complete: letztes Fenster endet
backlog --> showing: Fenster endet, nächstes
complete --> [*]
```
Nimm diese Startwerte:
- toastTime: 3 s
- queueLimit: 5 items
Achte auf diese typischen Fehler:
- Es wird bei jeder Gelegenheit neu freigeschaltet: Sag deiner KI: Schalte nur Ziele frei, die noch nicht in der Liste der freigeschalteten stehen, und füge ein Ziel im selben Schritt zur Liste hinzu.
- Eine negative oder kaputte Zahl nimmt Fortschritt weg: Sag deiner KI: Zähler gehen nur nach oben. Ignoriere jede Zahl, die null, kleiner als null oder keine echte Zahl ist.
- Ein alter Spielstand überschwemmt den Bildschirm: Sag deiner KI: Prüfe beim Laden des Spiels einmal alle Ziele, zeige ein paar Hinweisfenster und bündle die übrigen in einem Fenster „und mehr“.
- Ein gestrichenes Fenster verliert die Freischaltung: Sag deiner KI: Die Liste der freigeschalteten Ziele ist die Wahrheit. Schreibe sie zuerst und behandle das Fenster als Zierde, die entfallen darf.
- Ein geheimes Ziel zeigt seinen Fortschritt: Sag deiner KI: Schicke für ein verstecktes Ziel, das noch gesperrt ist, keinen Zählerwert, kein Ziel und keinen Fortschritt an den Bildschirm.
- Ein Bestwert-Zähler wird aufsummiert: Sag deiner KI: Lege für jeden Zähler fest, ob er aufsummiert oder den besten Wert behält, und behalte bei Bestwert-Zählern den höheren.
- Ein Ziel mit dem Zielwert null oder weniger: Sag deiner KI: Ein Ziel mit dem Zielwert null oder weniger gilt als schon erreicht, und sein Fortschritt wird als voll angezeigt.
- Ein Sammelziel nennt ein Ziel, das es nicht gibt: Sag deiner KI: Prüfe beim Start des Spiels, dass jedes Ziel, das in einem Sammelziel genannt wird, existiert, und melde jedes, das fehlt.
Ändere nichts anderes im Spiel. Behaupte nichts, ohne es zu belegen: Modelliere, was dafür nötig ist, und zeig mir, worauf deine Lösung beruht und woran ich sehe, dass sie klappt. Wenn du etwas nicht zeigen kannst, sag, dass du es nicht weißt. Sag mir danach in einfachen Worten, wie ich es ausprobiere.Der getestete Code (TypeScript)
/* Achievements: goals that unlock once, when a counter the game keeps reaches a target, or when a
group of other achievements is done. Two things are kept apart on purpose. The list of unlocked
achievements is the truth and only ever grows. The pop-up that tells the player is decoration: it
shows one at a time, waits in a short line, and when too many pile up the rest are folded into one
"and more" pop-up. Dropping a pop-up never drops an unlock.
Counters only go up. A "total" counter adds what it is given, a "best" counter keeps the highest
value it has seen. Time comes in as a value (`dt`). */
export interface Params {
/** How long one pop-up stays on screen, s. */
toastTime: number;
/** How many pop-ups may wait behind the one on screen; more are folded into one summary. */
queueLimit: number;
}
export const DEFAULT_PARAMS: Params = { toastTime: 3, queueLimit: 5 };
/** A timer counts as run out below this: summing dt leaves rounding error. */
const TIMER_EPSILON = 1e-9;
/** The id of the summary pop-up. */
export const MORE = "more";
export type Condition = { kind: "stat"; stat: string; target: number } | { kind: "all"; of: string[] };
export interface Achievement {
id: string;
/** Shown as a mystery until it is unlocked. */
hidden?: boolean;
when: Condition;
}
export interface Defs {
/** Every counter and how it grows. */
stats: Record<string, "total" | "best">;
achievements: Achievement[];
}
export const EXAMPLE_DEFS: Defs = {
stats: { jumps: "total", coins: "total", "best-combo": "best" },
achievements: [
{ id: "first-jump", when: { kind: "stat", stat: "jumps", target: 1 } },
{ id: "jumper", when: { kind: "stat", stat: "jumps", target: 100 } },
{ id: "combo-5", hidden: true, when: { kind: "stat", stat: "best-combo", target: 5 } },
{ id: "rich", when: { kind: "stat", stat: "coins", target: 500 } },
{ id: "all-rounder", when: { kind: "all", of: ["first-jump", "jumper", "combo-5", "rich"] } },
],
};
export type Outcome = "ok" | "ignored";
export interface State {
defs: Defs;
stats: Record<string, number>;
/** Unlocked achievements, in the order they unlocked, each once. */
unlocked: string[];
/** The pop-up on screen, or null. */
toast: string | null;
/** Seconds the pop-up has left. */
left: number;
/** Pop-ups waiting behind it. */
queue: string[];
/** Unlocks that did not fit in the line and wait to be folded into one summary. */
more: number;
outcome: Outcome;
}
export type Action = { type: "record"; stat: string; value: number } | { type: "check" } | { type: "tick"; dt: number };
export function initialState(_params: Params = DEFAULT_PARAMS, defs: Defs = EXAMPLE_DEFS, stats: Record<string, number> = {}): State {
return { defs, stats: { ...stats }, unlocked: [], toast: null, left: 0, queue: [], more: 0, outcome: "ok" };
}
export const valueOf = (state: Pick<State, "stats">, stat: string) => state.stats[stat] ?? 0;
function met(a: Achievement, state: Pick<State, "stats" | "unlocked">): boolean {
if (a.when.kind === "stat") return valueOf(state, a.when.stat) >= a.when.target;
return a.when.of.every((id) => state.unlocked.includes(id));
}
/** Puts one unlock on screen, in the line, or in the summary. */
function announce(state: State, id: string, params: Params): State {
if (state.toast === null) return { ...state, toast: id, left: params.toastTime };
if (state.queue.length < Math.max(1, Math.floor(params.queueLimit))) return { ...state, queue: [...state.queue, id] };
return { ...state, more: state.more + 1 };
}
/** Unlocks everything whose condition holds, again and again, so a "collect them all" goal unlocks in
the same moment as the last goal it waits for. */
export function unlockWhatIsMet(state: State, params: Params): State {
let s = state;
for (let pass = 0; pass <= s.defs.achievements.length; pass++) {
const next = s.defs.achievements.find((a) => !s.unlocked.includes(a.id) && met(a, s));
if (!next) break;
s = announce({ ...s, unlocked: [...s.unlocked, next.id] }, next.id, params);
}
return s;
}
export interface Progress {
id: string;
/** False while a hidden goal is still locked: the screen shows a mystery. */
revealed: boolean;
unlocked: boolean;
have: number;
target: number;
/** From 0 to 1. */
fraction: number;
}
/** What the achievements screen shows for each goal. */
export function view(state: State): Progress[] {
return state.defs.achievements.map((a) => {
const unlocked = state.unlocked.includes(a.id);
const revealed = unlocked || !a.hidden;
const target = a.when.kind === "stat" ? a.when.target : a.when.of.length;
const have = a.when.kind === "stat" ? valueOf(state, a.when.stat) : a.when.of.filter((id) => state.unlocked.includes(id)).length;
const fraction = unlocked ? 1 : target <= 0 ? 1 : Math.min(1, Math.max(0, have / target));
return { id: a.id, revealed, unlocked, have: revealed ? Math.min(have, target) : 0, target: revealed ? target : 0, fraction: revealed ? fraction : 0 };
});
}
/** Which state of the diagram the pop-ups are in. */
export function phase(state: State): "quiet" | "showing" | "backlog" | "complete" {
if (state.toast === null) return state.unlocked.length === state.defs.achievements.length ? "complete" : "quiet";
return state.queue.length > 0 || (state.more > 0 && state.toast !== MORE) ? "backlog" : "showing";
}
export function reduce(state: State, action: Action, params: Params): State {
switch (action.type) {
case "record": {
const kind = state.defs.stats[action.stat];
// A counter never goes down and a broken number counts for nothing.
if (kind === undefined || !Number.isFinite(action.value) || (kind === "total" && action.value <= 0)) return { ...state, outcome: "ignored" };
const now = valueOf(state, action.stat);
const value = kind === "total" ? now + action.value : Math.max(now, action.value);
if (!Number.isFinite(value)) return { ...state, outcome: "ignored" };
return { ...unlockWhatIsMet({ ...state, stats: { ...state.stats, [action.stat]: value } }, params), outcome: value === now ? "ignored" : "ok" };
}
case "check":
return { ...unlockWhatIsMet(state, params), outcome: "ok" };
case "tick": {
if (state.toast === null) return { ...state, outcome: "ignored" };
const left = state.left - (Number.isFinite(action.dt) ? Math.max(0, action.dt) : 0);
if (left > TIMER_EPSILON) return { ...state, left, outcome: "ok" };
// The pop-up is done. Next in line comes up with a full time of its own. A summary that ends
// has told all it held, those folded in while it showed included, so its count goes.
const more = state.toast === MORE ? 0 : state.more;
if (state.queue.length > 0) return { ...state, toast: state.queue[0], queue: state.queue.slice(1), left: params.toastTime, more, outcome: "ok" };
if (more > 0) return { ...state, toast: MORE, left: params.toastTime, outcome: "ok" };
return { ...state, toast: null, left: 0, more: 0, outcome: "ok" };
}
}
}
Die Tests, die der Referenzcode besteht
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import test from "node:test";
import { forAll, pick, real, seeded, type Rng } from "../../../proofs/property.ts";
import { type Action, DEFAULT_PARAMS, type Defs, EXAMPLE_DEFS, MORE, type Params, type State, initialState, phase, reduce, unlockWhatIsMet, valueOf, view } from "./reference.ts";
const P = DEFAULT_PARAMS;
const record = (stat: string, value: number): Action => ({ type: "record", stat, value });
const check: Action = { type: "check" };
const tick = (dt: number): Action => ({ type: "tick", dt });
const run = (s: State, ...actions: Action[]) => actions.reduce((acc, a) => reduce(acc, a, P), s);
const near = (a: number, b: number) => assert.ok(Math.abs(a - b) < 1e-9, `${a} is not ${b}`);
test("first-unlock-happens-once", () => {
let s = run(initialState(P), record("jumps", 1));
assert.deepEqual(s.unlocked, ["first-jump"]);
assert.equal(s.toast, "first-jump");
assert.equal(s.left, 3);
s = run(s, record("jumps", 1), record("jumps", 1));
assert.deepEqual(s.unlocked, ["first-jump"]);
assert.deepEqual(s.queue, []);
});
test("reaching-the-target-unlocks", () => {
let s = run(initialState(P), record("jumps", 99));
assert.deepEqual(s.unlocked, ["first-jump"]);
s = run(s, record("jumps", 1));
assert.deepEqual(s.unlocked, ["first-jump", "jumper"]);
assert.equal(valueOf(s, "jumps"), 100);
});
test("total-adds-and-best-keeps-the-highest", () => {
let s = run(initialState(P), record("coins", 30), record("coins", 20));
assert.equal(valueOf(s, "coins"), 50);
s = run(s, record("best-combo", 4), record("best-combo", 3));
assert.equal(valueOf(s, "best-combo"), 4);
s = run(s, record("best-combo", 6));
assert.equal(valueOf(s, "best-combo"), 6);
});
test("stats-never-go-down-and-bad-numbers-count-for-nothing", () => {
const base = run(initialState(P), record("coins", 40), record("best-combo", 4));
for (const bad of [-5, 0, Number.NaN, Number.POSITIVE_INFINITY]) {
const s = reduce(base, record("coins", bad), P);
assert.equal(valueOf(s, "coins"), 40);
assert.equal(s.outcome, "ignored");
}
assert.equal(reduce(base, record("best-combo", 2), P).outcome, "ignored");
assert.equal(valueOf(reduce(base, record("best-combo", Number.NaN), P), "best-combo"), 4);
});
test("several-unlock-at-once-show-one-after-another", () => {
const s = run(initialState(P), record("jumps", 100));
assert.deepEqual(s.unlocked, ["first-jump", "jumper"]);
assert.equal(s.toast, "first-jump");
assert.deepEqual(s.queue, ["jumper"]);
assert.equal(phase(s), "backlog");
});
test("toast-ends-after-its-time", () => {
let s = run(initialState(P), record("jumps", 100), tick(2.9));
assert.equal(s.toast, "first-jump");
near(s.left, 0.1);
s = run(s, tick(0.1));
assert.equal(s.toast, "jumper");
assert.equal(s.left, 3);
assert.deepEqual(s.queue, []);
s = run(s, tick(3));
assert.equal(s.toast, null);
assert.equal(phase(s), "quiet");
});
test("too-many-toasts-become-a-summary", () => {
const one = { ...P, queueLimit: 1 };
let s = reduce(initialState(one, EXAMPLE_DEFS, { jumps: 100, coins: 500, "best-combo": 5 }), check, one);
assert.equal(s.unlocked.length, 5);
assert.equal(s.toast, "first-jump");
assert.deepEqual(s.queue, ["jumper"]);
assert.equal(s.more, 3);
s = reduce(s, tick(3), one);
assert.equal(s.toast, "jumper");
s = reduce(s, tick(3), one);
assert.equal(s.toast, MORE);
assert.equal(s.more, 3);
assert.equal(phase(s), "showing");
s = reduce(s, tick(3), one);
assert.equal(s.toast, null);
assert.equal(s.more, 0);
assert.equal(phase(s), "complete");
});
test("collect-them-all-unlocks-in-the-same-moment", () => {
let s = run(initialState(P), record("jumps", 100), record("best-combo", 5));
assert.ok(!s.unlocked.includes("all-rounder"));
s = run(s, record("coins", 500));
assert.deepEqual(s.unlocked.slice(-2), ["rich", "all-rounder"]);
});
test("hidden-stays-hidden-until-unlocked", () => {
const before = view(initialState(P)).find((p) => p.id === "combo-5")!;
assert.deepEqual([before.revealed, before.target, before.have, before.fraction], [false, 0, 0, 0]);
const progressed = view(run(initialState(P), record("best-combo", 3))).find((p) => p.id === "combo-5")!;
assert.equal(progressed.revealed, false);
const after = view(run(initialState(P), record("best-combo", 5))).find((p) => p.id === "combo-5")!;
assert.deepEqual([after.revealed, after.unlocked, after.have, after.target], [true, true, 5, 5]);
});
test("progress-is-capped-at-the-goal", () => {
const jumper = (s: State) => view(s).find((p) => p.id === "jumper")!;
const part = jumper(run(initialState(P), record("jumps", 25)));
assert.deepEqual([part.have, part.target, part.fraction], [25, 100, 0.25]);
const over = jumper(run(initialState(P), record("jumps", 250)));
assert.deepEqual([over.have, over.fraction], [100, 1]);
});
test("check-unlocks-what-is-already-met", () => {
const s = reduce(initialState(P, EXAMPLE_DEFS, { coins: 500 }), check, P);
assert.deepEqual(s.unlocked, ["rich"]);
assert.equal(s.toast, "rich");
});
test("unknown-stat-is-ignored", () => {
const s = reduce(initialState(P), record("swims", 3), P);
assert.equal(s.outcome, "ignored");
assert.deepEqual(s.stats, {});
});
test("edge-it-unlocks-every-time-the-goal-is-true", () => {
let s = initialState(P);
for (let n = 0; n < 30; n++) s = run(s, record("jumps", 1), tick(5));
assert.equal(s.unlocked.filter((id) => id === "first-jump").length, 1);
assert.equal(s.unlocked.length, 1);
});
test("edge-a-negative-or-broken-count-takes-progress-away", () => {
const s = run(initialState(P), record("jumps", 10), record("jumps", -4), record("jumps", Number.NaN));
assert.equal(valueOf(s, "jumps"), 10);
});
test("edge-an-old-save-floods-the-screen", () => {
const s = reduce(initialState(P, EXAMPLE_DEFS, { jumps: 1000, coins: 1000, "best-combo": 9 }), check, P);
assert.equal(s.unlocked.length, 5);
assert.ok(s.queue.length <= P.queueLimit);
});
test("edge-a-dropped-pop-up-loses-the-unlock", () => {
const one = { ...P, queueLimit: 1 };
const s = reduce(initialState(one, EXAMPLE_DEFS, { jumps: 100, coins: 500, "best-combo": 5 }), check, one);
assert.equal(s.queue.length + 1 + s.more, s.unlocked.length);
assert.ok(s.unlocked.includes("all-rounder"));
});
test("a-summary-tells-each-unlock-once", () => {
// Found by the TLA+ check: a summary that ended while the line still had a pop-up kept its count,
// so the next summary told the same unlocks again.
const one = { ...P, queueLimit: 1 };
const defs: Defs = { stats: { n: "total" }, achievements: [1, 2, 3, 4, 5, 6].map((t) => ({ id: `g${t}`, when: { kind: "stat" as const, stat: "n", target: t } })) };
let s = reduce(initialState(one, defs), record("n", 4), one);
s = reduce(reduce(s, tick(3), one), tick(3), one);
assert.equal(s.toast, MORE);
assert.equal(s.more, 2);
s = reduce(s, record("n", 2), one);
assert.deepEqual([s.queue, s.more], [["g5"], 3]);
s = reduce(s, tick(3), one);
assert.equal(s.toast, "g5");
assert.equal(s.more, 0);
s = reduce(s, tick(3), one);
assert.equal(s.toast, null);
assert.equal(phase(s), "complete");
});
test("edge-a-secret-goal-shows-its-progress", () => {
const secret = view(run(initialState(P), record("best-combo", 4))).find((p) => p.id === "combo-5")!;
assert.equal(secret.have, 0);
assert.equal(secret.target, 0);
});
test("edge-a-best-counter-is-added-up", () => {
const s = run(initialState(P), record("best-combo", 3), record("best-combo", 3));
assert.equal(valueOf(s, "best-combo"), 3);
assert.ok(!s.unlocked.includes("combo-5"));
});
test("edge-a-goal-with-a-target-of-zero-or-less", () => {
const defs = { stats: { steps: "total" as const }, achievements: [{ id: "welcome", when: { kind: "stat" as const, stat: "steps", target: 0 } }] };
const s = unlockWhatIsMet(initialState(P, defs), P);
assert.deepEqual(s.unlocked, ["welcome"]);
assert.equal(view(s)[0].fraction, 1);
});
test("edge-a-collect-them-all-goal-that-names-a-missing-goal", () => {
const defs = { stats: {}, achievements: [{ id: "all", when: { kind: "all" as const, of: ["nothing-here"] } }] };
const s = unlockWhatIsMet(initialState(P, defs), P);
assert.deepEqual(s.unlocked, []);
});
const LISTED: { name: keyof Params; min: number; max: number }[] = JSON.parse(readFileSync(new URL("./mechanic.json", import.meta.url), "utf8")).spec.parameters;
function anyParams(r: Rng): Params {
const values = LISTED.map(({ name, min, max }) => [name, pick(r, [min, max, real(r, min, max), Math.round(real(r, min, max))])]);
return Object.fromEntries(values);
}
function anyAction(r: Rng): Action {
const stat = pick(r, ["jumps", "coins", "best-combo", "unknown"]);
const value = pick(r, [1, 3, 25, 120, 600, real(r, -5, 400), Number.NaN]);
return pick<Action>(r, [record(stat, value), record(stat, value), record(stat, value), check, tick(pick(r, [0.5, 3, 4, real(r, 0, 5), -1, Number.NaN])), tick(3), tick(3)]);
}
test("property: an unlock happens once and only when its goal holds", (t) => {
forAll(t, 141, 400, (r) => {
const params = anyParams(r);
let s = initialState(params);
for (let n = 0; n < 200; n++) {
s = reduce(s, anyAction(r), params);
assert.equal(new Set(s.unlocked).size, s.unlocked.length);
for (const id of s.unlocked) {
const a = s.defs.achievements.find((x) => x.id === id)!;
if (a.when.kind === "stat") assert.ok(valueOf(s, a.when.stat) >= a.when.target);
else for (const need of a.when.of) assert.ok(s.unlocked.indexOf(need) < s.unlocked.indexOf(id));
}
}
});
});
test("property: counters never go down and unlocks never go away", (t) => {
forAll(t, 142, 400, (r) => {
const params = anyParams(r);
let s = initialState(params);
for (let n = 0; n < 200; n++) {
const before = s;
s = reduce(s, anyAction(r), params);
for (const stat of Object.keys(before.stats)) assert.ok(valueOf(s, stat) >= valueOf(before, stat) && Number.isFinite(valueOf(s, stat)));
assert.deepEqual(s.unlocked.slice(0, before.unlocked.length), before.unlocked);
}
});
});
test("property: the line of pop-ups stays short and every unlock is accounted for", (t) => {
forAll(t, 143, 400, (r) => {
const params = anyParams(r);
let s = initialState(params);
let shown = 0;
let folded = 0;
for (let n = 0; n < 250; n++) {
const before = s;
s = reduce(s, anyAction(r), params);
assert.ok(s.queue.length <= Math.max(1, params.queueLimit));
assert.ok(s.left >= 0 && (s.toast !== null || s.left === 0));
if (s.toast !== null && s.toast !== before.toast && s.toast !== MORE) shown++;
if (s.more > before.more) folded += s.more - before.more;
if (s.toast === null) assert.deepEqual(s.queue, []);
// Every unlock was shown, waits in the line, or was folded into the summary. None is lost.
assert.equal(s.unlocked.length, shown + s.queue.length + folded);
}
});
});
/* The diagram in mechanic.json. Staying in the same state is not a move, so only changes count. */
const MODEL: { states: { id: string; start?: boolean }[]; moves: { from: string; to: string }[] } = JSON.parse(readFileSync(new URL("./mechanic.json", import.meta.url), "utf8")).model;
function observe(params: Params, seed: number): { changes: Set<string>; seen: Set<string> } {
const r = seeded(seed);
const changes = new Set<string>();
const seen = new Set<string>();
for (let episode = 0; episode < 120; episode++) {
// Some games start from a save that already meets many goals.
const stats: Record<string, number> = episode % 4 === 0 ? { jumps: 100, coins: 500, "best-combo": 5 } : episode % 4 === 1 ? { jumps: 1000 } : {};
let s = initialState(params, EXAMPLE_DEFS, stats);
if (episode % 4 < 2 && r() < 0.5) s = reduce(s, check, params);
seen.add(phase(s));
for (let n = 0; n < 60; n++) {
const before = phase(s);
s = reduce(s, anyAction(r), params);
const after = phase(s);
seen.add(after);
if (after !== before) changes.add(`${before}>${after}`);
}
}
return { changes, seen };
}
test("model-matches-code", () => {
assert.equal(phase(initialState()), MODEL.states.find((s) => s.start)?.id);
const listed = new Set(MODEL.moves.map((m) => `${m.from}>${m.to}`));
const ids = new Set(MODEL.states.map((s) => s.id));
const cases: Params[] = [P];
for (const { name, min, max } of LISTED) for (const value of [min, max]) cases.push({ ...P, [name]: value });
const allChanges = new Set<string>();
const allSeen = new Set<string>();
cases.forEach((params, i) => {
const { changes, seen } = observe(params, 700 + i);
for (const move of changes) assert.ok(listed.has(move), `the code does a move the diagram does not list: ${move} (case ${i})`);
for (const id of seen) assert.ok(ids.has(id), `the code reaches a state the diagram does not list: ${id}`);
changes.forEach((c) => allChanges.add(c));
seen.forEach((c) => allSeen.add(c));
});
for (const id of ids) assert.ok(allSeen.has(id), `the diagram lists a state the code never reaches: ${id}`);
for (const move of listed) assert.ok(allChanges.has(move), `the diagram lists a move the code never makes: ${move}`);
});
War diese Seite hilfreich?
Nächster Schritt
Quellen
- Kyle Hilliard, Activision Badges: The Original Gaming Achievement, Game Informer, 26. Oktober 2013
- Kevin Bunch, Dragster: August 1980, Atari Archive, 8. Oktober 2025
- Anleitung zu Dragster, Activision, 1980 (Textfassung, textfiles.com)
- Wikipedia, Achievement (video games)
- Ben Medler, Generations of Game Analytics, Achievements and High Scores, Eludamos 3(2), 2009
- Microsoft, Xbox 360 Ushers in the Future of Games and Entertainment, 12. Mai 2005
- Microsoft, Robbie Bach, J Allard und Peter Moore auf der E3 2005 (Mitschrift), 16. Mai 2005
- Mary Jane Irwin, Unlocking Achievements: Rewarding Skill With Player Incentives, Game Developer, 1. April 2009
- Eric Lempel, Firmware v2.40 Walkthrough Part 2: Trophies, PlayStation Blog, 30. Juni 2008
- Andrew Yoon, Everything you need to know about firmware 2.40, Engadget, 30. Juni 2008
- Steam-Neuigkeiten, 7. Mai 2009
- Major Nelson, Xbox One Achievements, Xbox Wire, 12. Juni 2013
- Xbox Wire, Xbox holiday update, 10. November 2016
- Juho Hamari und Veikko Eranti, Framework for Designing and Evaluating Game Achievements, DiGRA 2011