<commit_before>﻿using System;
using System.Collections;
using System.Reflection;
using UnityEngine;

public class ProbingComponentSolver : ComponentSolver
{
    public ProbingComponentSolver(BombCommander bombCommander, MonoBehaviour bombComponent, IRCConnection ircConnection, CoroutineCanceller canceller) :
        base(bombCommander, bombComponent, ircConnection, canceller)
    {
        _wires = (MonoBehaviour[])_wiresField.GetValue(bombComponent.GetComponent(_componentType));
    }

    protected override IEnumerator RespondToCommandInternal(string inputCommand)
    {
        var split = inputCommand.Trim().ToLowerInvariant().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        if (_wires == null || _wires[0] == null || _wires[1] == null || _wires[2] == null || _wires[3] == null ||
            _wires[4] == null || _wires[5] == null)
            yield break;


        if (split.Length == 1 && split[0] == "cycle")
        {
            yield return "Reading the frequencies";
            yield return EnsureWiresConnected(1, 0);

            for (var i = 1; i < 6; i++)
            {
                yield return ConnectWires(i, 0);
                yield return new WaitForSeconds(2.0f);
            }
            yield return ConnectWires(4, 4);  //Leave the blue wire disconnected.
            yield break;
        }

        int red, blue;
        if (split.Length != 3 || split[0] != "connect" ||
            !int.TryParse(split[1], out red) || !int.TryParse(split[2], out blue) ||
            red < 1 || red > 6 || blue < 1 || blue > 6)
            yield break;

        yield return "Probing Solve Attempt";
        yield return EnsureWiresConnected(red-1, blue-1);
        yield return new WaitForSeconds(6.5f);
    }


    IEnumerator EnsureWiresConnected(int red, int blue)
    {
        int x = (red + 1) % 6;
        while (x == red || x == blue)
        {
            x++;
            x %= 6;
        }
        int y = (blue + 1) % 6;
        while (y == red || y == blue || y == x)
        {
            y++;
            y %= 6;<commit_msg>red & blue wires for the connect command need to be different numbers.<commit_after>﻿using System;
using System.Collections;
using System.Reflection;
using UnityEngine;

public class ProbingComponentSolver : ComponentSolver
{
    public ProbingComponentSolver(BombCommander bombCommander, MonoBehaviour bombComponent, IRCConnection ircConnection, CoroutineCanceller canceller) :
        base(bombCommander, bombComponent, ircConnection, canceller)
    {
        _wires = (MonoBehaviour[])_wiresField.GetValue(bombComponent.GetComponent(_componentType));
    }

    protected override IEnumerator RespondToCommandInternal(string inputCommand)
    {
        var split = inputCommand.Trim().ToLowerInvariant().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        if (_wires == null || _wires[0] == null || _wires[1] == null || _wires[2] == null || _wires[3] == null ||
            _wires[4] == null || _wires[5] == null)
            yield break;


        if (split.Length == 1 && split[0] == "cycle")
        {
            yield return "Reading the frequencies";
            yield return EnsureWiresConnected(1, 0);

            for (var i = 1; i < 6; i++)
            {
                yield return ConnectWires(i, 0);
                yield return new WaitForSeconds(2.0f);
            }
            yield return ConnectWires(4, 4);  //Leave the blue wire disconnected.
            yield break;
        }

        int red, blue;
        if (split.Length != 3 || split[0] != "connect" ||
            !int.TryParse(split[1], out red) || !int.TryParse(split[2], out blue) ||
            red < 1 || red > 6 || blue < 1 || blue > 6 || red == blue)
            yield break;

        yield return "Probing Solve Attempt";
        yield return EnsureWiresConnected(red-1, blue-1);
        yield return new WaitForSeconds(6.5f);
    }


    IEnumerator EnsureWiresConnected(int red, int blue)
    {
        int x = (red + 1) % 6;
        while (x == red || x == blue)
        {
            x++;
            x %= 6;
        }
        int y = (blue + 1) % 6;
        while (y == red || y == blue || y == x)
        {
            y++;
            y %= 6;
{'fraction_non_alphanumeric': 0.12352663837812353, 'fraction_numerical': 0.0165016501650165, 'mean_word_length': 2.1383136094674557, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '6719815', 'n_tokens_mistral': 1298, 'n_tokens_neox': 1237, 'n_words': 338}