<commit_before>import React from 'react';

import ProblemPrompter from './ProblemPrompter';
import Repl from '../Repl';

import persistComponent from '../../util/persist';

import LambdaInput from '../LambdaInput';
import problems from '../../game/problems';

const StartPrompt = ({start}) => (
  <div>
    <p>
      Interactive REPL and tutorial for the untyped Lambda Calculus
    </p>
    <p>
      Click <button onClick={start}>here</button> to begin the tutorial
    </p>
  </div>
);

const defaultState = {
  currentProblem: 0,
  gameStarted: false,
  shownProblem: 0,
};

class App extends React.Component {
  state = defaultState;

  _handleOnCompute = (computation) => {
    let pNum = this.state.currentProblem;
    if (problems[pNum].winCondition(computation)) {
      if (pNum < problems.length - 1){
        this.setState({
          currentProblem: pNum + 1,
          shownProblem: pNum + 1,
        });
      } else {
        this.setState({gameStarted: false});
      }
    }
  }

  startGame = () => {
    this.setState({
      gameStarted: true,
      currentProblem: 0,
      shownProblem: 0,
    });
  }

  _handleNext = () => {
    this.setState({
      shownProblem: Math.min(
        this.state.shownProblem + 1,
        this.state.currentProblem
      ),
    });
  }
<commit_msg>make it so win conditions work on old problems<commit_after>import React from 'react';

import ProblemPrompter from './ProblemPrompter';
import Repl from '../Repl';

import persistComponent from '../../util/persist';

import LambdaInput from '../LambdaInput';
import problems from '../../game/problems';

const StartPrompt = ({start}) => (
  <div>
    <p>
      Interactive REPL and tutorial for the untyped Lambda Calculus
    </p>
    <p>
      Click <button onClick={start}>here</button> to begin the tutorial
    </p>
  </div>
);

const defaultState = {
  currentProblem: 0,
  gameStarted: false,
  shownProblem: 0,
};

class App extends React.Component {
  state = defaultState;

  _handleOnCompute = (computation) => {
    let {
      currentProblem,
      shownProblem,
    } = this.state;
    if (problems[shownProblem].winCondition(computation)) {
      if (shownProblem < problems.length - 1){
        this.setState({
          currentProblem: Math.max(shownProblem + 1, currentProblem),
          shownProblem: shownProblem + 1,
        });
      } else {
        this.setState({gameStarted: false});
      }
    }
  }

  startGame = () => {
    this.setState({
      gameStarted: true,
      currentProblem: 0,
      shownProblem: 0,
    });
  }

  _handleNext = () => {
    this.setState({
      shownProblem: Math.min(
        this.state.shownProblem + 1,
        this.state.currentProblem
      ),
    });
  }

{'fraction_non_alphanumeric': 0.13521436423598387, 'fraction_numerical': 0.005862953462806889, 'mean_word_length': 2.504492939666239, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6787866', 'n_tokens_mistral': 890, 'n_tokens_neox': 840, 'n_words': 208}