public void RandomTest() { Random random = new Random(7777777); int repetitions = 20; TimeSpan timeout = TimeSpan.FromSeconds(1); int returnLength = 18; int requiredLength = 20; for (int repetition = 0; repetition < repetitions; repetition++) { Alg scramble = Alg.FromRandomMoves(random.Next(20, 30), random); CubieCube cube = CubieCube.FromAlg(scramble); Alg solution = TwoPhaseSolver.FindSolution(cube, timeout, returnLength, requiredLength); Console.WriteLine("\nScramble: " + scramble + "\nSolution: " + solution + "\nLength: " + solution.Length); Assert.IsTrue(solution.Length <= 20); CubieCube expected = CubieCube.CreateSolved(); CubieCube result = CubieCube.CreateSolved(); result.ApplyAlg(scramble); result.ApplyAlg(solution); Assert.AreEqual(expected, result); } }
public async Task <IActionResult> PutAlg(int id, Alg alg) { if (id != alg.Id) { return(BadRequest()); } _context.Entry(alg).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AlgExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void EquatorPermutationCoordTest() //Tests GetEquatorPermutationCoord, SetEquatorPermutationCoord { Random random = new Random(7777777); int length = 50; int repetitions = 50; //if solved permutation corresponds to the coordinate 0 //SetEquatorPermutationCoord() CubieCube expected = CubieCube.CreateSolved(); CubieCube result = CubieCube.FromAlg(Alg.FromRandomMoves(length, random)); Coordinates.SetEquatorOrder(result, 0); CubingAssert.HaveEqualEquatorEdgePermutation(expected, result); expected = CubieCube.FromAlg(Alg.FromString("R2 L2")); result = CubieCube.FromAlg(Alg.FromRandomMoves(length, random)); Coordinates.SetEquatorOrder(result, Coordinates.NumEquatorOrders - 1); //GetEquatorPermutationCoord() result = CubieCube.CreateSolved(); Assert.AreEqual(0, Coordinates.GetEquatorOrder(result)); result.ApplyAlg(Alg.FromString("F' R' B' D' L2")); Assert.AreEqual(0, Coordinates.GetEquatorOrder(result)); //apply B1 int expectedCoord = 17; CubieCube cube = CubieCube.CreateSolved(); cube.ApplyMove(Move.B1); int resultCoord = Coordinates.GetEquatorOrder(cube); Assert.AreEqual(expectedCoord, resultCoord); //apply B2 expectedCoord = 6; cube = CubieCube.CreateSolved(); cube.ApplyMove(Move.B2); resultCoord = Coordinates.GetEquatorOrder(cube); Assert.AreEqual(expectedCoord, resultCoord); //if applying GetEquatorPermutationCoord() and SetEquatorPermutationCoord() results in the same array as at the beginning for (int repetition = 0; repetition < repetitions; repetition++) { expected = CubieCube.FromAlg(Alg.FromRandomMoves(length, random)); result = CubieCube.CreateSolved(); int coord = Coordinates.GetEquatorOrder(expected); Coordinates.SetEquatorOrder(result, coord); CubingAssert.HaveEqualEquatorEdgePermutation(expected, result); } //exceptions Assert.ThrowsException <ArgumentNullException>(() => Coordinates.GetEquatorOrder(null)); Assert.ThrowsException <ArgumentNullException>(() => Coordinates.SetEquatorOrder(null, 0)); Assert.ThrowsException <ArgumentOutOfRangeException>(() => Coordinates.SetEquatorOrder(CubieCube.CreateSolved(), -1)); Assert.ThrowsException <ArgumentOutOfRangeException>(() => Coordinates.SetEquatorOrder(CubieCube.CreateSolved(), Coordinates.NumEquatorOrders)); }
public void ReduceEoEquatorCoordinateTest() { Random random = new Random(7777777); int length = 30; int count = 100; for (int i = 0; i < count; i++) { CubieCube cube = CubieCube.FromAlg(Alg.FromRandomMoves(length, random)); for (int sym = 0; sym < NumSymmetriesDh4; sym++) { CubieCube symCube = Symmetries.SymmetryCubes[sym].Clone(); symCube.Multiply(cube); symCube.Multiply(Symmetries.SymmetryCubes[Symmetries.InverseIndex[sym]]); int cubeEoEquator = GetEoEquatorCoord(cube); int cubeReducedEoEquator = SymmetryReduction.ReduceEoEquatorCoordinate[cubeEoEquator]; int symCubeEoEquator = GetEoEquatorCoord(symCube); int symCubeReducedEoEqutor = SymmetryReduction.ReduceEoEquatorCoordinate[symCubeEoEquator]; Assert.AreEqual(cubeReducedEoEquator, symCubeReducedEoEqutor); } } }
public async Task <ActionResult <Alg> > PostAlg(Alg alg) { _context.Algs.Add(alg); await _context.SaveChangesAsync(); return(CreatedAtAction("GetAlg", new { id = alg.Id }, alg)); }
public void OperatorTest() { Random random = new Random(7777777); int length1 = 50, length2 = 50; int times = 4; Alg nullAlg = null; // + Alg alg1 = Alg.FromRandomMoves(length1, random); Alg alg2 = Alg.FromRandomMoves(length2, random); Alg addTest = alg1 + alg2; Assert.AreEqual(alg1, Alg.FromEnumerable(addTest, 0, alg1.Length)); Assert.AreEqual(alg2, Alg.FromEnumerable(addTest, alg1.Length, alg1.Length + alg2.Length)); Assert.ThrowsException <ArgumentNullException>(() => nullAlg + alg1); Assert.ThrowsException <ArgumentNullException>(() => alg1 + nullAlg); // * Alg multiplyTest = alg1 * times; for (int i = 0; i < times; i++) { Assert.AreEqual(alg1, Alg.FromEnumerable(multiplyTest, i * alg1.Length, (i + 1) * alg1.Length)); } Assert.ThrowsException <ArgumentNullException>(() => nullAlg * times); Assert.ThrowsException <ArgumentOutOfRangeException>(() => alg1 * -1); }
public void EoCoordTest() //Tests GetEOCoord, SetEOCoord { Random random = new Random(7777777); int length = 50; //if applying GetEOCoord and SetEOCoord results in the same array as at the beginning CubieCube expected = CubieCube.FromAlg(Alg.FromRandomMoves(length, random)); CubieCube result = CubieCube.CreateSolved(); int coord = Coordinates.GetEdgeOrientation(expected); Coordinates.SetEdgeOrientation(result, coord); CollectionAssert.AreEqual(expected.EdgeOrientation, result.EdgeOrientation); //if solved orientation corresponds to the coordinate 0 expected = CubieCube.CreateSolved(); result = CubieCube.FromAlg(Alg.FromRandomMoves(length, random)); Coordinates.SetEdgeOrientation(result, 0); CollectionAssert.AreEqual(expected.EdgeOrientation, result.EdgeOrientation); result = CubieCube.CreateSolved(); Assert.AreEqual(0, Coordinates.GetEdgeOrientation(result)); //exceptions Assert.ThrowsException <ArgumentNullException>(() => Coordinates.GetEdgeOrientation(null)); Assert.ThrowsException <ArgumentNullException>(() => Coordinates.SetEdgeOrientation(null, 0)); Assert.ThrowsException <ArgumentOutOfRangeException>(() => Coordinates.SetEdgeOrientation(CubieCube.CreateSolved(), -1)); Assert.ThrowsException <ArgumentOutOfRangeException>(() => Coordinates.SetEdgeOrientation(CubieCube.CreateSolved(), Coordinates.NumEdgeOrientations)); }
public void CombineUAndDEdgeCoordsTest() { Random random = new Random(7777777); int length = 50; int repetitions = 50; double[] phase2probabilities = { 0d, 1d, 0d, 1d, 1d, 1d, 0d, 1d, 0d, 0d, 1d, 0d, 1d, 1d, 1d, 0d, 1d, 0d }; for (int repetition = 0; repetition < repetitions; repetition++) { Alg alg = Alg.FromRandomMoves(length, random, phase2probabilities); CubieCube cube = CubieCube.FromAlg(alg); int uEdgeCoord = Coordinates.GetUEdgePermutation(cube); int dEdgeCoord = Coordinates.GetDEdgePermutation(cube); int result = Coordinates.CombineUEdgePermutationAndDEdgeOrder(uEdgeCoord, dEdgeCoord % Coordinates.NumDEdgeOrders); int expected = Coordinates.GetUdEdgeOrder(cube); Assert.AreEqual(expected, result); } }
public void EqualityTest() { Alg alg1 = Alg.FromEnumerable(new[] { Move.L2, Move.F1, Move.R3 }); Alg alg2 = Alg.FromEnumerable(new[] { Move.L2, Move.F1, Move.R3 }); Alg nullAlg = null; Assert.IsTrue(alg1.Equals(alg1)); Assert.IsTrue(alg1.Equals(alg2)); Assert.IsFalse(alg1.Equals(nullAlg)); Assert.IsTrue(Alg.AreEqual(alg1, alg1)); Assert.IsTrue(Alg.AreEqual(alg1, alg2)); Assert.IsFalse(Alg.AreEqual(null, alg1)); #pragma warning disable CS1718 // Comparison made to same variable Assert.IsTrue(alg1 == alg1); Assert.IsTrue(alg1 == alg2); Assert.IsFalse(alg1 == nullAlg); Assert.IsFalse(nullAlg == alg1); Assert.IsFalse(alg1 != alg1); Assert.IsFalse(alg1 != alg2); Assert.IsTrue(alg1 != nullAlg); Assert.IsTrue(nullAlg != alg1); #pragma warning restore CS1718 // Comparison made to same variable }
protected override void Train() { var tcnt = m_Training.Count; var tstart = DateTime.Now; var now = DateTime.Now; Alg = Examples.CreateCIFAR10TruncDemo2(m_Training); Alg.EpochEndedEvent += (o, e) => { Utils.HandleEpochEnded(Alg, m_Test, ResultsFolder); tstart = DateTime.Now; }; Alg.BatchEndedEvent += (o, e) => { now = DateTime.Now; var iter = Alg.Iteration; var pct = 100 * iter / (float)tcnt; var elapsed = TimeSpan.FromMinutes((now - tstart).TotalMinutes * (tcnt - iter) / iter); Console.Write("\rCurrent epoch progress: {0:0.00}%. Left {1:0}m {2:0}s ", pct, elapsed.Minutes, elapsed.Seconds); }; Console.WriteLine(); Console.WriteLine("Training started at {0}", now); Alg.Train(); Console.WriteLine("--------- ELAPSED TRAIN ----------" + (DateTime.Now - now).TotalMilliseconds); }
public void FromEnumerableTest() { Move[] moves = { Move.R1, Move.D2, Move.B3 }; Alg alg1 = Alg.FromEnumerable(moves); Assert.AreEqual("R D2 B'", alg1.ToString()); Assert.ThrowsException <ArgumentNullException>(() => Alg.FromEnumerable(null)); Alg alg2 = Alg.FromEnumerable(moves, 0, moves.Length); Assert.AreEqual(alg2, alg1); for (int i = 0; i < moves.Length; i++) { Alg alg3 = Alg.FromEnumerable(moves, i, i); Assert.AreEqual(0, alg3.Length); } Alg alg4a = Alg.FromEnumerable(moves, 0, 2); Alg alg4b = Alg.FromEnumerable(moves.Take(2)); Assert.AreEqual(alg4b, alg4a); Alg alg5a = Alg.FromEnumerable(moves, 1, 3); Alg alg5b = Alg.FromEnumerable(moves.Skip(1)); Assert.AreEqual(alg5b, alg5a); Assert.ThrowsException <ArgumentNullException>(() => Alg.FromEnumerable(null, 0, 0)); Assert.ThrowsException <ArgumentOutOfRangeException>(() => Alg.FromEnumerable(moves, -1, 0)); Assert.ThrowsException <ArgumentOutOfRangeException>(() => Alg.FromEnumerable(moves, 0, moves.Length + 1)); Assert.ThrowsException <ArgumentException>(() => Alg.FromEnumerable(moves, 1, 0)); }
public void FromStringTest() { string alg = "B R' F2 D'"; Assert.AreEqual(alg, Alg.ToString(Alg.FromString(alg))); Assert.ThrowsException <ArgumentException>(() => Alg.FromString("Exp")); Assert.ThrowsException <ArgumentNullException>(() => Alg.FromString(null)); }
private void button6_Click(object sender, RoutedEventArgs e) { Alg Algoritm = (Alg)Enum.Parse(typeof(Alg), comboBox1.Text); CipherMode Cipher = (CipherMode)Enum.Parse(typeof(CipherMode), comboBox2.Text); PaddingMode Padding = (PaddingMode)Enum.Parse(typeof(PaddingMode), comboBox3.Text); Criptare(textBox1.Text, textBox2.Text, Cheie, IV, Algoritm, Cipher, Padding, true); }
static void FOVTransition(float fov, long intermission = 0) { startFOV = currentFOV; endFOV = Alg.Clamp(10, fov, 160); startFOVTime = GameTime.Ticks; endFOVTime = startFOVTime + intermission; }
private void button5_Click(object sender, RoutedEventArgs e) { Alg alg = (Alg)Enum.Parse(typeof(Alg), comboBox1.Text); CipherMode cm = (CipherMode)Enum.Parse(typeof(CipherMode), comboBox2.Text); PaddingMode pm = (PaddingMode)Enum.Parse(typeof(PaddingMode), comboBox3.Text); EncryptData(textBox1.Text, textBox2.Text, Key, IV, alg, cm, pm, false); }
public override int GetHashCode() { int hash = 1; if (Hash.Length != 0) { hash ^= Hash.GetHashCode(); } if (From.Length != 0) { hash ^= From.GetHashCode(); } if (To.Length != 0) { hash ^= To.GetHashCode(); } if (Value.Length != 0) { hash ^= Value.GetHashCode(); } if (Nonce != 0UL) { hash ^= Nonce.GetHashCode(); } if (Timestamp != 0L) { hash ^= Timestamp.GetHashCode(); } if (data_ != null) { hash ^= Data.GetHashCode(); } if (ChainId != 0) { hash ^= ChainId.GetHashCode(); } if (GasPrice.Length != 0) { hash ^= GasPrice.GetHashCode(); } if (GasLimit.Length != 0) { hash ^= GasLimit.GetHashCode(); } if (Alg != 0) { hash ^= Alg.GetHashCode(); } if (Sign.Length != 0) { hash ^= Sign.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public void FromRandomMoves2Test() { Random random = new Random(7777777); int length = 50; int repetitions = 1000; double[] probabilities = Enumerable .Repeat(0d, Constants.NumMoves) .ToArray(); probabilities[9] = 100000; probabilities[3] = 1; probabilities[4] = 1; probabilities[5] = 1; probabilities[6] = 3; Move[] possibleMoves = { Move.L1, Move.U1, Move.U2, Move.U3, Move.F1 }; int[] sumOfMoves = Enumerable. Repeat(0, Constants.NumMoves) .ToArray(); for (int repetition = 0; repetition < repetitions; repetition++) { int lastCount = sumOfMoves.Sum(); Alg randomAlg = Alg.FromRandomMoves(length, random, probabilities); Assert.AreEqual(length, randomAlg.Length); for (int move = 0; move < Constants.NumMoves; move++) { sumOfMoves[move] += randomAlg.Count(randomMove => randomMove == (Move)move); } Assert.AreEqual(length, sumOfMoves.Sum() - lastCount); } Assert.AreEqual(length * repetitions, sumOfMoves.Sum()); double[] effectiveProbabilities = sumOfMoves .Select(count => count / (double)(length * repetitions)) .ToArray(); //make sure only move with probability > 0 occur double impossibleMoveProbability = effectiveProbabilities .Where((probability, index) => !possibleMoves.Contains((Move)index)) .Sum(); Assert.AreEqual(0d, impossibleMoveProbability); //compare the effective probabilities double delta = 0.02d; Assert.AreEqual(1 / 2d, effectiveProbabilities[9], delta); Assert.AreEqual(1 / 4d, effectiveProbabilities[6], delta); Assert.AreEqual(1 / 12d, effectiveProbabilities[3], delta); Assert.AreEqual(1 / 12d, effectiveProbabilities[4], delta); Assert.AreEqual(1 / 12d, effectiveProbabilities[5], delta); }
public void CpCoordTest() //Tests GetCpCoord, SetCpCoord { Random random = new Random(7777777); int length = 50; //if applying GetCpCoord and SetCpCoord results in the same array as at the beginning CubieCube expected = CubieCube.FromAlg(Alg.FromRandomMoves(length, random)); CubieCube result = CubieCube.CreateSolved(); int coord = Coordinates.GetCornerPermutation(expected); Coordinates.SetCornerPermutation(result, coord); CollectionAssert.AreEqual(expected.CornerPermutation, result.CornerPermutation); //apply R2 to a solved cube CubieCube cube = CubieCube.CreateSolved(); cube.ApplyMove(Move.R2); int expectedCoord = 36177; int resultCoord = Coordinates.GetCornerPermutation(cube); Assert.AreEqual(expectedCoord, resultCoord); expected = CubieCube.CreateSolved(); expected.ApplyMove(Move.R2); result = CubieCube.CreateSolved(); Coordinates.SetCornerPermutation(result, expectedCoord); CollectionAssert.AreEqual(expected.CornerPermutation, result.CornerPermutation); //if solved permutation corresponds to the coordinate 0 expected = CubieCube.CreateSolved(); result = CubieCube.FromAlg(Alg.FromRandomMoves(length, random)); Coordinates.SetCornerPermutation(result, 0); CollectionAssert.AreEqual(expected.CornerPermutation, result.CornerPermutation); result = CubieCube.CreateSolved(); Assert.AreEqual(0, Coordinates.GetCornerPermutation(result)); //example from http://kociemba.org/math/coordlevel Corner[] cp = new Corner[] { Corner.DFR, Corner.UFL, Corner.ULB, Corner.URF, Corner.DRB, Corner.DLF, Corner.DBL, Corner.UBR }; cube = CubieCube.Create(cp, CubieCube.SolvedCO, CubieCube.SolvedEP, CubieCube.SolvedEO, CubieCube.SolvedCenters); resultCoord = Coordinates.GetCornerPermutation(cube); expectedCoord = 21021; Assert.AreEqual(expectedCoord, resultCoord); //exceptions Assert.ThrowsException <ArgumentNullException>(() => Coordinates.GetCornerPermutation(null)); Assert.ThrowsException <ArgumentNullException>(() => Coordinates.SetCornerPermutation(null, 0)); Assert.ThrowsException <ArgumentOutOfRangeException>(() => Coordinates.SetCornerPermutation(CubieCube.CreateSolved(), -1)); Assert.ThrowsException <ArgumentOutOfRangeException>(() => Coordinates.SetCornerPermutation(CubieCube.CreateSolved(), Coordinates.NumCornerPermutations)); }
private void MyCircle_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { Ellipse clickdot = ((Ellipse)sender); if (!OnlyOneSelected) { PreviousEl = clickdot; if (!gameState.Jugador)//0 Max { clickdot.Stroke = Brushes.Blue; } else { clickdot.Stroke = Brushes.Red;//Min Rojo } clickdot.StrokeThickness = 3; TAGPrevious = (TAGInfo)clickdot.Tag; OnlyOneSelected = true; } else { OnlyOneSelected = false; if (TAGPrevious.TAG == ((TAGInfo)clickdot.Tag).TAG) { clickdot.Stroke = Brushes.Black; clickdot.StrokeThickness = 1; } else { double x1 = TAGPrevious.X + 10; double x2 = ((TAGInfo)clickdot.Tag).X + 10; double y1 = TAGPrevious.Y + 10; double y2 = ((TAGInfo)clickdot.Tag).Y + 10; DotLine linetodraw; //Sirve para izquierda a derecha y arriba hacia abajo linetodraw = gameState.ItemsLine.Where(x => (x.X1 == x1 && x.Y1 == y1 && x.X2 == x2 && x.Y2 == y2) || (x.X1 == x2 && x.Y1 == y2 && x.X2 == x1 && x.Y2 == y1)).SingleOrDefault(); linetodraw?.DrawLine(); PreviousEl.Stroke = Brushes.Black; PreviousEl.StrokeThickness = 1; //Dibujar rectangulito Thread.Sleep(10); DrawBox(); while (gameState.Jugador) { //Hacer jugada por parte de la maquina var tem = Alg.MaxValue(gameState.BooleanRepresentation(), float.MinValue + 1, float.MaxValue - 1, 4); BooleanState t = Alg.Result; gameState.UpdateGame(t); DrawBox(); } } } }
private void Decrypt_Click(object sender, RoutedEventArgs e) { Alg alg = (Alg)Enum.Parse(typeof(Alg), comboBox1.Text); CipherMode cm = (CipherMode)Enum.Parse(typeof(CipherMode), comboBox2.Text); PaddingMode pm = (PaddingMode)Enum.Parse(typeof(PaddingMode), comboBox3.Text); GetPreReq(); DecryptData(Key, IV, alg, cm, pm); }
public void IndexerTest() { Alg alg = Alg.FromString("R U2 F'"); Assert.AreEqual(Move.R1, alg[0]); Assert.AreEqual(Move.U2, alg[1]); Assert.AreEqual(Move.F3, alg[2]); Assert.ThrowsException <IndexOutOfRangeException>(() => alg[-1]); Assert.ThrowsException <IndexOutOfRangeException>(() => alg[4]); }
private static string GetGetValueErrorMessage <TKey, TValue>(IEnumerable <KeyValuePair <TKey, TValue> > dictionary, TKey key) { const int lengthCap = 500; var keysCharList = Alg.Intersperse(",", dictionary.Select(x => x.Key.ToString())).SelectMany(x => x.ToCharArray()); var errorMessage = "Failed to find key " + key.ToString() + " in dictionary containing keys [" + Alg.MergedChars(keysCharList.Take(lengthCap)) + (keysCharList.Skip(lengthCap).Any() ? " ...<truncated for length>" : "") + "]"; return(errorMessage); }
public void ToStringTest() { Alg alg = Alg.FromEnumerable(new[] { Move.B1, Move.R3, Move.F2 }); string expected = "B R' F2"; string result1 = Alg.ToString(alg); string result2 = alg.ToString(); Assert.AreEqual(expected, result1); Assert.AreEqual(expected, result2); Assert.ThrowsException <ArgumentNullException>(() => Alg.ToString(null)); }
protected override void Train() { Alg.EpochEndedEvent += (o, e) => Utils.HandleEpochEnded(Alg, m_TrainingSet.Subset(0, 10000), m_ValidationSet, OutputPath); // we do not have public test data in kaggle :( var now = DateTime.Now; Console.WriteLine(); Console.WriteLine("Training started at {0}", now); Alg.Train(m_TrainingSet); Console.WriteLine("--------- ELAPSED TRAIN ----------" + (DateTime.Now - now).TotalMilliseconds); }
private void doExport(string fpath, string opath) { var sample = new ClassifiedSample <string>(); using (var srcFile = File.Open(fpath, FileMode.Open, FileAccess.Read)) using (var srcReader = new StreamReader(srcFile)) { var line = srcReader.ReadLine(); var segs = line.Split(SEPARATOR, StringSplitOptions.RemoveEmptyEntries); var cls = m_Classes[segs[0]]; var doc = segs[1]; sample.Add(doc, cls); } var vocabulary = Alg.ExtractVocabulary(sample); var dim = vocabulary.Count; var builder = new StringBuilder(); using (var outFile = File.Open(opath, FileMode.CreateNew, FileAccess.Write)) using (var outWriter = new StreamWriter(outFile)) { for (int i = 0; i < dim; i++) { builder.AppendFormat("{0},", vocabulary[i]); } builder.Append("_class,_value,_training"); outWriter.WriteLine(builder.ToString()); foreach (var pData in sample) { var doc = pData.Key; var cls = pData.Value; bool isEmpty; var data = Alg.ExtractFeatureVector(doc, out isEmpty); if (isEmpty) { continue; } builder.Clear(); for (int i = 0; i < dim; i++) { builder.AppendFormat("{0},", data[i]); } builder.AppendFormat("{0},{1},{2}", cls.Name, cls.Value, 1); outWriter.WriteLine(builder.ToString()); } } }
public static byte[] Genesis(BigInteger serverID) { if (Runtime.CheckWitness(Owner)) { Alg.GenesisCreateCities(serverID); //RW.GenesisCreateFake return(NuTP.RespDataSuccess()); } else { return(NuTP.RespDataWithCode(ErrCate.Account, ErrType.AuthFail)); } }
public void SexyMoveTest(Action <CubieCube, CubieCube> test) { Alg sexyMove = Alg.FromString("R U R' U'"); foreach (Rotation rotation in Enum.GetValues(typeof(Rotation))) { CubieCube expected = CubieCube.CreateSolved(); CubieCube result = CubieCube.CreateSolved(); result.ApplyAlg(sexyMove.Rotate(rotation) * 6); test(expected, result); } }
public void GetHashCodeTest() { Random random = new Random(7777777); int length = 50; int repetitions = 50; for (int rep = 0; rep < repetitions; rep++) { Alg alg = Alg.FromRandomMoves(length, random); Alg clone = Alg.FromEnumerable(alg); Assert.AreEqual(alg.GetHashCode(), clone.GetHashCode()); } }
public void GetNumberOfEachMoveTest() { Alg alg = Alg.FromString("L2 B F' R L2 F2 L2 R"); int[] expected = { 2, 0, 0, 0, 0, 0, 0, 1, 1, 0, 3, 0, 0, 0, 0, 1, 0, 0 }; int[] result = alg.GetCountOfEachMove(); CollectionAssert.AreEqual(expected, result); }
protected override void Train() { Alg = Examples.CreateCIFAR10Demo1(m_Training); Alg.EpochEndedEvent += (o, e) => Utils.HandleEpochEnded(Alg, m_Training.Subset(0, 10000), ResultsFolder); // we do not have public test data in kaggle :( var now = DateTime.Now; Console.WriteLine(); Console.WriteLine("Training started at {0}", now); Alg.Train(); Console.WriteLine("--------- ELAPSED TRAIN ----------" + (DateTime.Now - now).TotalMilliseconds); }
public Game() { try { FileStream inFile = new FileStream("Setting.txt", FileMode.Open); StreamReader sr = new StreamReader(inFile); string st = sr.ReadLine(); map= new Map(this, st[0] - '0', st[1] - '0'); st = sr.ReadLine(); cntPlayer = st.Length; player = new Player[cntPlayer]; for (int i = 0; i < cntPlayer; ++i) player[i] = new Player(i, "", st[i].ToString(), map.MapX / 2, map.MapY / 2); } catch { map = new Map(this); cntPlayer = 4; player = new Player[cntPlayer]; player[0] = new Player(0, "", "A", map.MapX / 2, map.MapY / 2); player[1] = new Player(1, "", "B", map.MapX / 2, map.MapY / 2); player[2] = new Player(2, "", "C", map.MapX / 2, map.MapY / 2); player[3] = new Player(3, "", "D", map.MapX / 2, map.MapY / 2); } //cntPlayer = 4; //player = new Player[cntPlayer]; //player[0] = new Player(0, "", "A", map.MapX / 2, map.MapY / 2); //player[1] = new Player(1, "", "B", map.MapX / 2, map.MapY / 2); //player[2] = new Player(2, "", "C", map.MapX / 2, map.MapY / 2); //player[3] = new Player(3, "", "D", map.MapX / 2, map.MapY / 2); //nowPlayerID = -1; alg = new Alg(this); help = new Help(this); Mover.game = this; nowPlayerID = -1; WaitReviving = true; NewRound(); }