This section quickly skims through the basic mechanics of the Fault Seeding game mode.
- Fault Seeding is a free-for-all game mode: each player is on its own.
- Number of players: 2 or more.
- Objective: Collect the most number of points until the time runs out.
Each player is working on the same challenge. However, only the first one who solves the challenge gets reward. Afterwards, a new challenge is selected. This goes on util the time runs out.
A challenge consists of a specification and a solution which does not adhere fully to the specification. The task of the players is to identify an input for which the output provided by solution contradicts the specification.
Prior to creating a new specification, a good starting point is to create a new solution for an existing specification.
Let's assume, that you want to create a new solution for the example-spec specification! The process is as follows:
- Naming Your Solution
- Solution Directory
- Solution Manifest File
- Description and Breakdown
- Actual Solution Code
- Test Cases
- Running the Tests
The name of your solution should refer to the contradiction between the solution and the specification.
Create a new directory under the src/fault-seeding/challenges/example-spec/solutions directory named after your solution. Directory names should be in kebab-case.
The manifest is a machine readable solution descriptor in JSON format. The schema of this file can be found at solution-manifest.schema.json.
This file must be placed in the solution directory.
A human readable description of the solution in the form of a README.md. This file must include a Breakdown section where the bug is highlighted.
This file must be placed in the solution directory.
An index.js file containing the actual solution. This file must be written as stated in the specification with a little bug hidden inside.
This file must be placed in the solution directory.
Test cases that catch the bug in the newly created solution. The test.js file must export an array of test cases.
A test case is an object of the following shape:
{
description: 'A short description of the case.`,
test
}where the test field can be any of the following two:
- A function taking a single parameter, a solution. The function must return with the result of that should be compared.
- An array of input parameters the solutions will be called with.
This file must be placed in the solution directory.
Run the npm run test command in the repository root and make sure, that all tests are green!
Here are some tips to write good solutions:
- Break for a single class of inputs.
- If your solution breaks only for a single class of inputs, it makes it much harder to find a contradicting input.
- Use real-world inspirations.
- Typically, bugs inspired by real-world code work best, as those are the hardest to spot.
- Feel free to be evil.
- Misleading comments? Sure!
The process is as follows:
- Naming Your Specification
- Specification Directory
- Specification Manifest File
- Description
- Evaluator Code
- Starter Code
- Solution
The name of your solution be as short and catchy as possible.
Create a new directory under the src/fault-seeding/challenges directory named after your specification. Directory names should be in kebab-case.
The manifest is a machine readable specification descriptor in JSON format. The schema of this file can be found at challenge-manifest.schema.json.
This file must be placed in the specification directory.
The actual specification text in a README.md file. The following sections are recommended:
- Task
- Signature
- Behaviour
- Input Format
- Output Format
- Examples
This file must be placed in the specification directory.
A perfect implementation of the specification. Make sure, that this solution adheres completely to the spec, as this is going to be used as the gold standard when evaluating the output of erroneous solutions.
This code must be in an index.js file placed under the evaluator directory in the specification directory.
A simple index.js file placed in the starter directory containing an empty but signature-wise correct implementation of the specification.
Create one or more solutions to your new specification according to the Developing Solutions section.
Here are some tips to write good specifications:
- Choose a simple problem.
- Codeosseum is intended to be a fast-paced competitive platform. Therefore, make sure that you choose problems that can be easily described.
- Choose a problem with many pitfalls.
- Make sure, that the problem is not only easy to comprehend, but easy to get wrong too.
- Use real-world inspirations.
- Just as in the case for solutions, best problems have real-world roots.
- Be as specific as possible.
- Vague specifications make it hard to create new solutions and even harder to catch bugs. However, this is not the good kind of hard.