> For the complete documentation index, see [llms.txt](https://docs.empirica.ly/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.empirica.ly/tutorials/beginner-experiment-prisoners-dilemma/part-4-coding-the-prisoners-dilemma-game/part-4.1-removing-example-code.md).

# Part 4.1: Removing example code

When you create an experiment with the `empirica create` command, Empirica populates a template experiment with the jelly bean and minesweeper code that you saw in the previous step.  We won't use this example code in our experiment, so let's clean it out. There are a few steps:

* delete the entire `client/src/examples` folder
* In `client/src/Stage.jsx`:
  * remove the imports for `JellyBeans` and `MineSweeper` (2 lines)
  * replace the `switch` statement and its three cases (8 lines, including brackets) with the code \`

    ```
    return (<p>Not yet implemented...</p>)
    ```

The file should look like this when you are done:

{% code title="Stage.jsx" lineNumbers="true" %}

```jsx
import {
  usePlayer,
  usePlayers,
  useRound,
} from "@empirica/core/player/classic/react";
import { Loading } from "@empirica/core/player/react";
import React from "react";

export function Stage() {
  const player = usePlayer();
  const players = usePlayers();
  const round = useRound();

  if (player.stage.get("submit")) {
    if (players.length === 1) {
      return <Loading />;
    }

    return (
      <div className="text-center text-gray-400 pointer-events-none">
        Please wait for other player(s).
      </div>
    );
  }

  return (<p>Not yet implemented...</p>)
}
```

{% endcode %}

* In the `server/src/callbacks.js` file:
  * empty the contents of the `onGameStart` and `onStageEnded` functions, keeping the function definitions
  * delete everything after the empty function definition for `Empirica.onGameEnded({})`.

When you are done, the file should look like this:

```javascript
import { ClassicListenersCollector } from "@empirica/core/admin/classic";
export const Empirica = new ClassicListenersCollector();

Empirica.onGameStart(({ game }) => {});

Empirica.onRoundStart(({ round }) => {});

Empirica.onStageStart(({ stage }) => {});

Empirica.onStageEnded(({ stage }) => {});

Empirica.onRoundEnded(({ round }) => {});

Empirica.onGameEnded(({ game }) => {});
```

> Note: In JavaScript, a callback function is a function that is passed as an argument to another function and is invoked or called at a specific point within that function's execution. The callback function is typically used to ensure that certain code is executed only after the completion of a specific task or operation. In our case, these callbacks are invoked when parts of the experiment start and end.

#### Restart empirica

Now we can restart Empirica to have it reflect our changes. The command below will remove our existing datafile and start the server.

```sh
rm .empirica/local/tajriba.json; empirica
```

At this point of the tutorial, you should be able to start a new game on the admin site (<http://localhost:3000/admin/>).&#x20;

At this stage, if we login as a participant (by visiting [http://localhost:3000](http://localhost:3000/admin/)), the game will be stuck in loading, as we haven't yet added any content - that's what we'll do next!&#x20;


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.empirica.ly/tutorials/beginner-experiment-prisoners-dilemma/part-4-coding-the-prisoners-dilemma-game/part-4.1-removing-example-code.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
