Merged First and NextCoor

This commit is contained in:
c-weidinger 2017-12-03 20:12:32 +01:00
parent e12550274b
commit 3ddb217f6d
8 changed files with 168 additions and 76 deletions

BIN
.DS_Store vendored

Binary file not shown.

BIN
Legacy/.DS_Store vendored Normal file

Binary file not shown.

BIN
Source/.DS_Store vendored

Binary file not shown.

View File

@ -22,21 +22,64 @@
</component> </component>
<component name="FileEditorManager"> <component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300"> <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="classExtension.cpp" pinned="false" current-in-tab="false"> <file leaf-file-name="main.cpp" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/functions/solve/classExtension.cpp"> <entry file="file://$PROJECT_DIR$/main.cpp">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="4080"> <state relative-caret-position="255">
<caret line="240" column="15" lean-forward="false" selection-start-line="240" selection-start-column="15" selection-end-line="240" selection-end-column="15" /> <caret line="15" column="43" lean-forward="true" selection-start-line="15" selection-start-column="43" selection-end-line="15" selection-end-column="43" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="main.cpp" pinned="false" current-in-tab="true"> <file leaf-file-name="structure.cpp" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/main.cpp"> <entry file="file://$PROJECT_DIR$/functions/solve/structure.cpp">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="170"> <state relative-caret-position="-231">
<caret line="23" column="35" lean-forward="false" selection-start-line="23" selection-start-column="35" selection-end-line="23" selection-end-column="35" /> <caret line="51" column="5" lean-forward="true" selection-start-line="51" selection-start-column="5" selection-end-line="51" selection-end-column="5" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="solve.h" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/header/solve.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2533">
<caret line="149" column="5" lean-forward="true" selection-start-line="149" selection-start-column="5" selection-end-line="149" selection-end-column="5" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="input.h" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/header/input.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="17">
<caret line="1" column="0" lean-forward="false" selection-start-line="1" selection-start-column="0" selection-end-line="1" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="header.h" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/header.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="323">
<caret line="19" column="0" lean-forward="false" selection-start-line="19" selection-start-column="0" selection-end-line="19" selection-end-column="0" />
<folding>
<element signature="e#0#19#0" expanded="true" />
<element signature="e#139#164#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="classExtension.cpp" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/functions/solve/classExtension.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="813">
<caret line="193" column="40" lean-forward="false" selection-start-line="193" selection-start-column="40" selection-end-line="193" selection-end-column="40" />
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -56,8 +99,9 @@
<option name="CHANGED_PATHS"> <option name="CHANGED_PATHS">
<list> <list>
<option value="$PROJECT_DIR$/CMakeLists.txt" /> <option value="$PROJECT_DIR$/CMakeLists.txt" />
<option value="$PROJECT_DIR$/header/solve.h" />
<option value="$PROJECT_DIR$/functions/solve/classExtension.cpp" /> <option value="$PROJECT_DIR$/functions/solve/classExtension.cpp" />
<option value="$PROJECT_DIR$/header/solve.h" />
<option value="$PROJECT_DIR$/functions/solve/structure.cpp" />
<option value="$PROJECT_DIR$/main.cpp" /> <option value="$PROJECT_DIR$/main.cpp" />
</list> </list>
</option> </option>
@ -68,8 +112,10 @@
<detection-done>true</detection-done> <detection-done>true</detection-done>
<sorting>DEFINITION_ORDER</sorting> <sorting>DEFINITION_ORDER</sorting>
</component> </component>
<component name="OCFindUsagesOptions" text="false" ivars="false" properties="true" derivedClasses="false" />
<component name="ProjectFrameBounds" extendedState="6"> <component name="ProjectFrameBounds" extendedState="6">
<option name="y" value="23" /> <option name="x" value="1680" />
<option name="y" value="32" />
<option name="width" value="1680" /> <option name="width" value="1680" />
<option name="height" value="974" /> <option name="height" value="974" />
</component> </component>
@ -183,26 +229,31 @@
<workItem from="1512294822347" duration="171000" /> <workItem from="1512294822347" duration="171000" />
<workItem from="1512295013657" duration="158000" /> <workItem from="1512295013657" duration="158000" />
<workItem from="1512295189973" duration="19000" /> <workItem from="1512295189973" duration="19000" />
<workItem from="1512295394558" duration="1095000" />
<workItem from="1512297422046" duration="543000" />
<workItem from="1512304707314" duration="2085000" />
<workItem from="1512306922542" duration="1827000" />
<workItem from="1512316653068" duration="5261000" />
</task> </task>
<servers /> <servers />
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="3421000" /> <option name="totallyTimeSpent" value="14232000" />
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="0" y="23" width="1680" height="974" extended-state="6" /> <frame x="1680" y="23" width="1920" height="1057" extended-state="6" />
<editor active="true" /> <editor active="true" />
<layout> <layout>
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.125" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" /> <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.0953125" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" /> <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.48809522" sideWeight="0.3445567" order="5" side_tool="true" content_ui="tabs" /> <window_info id="Messages" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.35885417" sideWeight="0.3445567" order="5" side_tool="true" content_ui="tabs" />
<window_info id="CMake" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32815966" sideWeight="0.5541667" order="6" side_tool="false" content_ui="tabs" /> <window_info id="CMake" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32815966" sideWeight="0.5517857" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32815966" sideWeight="0.44583333" order="7" side_tool="true" content_ui="tabs" /> <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32815966" sideWeight="0.4482143" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Run" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3577381" sideWeight="0.6554433" order="4" side_tool="true" content_ui="tabs" /> <window_info id="Run" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.35677084" sideWeight="0.6554433" order="4" side_tool="true" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" /> <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" /> <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.37461928" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" /> <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Data View" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Data View" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
@ -210,7 +261,7 @@
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" /> <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" /> <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3292683" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
</layout> </layout>
</component> </component>
@ -221,7 +272,16 @@
<option name="myLimit" value="2678400000" /> <option name="myLimit" value="2678400000" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager /> <breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
<url>file://$PROJECT_DIR$/main.cpp</url>
<line>44</line>
<option name="timeStamp" value="2" />
</line-breakpoint>
</breakpoints>
<option name="time" value="8" />
</breakpoint-manager>
<watches-manager /> <watches-manager />
</component> </component>
<component name="editorHistoryManager"> <component name="editorHistoryManager">
@ -509,6 +569,14 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$APPLICATION_HOME_DIR$/bin/cmake/share/cmake-3.9/Modules/CMakeDetermineCompilerId.cmake" />
<entry file="file://$PROJECT_DIR$/CMakeLists.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="102">
<caret line="6" column="38" lean-forward="false" selection-start-line="6" selection-start-column="38" selection-end-line="6" selection-end-column="38" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/header/output.h"> <entry file="file://$PROJECT_DIR$/header/output.h">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0"> <state relative-caret-position="0">
@ -523,54 +591,68 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/functions/solve/structure.cpp"> <entry file="file://$PROJECT_DIR$/functions/output/output.cpp">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0"> <state relative-caret-position="0">
<caret line="0" column="20" lean-forward="false" selection-start-line="0" selection-start-column="20" selection-end-line="0" selection-end-column="20" /> <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$APPLICATION_HOME_DIR$/bin/cmake/share/cmake-3.9/Modules/CMakeDetermineCompilerId.cmake" /> <entry file="file:///Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ostream">
<entry file="file://$PROJECT_DIR$/header/input.h">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="34"> <state relative-caret-position="551">
<caret line="2" column="6" lean-forward="false" selection-start-line="2" selection-start-column="6" selection-end-line="2" selection-end-column="6" /> <caret line="1079" column="0" lean-forward="false" selection-start-line="1079" selection-start-column="0" selection-end-line="1079" selection-end-column="0" />
</state> <folding />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/header.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="4" column="17" lean-forward="true" selection-start-line="4" selection-start-column="17" selection-end-line="4" selection-end-column="17" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/header/solve.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="555">
<caret line="172" column="20" lean-forward="false" selection-start-line="172" selection-start-column="20" selection-end-line="172" selection-end-column="20" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/CMakeLists.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="102">
<caret line="6" column="38" lean-forward="false" selection-start-line="6" selection-start-column="38" selection-end-line="6" selection-end-column="38" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/functions/solve/classExtension.cpp"> <entry file="file://$PROJECT_DIR$/functions/solve/classExtension.cpp">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="4080"> <state relative-caret-position="813">
<caret line="240" column="15" lean-forward="false" selection-start-line="240" selection-start-column="15" selection-end-line="240" selection-end-column="15" /> <caret line="193" column="40" lean-forward="false" selection-start-line="193" selection-start-column="40" selection-end-line="193" selection-end-column="40" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/header/input.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="17">
<caret line="1" column="0" lean-forward="false" selection-start-line="1" selection-start-column="0" selection-end-line="1" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/header.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="323">
<caret line="19" column="0" lean-forward="false" selection-start-line="19" selection-start-column="0" selection-end-line="19" selection-end-column="0" />
<folding>
<element signature="e#0#19#0" expanded="true" />
<element signature="e#139#164#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/functions/solve/structure.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-231">
<caret line="51" column="5" lean-forward="true" selection-start-line="51" selection-start-column="5" selection-end-line="51" selection-end-column="5" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/header/solve.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2533">
<caret line="149" column="5" lean-forward="true" selection-start-line="149" selection-start-column="5" selection-end-line="149" selection-end-column="5" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/main.cpp"> <entry file="file://$PROJECT_DIR$/main.cpp">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="170"> <state relative-caret-position="255">
<caret line="23" column="35" lean-forward="false" selection-start-line="23" selection-start-column="35" selection-end-line="23" selection-end-column="35" /> <caret line="15" column="43" lean-forward="true" selection-start-line="15" selection-start-column="43" selection-end-line="15" selection-end-column="43" />
<folding /> <folding />
</state> </state>
</provider> </provider>

