Commit 3ab03fd4 authored by Bošániová Monika's avatar Bošániová Monika
Browse files

timeline added, latex update

parent baeb3eb0
This diff is collapsed.
......@@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
//UROBIT setters a getters!!!
public class Automate : MonoBehaviour
......@@ -13,6 +14,8 @@ public class Automate : MonoBehaviour
public GameObject rubicsCube;
public GameObject cubeMap;
public GameObject ClickableRotator;
public GameObject timeline;
public Text algorithmMessage;
public static int actualPosition = 0;
public static bool shuffleDone = false;
public static bool AutomatePlaying = false;
......@@ -25,6 +28,11 @@ public class Automate : MonoBehaviour
private float speed = 300f;
private float angle = 0;
private string firstPhase = "Solve white face";
private string secondPhase = "Solve second row";
private string thirdPhase = "Solve third rows's corners";
private string fourthPhase = "Solve third row's middles";
private readonly List<string> allMoves = new List<string>()
{ "U", "D", "L", "R", "F", "B",
"U2", "D2", "L2", "R2", "F2", "B2",
......@@ -70,16 +78,31 @@ public class Automate : MonoBehaviour
}
if (movelist.getItems().Count > 0 && !CubeState.autoRotating && CubeState.started && AutomatePlaying && movelistIterator.MoveNext())
{
string actualMove = movelistIterator.Current().ToString();
if (actualMove != "1" && actualMove != "2" && actualMove != "3" && actualMove != "4")
{
updateTimeline();
}
//do the move at the first index;
DoMove(movelistIterator.Current().ToString());
DoMove(actualMove);
}
}
private void updateTimeline()
{
int index = movelistIterator.Key();
for (int i = -1; i < 6; i++)
{
timeline.transform.Find("Step" + i).GetComponent<Text>().text = (index + i) < movelist.getItems().Count && (index + i) > -1 ? movelist.getItems()[index + i] : " ";
}
}
public void AutomatePlayStart()
{
if(movelist.getItems().Count > 0)
......@@ -99,6 +122,7 @@ public class Automate : MonoBehaviour
if (movelistIterator.MoveNext())
{
DoMove(movelistIterator.Current().ToString());
updateTimeline();
print(movelistIterator.Key().ToString() + " : " + movelistIterator.Current().ToString());
}
......@@ -111,11 +135,12 @@ public class Automate : MonoBehaviour
{
AutomatePlaying = false;
if(movelist.getItems().Count > 0 && !CubeState.autoRotating && CubeState.started && movelistIterator.Key() != -1)
if (movelist.getItems().Count > 0 && !CubeState.autoRotating && CubeState.started && movelistIterator.Key() != -1)
{
DoOppositeMove(movelistIterator.Current().ToString());
updateTimeline();
print(movelistIterator.Key().ToString() + " : " + movelistIterator.Current().ToString());
if (!movelistIterator.MoveBack())
......@@ -225,9 +250,23 @@ public class Automate : MonoBehaviour
side = Colors.Yellow;
angle = -180;
break;
default: break;
case "1":
algorithmMessage.text = firstPhase;
return;
case "2":
algorithmMessage.text = secondPhase;
return;
case "3":
algorithmMessage.text = thirdPhase;
return;
case "4":
algorithmMessage.text = fourthPhase;
return;
default:
return;
}
List<Transform> childsToEdit = new List<Transform>();
float epsilon = 0.01f;
foreach (Transform child in rubicsCube.transform)
......@@ -309,6 +348,15 @@ public class Automate : MonoBehaviour
case "D'":
DoMove("D");
return;
case "2":
algorithmMessage.text = firstPhase;
return;
case "3":
algorithmMessage.text = secondPhase;
return;
case "4":
algorithmMessage.text = thirdPhase;
return;
default:
return;
}
......
......@@ -3,6 +3,7 @@ using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Kociemba;
using System;
public class SolveTwoFace : MonoBehaviour
{
......@@ -32,30 +33,38 @@ public class SolveTwoFace : MonoBehaviour
{
if (!CubeState.autoRotating)
{
if (isCubeSolvable())
{
//get the state of the cube as a string
string moveString = cubeState.GetStateString(false);
print(moveString);
//get the state of the cube as a string
string moveString = cubeState.GetStateString(false);
print(moveString);
////solve the cube
Solver solver = new Solver(moveString);
////string info = "";
////first time build the tables
string solution = solver.Solve();
////solve the cube
Solver solver = new Solver(moveString);
////string info = "";
////first time build the tables
string solution = solver.Solve();
////convert the solved moves from a string to a list
List<string> solutionList = StringToList(solution);
////convert the solved moves from a string to a list
List<string> solutionList = StringToList(solution);
////Automate the list
//Automate.shuffleDone = false;
//Automate.setAutomateList(new List<string> { "F" } );
print("Count: " + solutionList.Count);
Automate.setAutomateList(solutionList);
Automate.actualPosition = 0;
Automate.AutomatePlaying = true;
////Automate the list
//Automate.shuffleDone = false;
//Automate.setAutomateList(new List<string> { "F" } );
print("Count: " + solutionList.Count);
Automate.setAutomateList(solutionList);
Automate.actualPosition = 0;
Automate.AutomatePlaying = true;
print(solution);
}
else
{
errorMsgBox.text = "Cube is not solvable!";
}
print(solution);
}
else
{
......@@ -64,6 +73,28 @@ public class SolveTwoFace : MonoBehaviour
}
private bool isCubeSolvable()
{
//get the state of the cube as a string
string moveString = cubeState.GetStateString(true);
print(moveString);
////solve the cube
string info = "";
////first time build the tables
string solution = Search.solution(moveString, out info);
if (solution.Length > 0 && solution[0] == 'E')
{
return false;
}
else
{
return true;
}
}
public void SolveKociemba()
{
if (!CubeState.autoRotating)
......
......@@ -23,8 +23,11 @@ public class Solver
public string Solve()
{
CreateCubeMatrix();
finalMoves += "1 ";
SolveOneFace();
finalMoves += "2 ";
SolveSecondRow();
finalMoves += "3 ";
SolveThirdRow();
return finalMoves;
//return "";
......@@ -86,6 +89,7 @@ public class Solver
}
RotateCorners();
finalMoves += "4 ";
SolveDownMiddles();
}
......
......@@ -8,8 +8,15 @@ cieľov projektu.
profesionálny. Keď užívateľ drží po prvýkrát tento hlavolam v rukách, väčšinou sa zasekne
po dokončení jednej zo strán. Preto existuje mnoho spísaných algoritmov, ktoré slúžia ako pomoc
začiatočníckym riešiteľom. V tejto kapitole si ukážeme jednoduché spôsoby rišenia, ale aj tie pokročilejšie.
\subsection{Twistlewaitov algoritmnus}
Tento algoritmus vytvoril matematik Morgen B.Thistlethwaite. Spôsob, akým rieši daný problém patrí
k pokročilejším. Hlavnou myšlienkou je rozdelenie jednotlivých malých kociek do skupín podľa pozície
z ktorej môžu byť umiestnené na svoje miesto vďaka určitej množiny ťahov.
Spomínané skupiny
\subsection{Kociemba}
Jeden z najznámejších algoritmov na skladanie Rubikovej kocky je Kociemba.
Svoje meno získal po svojom tvorcovi menom Herbert Kociemba. Existuje podobnosť
medzi ním a Thistlewaiteovým 52-pohybovým algoritmom.
\subsection{Začiatočnícky spôsob riešenia}
Aby sme vysvetlili začiatočníkom, ako poskladať tento hlavolam, musíme postupovať po jednotlivých krokoch.
......
......@@ -40,6 +40,7 @@ s názvom SceneLoader.
tabuľu, ten je vycentrovaný na stred a zarovnaný, aby pokrýval celú časť plátna.
\subsection{Návod pre užívateľov}
\subsection{Prostredie}
Užívateľské prostredie sme sa snažili ladiť do tmavých farieb. Jedným z hlavných
......
......@@ -80,15 +80,15 @@
</rdf:Description>
<rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/">
<xmp:CreatorTool>LaTeX with hyperref</xmp:CreatorTool>
<xmp:ModifyDate>2021-07-18T03:34:54+02:00</xmp:ModifyDate>
<xmp:CreateDate>2021-07-18T03:34:54+02:00</xmp:CreateDate>
<xmp:MetadataDate>2021-07-18T03:34:54+02:00</xmp:MetadataDate>
<xmp:ModifyDate>2021-07-18T20:25:50+02:00</xmp:ModifyDate>
<xmp:CreateDate>2021-07-18T20:25:50+02:00</xmp:CreateDate>
<xmp:MetadataDate>2021-07-18T20:25:50+02:00</xmp:MetadataDate>
</rdf:Description>
<rdf:Description rdf:about="" xmlns:xmpRights = "http://ns.adobe.com/xap/1.0/rights/">
</rdf:Description>
<rdf:Description rdf:about="" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/">
<xmpMM:DocumentID>uuid:E471EDA9-0143-B4EC-2929-27CBFE26697B</xmpMM:DocumentID>
<xmpMM:InstanceID>uuid:D7554128-F263-C950-7D87-BFF3A5928CDC</xmpMM:InstanceID>
<xmpMM:InstanceID>uuid:52A3BF42-06C7-66CA-73A1-12CA621F676C</xmpMM:InstanceID>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
......
No preview for this file type
No preview for this file type
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment