# Nonlinear gameplay

A video game with nonlinear gameplay presents players with challenges that can be completed in a number of different sequences. Each player may take on (or even encounter) only some of the challenges possible, and the same challenges may be played in a different order. Conversely, a video game with linear gameplay will confront a player with a fixed sequence of challenges: every player faces every challenge and has to overcome them in the same order.
A nonlinear game will allow greater player freedom than a linear game. For example, a nonlinear game may permit multiple sequences to finish the game, a choice between paths to victory, different types of victory, or optional side-quests and subplots. Some games feature both linear and nonlinear elements, and some games offer a sandbox mode that allows players to explore an open world game environment independently from the game's main objectives, if any objectives are provided at all.
A game that is significantly nonlinear is sometimes described as being open-ended or a sandbox, and is characterized by allowing players to measure progress through self-determined goals, independent of scripted game elements.

## Level design

A game level or world can be linear, nonlinear or both. In a linear game, there is only one path the player can take through a level, but in games with nonlinear gameplay, players might have to revisit locations or choose from multiple paths to finish the level.
As with other game elements, linear level design is not absolute. While a nonlinear level can give the freedom to explore or backtrack, there can be a sequence of challenges that a player must solve to complete the level. If a player must confront the challenges in a fixed order nonlinear games will often give multiple approaches to achieve said objectives.
A more linear game requires a player to finish levels in a fixed sequence to win. The ability to skip, repeat, or choose between levels makes this type of game less linear. Super Mario Bros. is an early example of this, where the player had access to warp zones that skipped many levels of the game.
In some games, levels can change between linear design and free roaming depending on the objective of the stage. Super Mario 64 is an example where the main stages are free roam, while the levels where Bowser is encountered follow a straight path to the end.

### Open worlds and sandbox modes

When a game is sufficiently large and open-ended, it may be described as an open world or as a sandbox game. Open-world game designs have existed in some form since the 1980s, such as the space trading game Elite, and often make use of procedurally generated environments.
In a game with a sandbox mode, a player may turn off or ignore game objectives, or have unlimited access to items. This can open up possibilities that were not intended by the game designer. A sandbox mode is an option in otherwise goal-oriented games and is distinguished from open-ended games that have no objectives, such as SimCity, and Garry's Mod.

## Branching storylines

Games that employ linear stories are those where the player cannot change the story line or ending of the story. Many video games use a linear structure, thus making them more similar to other fiction. However, it is common for such games to use interactive narration in which a player needs to interact with something before the plot will advance, or nonlinear narratives in which events are portrayed in a non-chronological order. Many games have offered premature endings should the player fail to meet an objective, but these are usually just interruptions in a player's progress rather than actual endings. Even in games with a linear story, players interact with the game world by performing a variety of actions along the way.
More recently, some games have begun offering multiple endings to increase the dramatic effect of moral choices within the game, although early examples also exist. Still, some games have gone beyond small choices or special endings, offering a branching storyline (also known as an interactive narrative outside of a video game context), that players may control at critical points in the game. Sometimes the player is given a choice of which branch of the plot to follow, while sometimes the path will be based on the player's success or failure at a specific challenge. For example, Black Isle Studios' Fallout series of role-playing video games features numerous quests where player actions dictate the outcome of the story behind the objectives. Players can eliminate in-game characters permanently from the virtual world should they choose to do so, and by doing so may actually alter the number and type of quests that become available to them as the game progresses. The effects of such decisions may not be immediate. Branches of the story may merge or split at different points in the game, but seldom allow backtracking. Some games even allow for different starting points, and one way this is done is through a character selection screen.
Linear stories cost less time and money to develop, since there is only one fixed sequence of events and no major decisions to keep track of. For example, several games from the Wing Commander series offered a branching storyline, but eventually they were abandoned as too expensive. Nonlinear stories increase the chances for bugs or absurdities if they are not tested properly, although they do provide greater player freedom. Some players have also responded negatively to branching stories because it is hard and tedious for them to experience the "full value" of all the game's content. As a compromise between linear and branching stories, there are also games where stories split into branches and then fold back into a single storyline. In these stories, the plot will branch, but then converge upon some inevitable event, giving the impression of a nonlinear gameplay through the use of nonlinear narrative, without the use of interactive narratives. This is typically used in many graphic adventure games.
A truly nonlinear story would be written entirely by the actions of the player, and thus remains a difficult design challenge. As such, there is often little or no story in video games with a truly nonlinear gameplay. Facade, a video game often categorized as an interactive drama, features many branching paths that are dictated by the user's text input based on the current situation, but there is still a set number of outcomes as a result of the inherent limitations of programming, and as such, is non-linear, but not entirely so.

### Visual novels

Branching storylines are a common trend in visual novels, a subgenre of interactive narrative and adventure games. Visual novels frequently use multiple branching storylines to achieve multiple different endings, allowing non-linear freedom of choice along the way. Decision points within a visual novel often present players with the option of altering the course of events during the game, leading to many different possible outcomes. Visual novels are popular in East Asia, especially in Japan where they account for nearly 70% of personal computer games released there. A recent acclaimed example is 999: Nine Hours, Nine Persons, Nine Doors, where nearly every action and dialogue choice can lead to entirely new branching paths and endings. Each path only reveals certain aspects of the overall storyline and it is only after uncovering all the possible different paths and outcomes through multiple playthroughs that everything comes together to form a coherent well-written story.
It is not uncommon for visual novels to have morality systems. A well-known example is the 2005 title School Days, an animated visual novel that Kotaku describes as going well beyond the usual "black and white choice systems" (referring to video games such as Mass Effect, Fallout 3 and BioShock) where the players "pick a side and stick with it" while leaving "the expansive middle area between unexplored". School Days instead encourages players to explore the grey, neutral middle-ground in order to view more interesting, "bad" endings.
It is also not uncommon for visual novels to have multiple protagonists giving different perspectives on the story. C's Ware's EVE Burst Error (1995) introduced a unique twist to the system by allowing the player to switch between both protagonists at any time during the game, instead of finishing one protagonist's scenario before playing the other. EVE Burst Error often requires the player to have both protagonists co-operate with each other at various points during the game, with choices in one scenario affecting the other. Fate/stay night is another example that features multiple perspectives. Chunsoft sound novels such as Machi (1998) and 428: Shibuya Scramble (2008) develop this concept further, by allowing the player to alternate between the perspectives of several or more different characters, making choices with one character that have consequences for other characters. 428 in particular features up to 85 different possible endings.
Another approach to non-linear storytelling can be seen in Cosmology of Kyoto. The game lacks an overall plot, but it instead presents fragmented narratives and situations in a non-linear manner, as the player character encounters various non-player characters while wandering the city. These narratives are cross-referenced to an encyclopedia, providing background information as the narratives progress and as the player comes across various characters and locations, with various stories, situations and related information appearing at distinct locations. It provides enough freedom to allow for the player to experiment with the game, such as using it as a resource for their own role-playing game campaign, for example.

### Role-playing games

Branching storylines are also often used in role-playing video games (RPGs) to an extent. An early example, published in 1999, is the fantasy role-playing game Might and Magic VII: For Blood and Honor, where players have to choose between Light and Dark. While the dark side wants to destroy the world of Enroth, the light side tries to save it. The choice determines which grandmaster levels the player characters can obtain and the quests they have to do in that part of the game. Earlier in the game, the player already has to choose sides in a border conflict between Elves and Humans, or remain neutral. This affects the flag in their Castle Harmondale and a few quests, but not the outcome.
A second example is Obsidian Entertainment's Fallout: New Vegas, where the player's decisions influence whether one of three different factions gain control of the area surrounding post-apocalyptic Las Vegas. These factions include Caesar's Legion, a group of Roman-esque slavers; the New California Republic (NCR), an expansionist military government; and Mr. House, the enigmatic de facto ruler of New Vegas, in command of an army of robots that patrols the city. Each of the three sides aim to control Hoover Dam, which is still operational and supplying the American Southwest with power and clean, non-irradiated water; thus, control of the dam means effective control of the region. A fourth option, siding with a robot named Yes Man and prevailing upon or eliminating the other faction leaders, enables the player to go solo and take over the Hoover Dam for themselves.
Another RPG example is tri-Ace's Star Ocean series, where the storyline is not affected by moral alignments like in other role-playing games, but inspired by dating sims, by friendship and relationship points between each of the characters. Star Ocean: The Second Story in particular offers as many as 86 different endings with hundreds of permutations, setting a benchmark for the number of possible outcomes of a video game. Another unique variation of this system is the Sakura Wars series, which features a real-time branching choice system where, during an event or conversation, the player must choose an action or dialogue choice within a time limit, or not to respond at all within that time; the player's choice, or lack thereof, affects the player character's relationship with other characters and in turn the direction and outcome of the storyline. Later games in the series added several variations, including an action gauge that can be raised up or down depending on the situation, and a gauge that the player can manipulate using the analog stick depending on the situation. A similar type of conversation system later appeared in a more recent action role-playing game also published by Sega, Alpha Protocol.
Another unique take on the concept is combining non-linear branching storytelling with the concepts of time travel and parallel universes. Early attempts at such an approach included Squaresoft's Chrono role-playing game series (1995–1999) and ELF's visual novel YU-NO: A girl who chants love at the bound of this world (1996). Radiant Historia takes it further by giving players the freedom to travel backwards and forwards through a timeline to alter the course of history, with each of their choices and actions significantly affect the timeline. The player can return to certain points in history and live through certain events again to make different choices and see different possible outcomes on the timeline. The player can also travel back and forth between two parallel timelines, and can obtain many possible parallel endings. The PSP version of Tactics Ogre featured a "World" system that allows players to revisit key plot points and make different choices to see how the story unfolds differently. Final Fantasy XIII-2 also features a similar non-linear time travel system to Radiant Historia.

## Early examples

Early examples (pre-1983) of nonlinear gameplay include:
* Colossal Cave Adventure (1976)
* Zork (1977/1980)
* MUD1 (1978)
* Akalabeth (1979)
* Star Raiders (1979)
* Superman (1979)
* Temple of Apshai (1979)
* Computer Bismarck (1980)
* Flight Simulator (1979/1980)
* Mystery House (1980)
* The Prisoner (1980)
* Rogue (1980)
* Adventure (1980)
* 005 (1981)
* Bosconian (1981)
* Castle Wolfenstein (1981)
* Crush, Crumble and Chomp! (1981)
* Ultima (1981)
* Star Warrior (1981)
* Venture (1981)
* E.T. the Extra-Terrestrial (1982)
* Haunted House (1982)
* The Hobbit (1982)
* Pitfall! (1982)
* Raiders of the Lost Ark (1982)
* Snipes (1982)
* Time Pilot (1982)
* Ultima II (1982)