Binary file not shown.

Binary file not shown.

View File

@ -4,15 +4,17 @@ void status(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMa
bool next(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat) bool next(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat)
{ {
//log not yet started //log not yet started
/*
if(!(log.size())) if(!(log.size()))
{ {
log.push_back(LogEntry()); log.push_back(LogEntry());
log.back().myCoor = calculateFirstCoor(log, p_Box, puzzleMat); log.back().myCoor = calculateNextCoor(log, p_Box, puzzleMat);
solve(log, p_Box,puzzleMat); solve(log, p_Box,puzzleMat);
} }
*/
//last log element is set, create new log element //last log element is set, create new log element
else if(log.back().isSet()) if(!(log.size()) || log.back().isSet())
{ {
if(!(p_Box.size())) if(!(p_Box.size()))
{ {
@ -20,8 +22,8 @@ bool next(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat)
return 0; return 0;
} }
log.push_back(LogEntry()); log.push_back(LogEntry());
log.back().myCoor = calculateNextCoor(log, p_Box, puzzleMat); log.back().myCoor = calculateNextCoor(log, p_Box, puzzleMat);
solve(log, p_Box,puzzleMat); solve(log, p_Box,puzzleMat);
} }
//last log element is empty, backtrack //last log element is empty, backtrack
@ -35,7 +37,7 @@ bool next(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat)
if(log.back().abstractionLevel < MAX_ABSTRAX) if(log.back().abstractionLevel < MAX_ABSTRAX)
{ {
log.back().advance(); log.back().advance();
solve(log,p_Box,puzzleMat); solve(log,p_Box,puzzleMat);
} }
//no more layers, pick first //no more layers, pick first
else else
@ -47,13 +49,13 @@ bool next(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat)
//case last log exactly one solution //case last log exactly one solution
else if(log.back().PieceCollector.size() == 1) else if(log.back().PieceCollector.size() == 1)
{ {
if(log.back().hasRandomed()) if(log.back().hasRandomed())
{ {
if(log.back().abstractionLevel < MAX_ABSTRAX) if(log.back().abstractionLevel < MAX_ABSTRAX)
{ {
log.back().advance(); log.back().advance();
solve(log,p_Box,puzzleMat); solve(log,p_Box,puzzleMat);
} }
else else
setsolution(log,p_Box,puzzleMat); setsolution(log,p_Box,puzzleMat);
@ -64,20 +66,28 @@ bool next(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat)
return 1; return 1;
} }
/*
coor calculateFirstCoor(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat) coor calculateFirstCoor(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat)
{ {
//returns coor of first piece //returns coor of first piece
coor firstCoor(0,0); coor firstCoor(0,0);
return firstCoor; return firstCoor;
} }
*/
coor calculateNextCoor(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat) coor calculateNextCoor(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat)
{ {
//level 1: //level 1:
//go left to right, then increase current row //go left to right, then increase current row
if (log.size() == 1)
return coor(0,0);
int m= log.rbegin()[1].myCoor.m; int m= log.rbegin()[1].myCoor.m;
int n= log.rbegin()[1].myCoor.n; int n= log.rbegin()[1].myCoor.n;
if(m<puzzleMat.getCols()-1) m++; if(m<puzzleMat.getCols()-1) m++;
else if(n<puzzleMat.getRows()-1){ m=0; n++;} else if(n<puzzleMat.getRows()-1){ m=0; n++;}
else return coor(); else return coor();
@ -138,12 +148,12 @@ void setsolution(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puz
//remove first element in last logelement from box //remove first element in last logelement from box
for(int i=0;i<p_Box.size();) for(int i=0;i<p_Box.size();)
if(p_Box[i]==log.back().PieceCollector[0]) if(p_Box[i]==log.back().PieceCollector[0])
p_Box.erase(p_Box.begin()+i); p_Box.erase(p_Box.begin()+i);
else else
i++; i++;
//turn piece until it fits and then set element into matrix //turn piece until it fits and then set element into matrix
if(puzzleMat.testRotationPiece(log.back().myCoor.m, log.back().myCoor.n,*(log.back().PieceCollector[0]))) if(puzzleMat.testRotationPiece(log.back().myCoor.m, log.back().myCoor.n,*(log.back().PieceCollector[0])))
//error if it turned //error if it turned
puzzleMat.setPiece(log.back().myCoor.m, log.back().myCoor.n, *(log.back().PieceCollector[0])); puzzleMat.setPiece(log.back().myCoor.m, log.back().myCoor.n, *(log.back().PieceCollector[0]));
else else
@ -154,16 +164,16 @@ void setsolution(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puz
//tell log entry that it is set //tell log entry that it is set
log.back().Set(); log.back().Set();
} }
bool backtrack(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat) bool backtrack(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMat)
{ {
//following possibilities: //following possibilities:
//last log entry empty - delete last log + backtrack //last log entry empty - delete last log + backtrack
if(!(log.back().PieceCollector.size())) if(!(log.back().PieceCollector.size()))
{ {
puzzleMat.removePiece(log.back().myCoor.m, log.back().myCoor.n); puzzleMat.removePiece(log.back().myCoor.m, log.back().myCoor.n);
log.pop_back(); log.pop_back();
backtrack(log,p_Box,puzzleMat); backtrack(log,p_Box,puzzleMat);
return 1; return 1;
} }
@ -188,14 +198,14 @@ bool backtrack(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzl
//shuffleup //shuffleup
random_shuffle(p_Box.begin(),p_Box.end()); random_shuffle(p_Box.begin(),p_Box.end());
puzzleMat.removePiece(log.back().myCoor.m, log.back().myCoor.n); puzzleMat.removePiece(log.back().myCoor.m, log.back().myCoor.n);
log.pop_back(); log.pop_back();
//cout << "removed" << endl; //cout << "removed" << endl;
//status(log,p_Box,puzzleMat); //status(log,p_Box,puzzleMat);
backtrack(log,p_Box,puzzleMat); backtrack(log,p_Box,puzzleMat);
return 1; return 1;
} }
//last log entry multiple solutions (and current one was randomed) - delete randomed piece and go to next //last log entry multiple solutions (and current one was randomed) - delete randomed piece and go to next
else if((log.back().PieceCollector.size())>1) else if((log.back().PieceCollector.size())>1)
{ {
@ -216,11 +226,11 @@ bool backtrack(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzl
p_Box.push_back(log.back().PieceCollector[0]); p_Box.push_back(log.back().PieceCollector[0]);
//shuffleup //shuffleup
random_shuffle(p_Box.begin(),p_Box.end()); random_shuffle(p_Box.begin(),p_Box.end());
log.back().PieceCollector.erase(log.back().PieceCollector.begin()); log.back().PieceCollector.erase(log.back().PieceCollector.begin());
if(log.back().PieceCollector.size()==1) if(log.back().PieceCollector.size()==1)
log.back().decreaseRandomed(); log.back().decreaseRandomed();
//for abstraction layer 1 so that first rotation solution is set. //for abstraction layer 1 so that first rotation solution is set.
(*(log.back().PieceCollector[0])).resetShift(); (*(log.back().PieceCollector[0])).resetShift();
setsolution(log,p_Box,puzzleMat); setsolution(log,p_Box,puzzleMat);
@ -253,7 +263,7 @@ void status(vector<LogEntry>& log, vector<PuzzlePiece*>& p_Box, Puzzle& puzzleMa
{ {
(*(log[i].PieceCollector[j])).printPiece(); (*(log[i].PieceCollector[j])).printPiece();
cout << endl; cout << endl;
}*/ }*/
} }
cout << endl; cout << endl;

View File

@ -9,7 +9,7 @@
int main() int main()
{ {
int cols=10, rows=10; int cols=10, rows=20;
//some basic part stuff //some basic part stuff
vector<Part> myFirstPuzzle; vector<Part> myFirstPuzzle;
Part myFirstPart; Part myFirstPart;