|
3 | 3 | #include "calculator.h"
|
4 | 4 | #include "base.h"
|
5 | 5 | #include "FTPManagement.h"
|
| 6 | +#include "node_print.h" |
6 | 7 | #include "recipes.h"
|
7 | 8 | #include "start.h"
|
8 | 9 | #include "shutdown.h"
|
@@ -1573,285 +1574,6 @@ void popAllButFirstLegalMove(struct BranchPath *node) {
|
1573 | 1574 | }
|
1574 | 1575 | }
|
1575 | 1576 |
|
1576 |
| -/*------------------------------------------------------------------- |
1577 |
| - * Function : printCh5Data |
1578 |
| - * Inputs : BranchPath *curNode |
1579 |
| - * MoveDescription desc |
1580 |
| - * FILE *fp |
1581 |
| - * |
1582 |
| - * Print to a txt file the data which pertains to Chapter 5 evaluation |
1583 |
| - * (where to place Dried Bouquet, Coconut, etc.) |
1584 |
| - -------------------------------------------------------------------*/ |
1585 |
| -void printCh5Data(const BranchPath *curNode, const MoveDescription desc, FILE *fp) { |
1586 |
| - const CH5 *ch5Data = desc.data; |
1587 |
| - |
1588 |
| - // Determine how many nulls there are when allocations start |
1589 |
| - int nulls = curNode->prev->inventory.nulls; |
1590 |
| - if (indexOfItemInInventory(curNode->prev->inventory, Mousse_Cake) < 10) { |
1591 |
| - ++nulls; |
1592 |
| - } |
1593 |
| - |
1594 |
| - fprintf(fp, "Ch.5 Break: "); |
1595 |
| - if (nulls) { |
1596 |
| - fprintf(fp, "DB filling null, "); |
1597 |
| - --nulls; |
1598 |
| - } |
1599 |
| - else { |
1600 |
| - fprintf(fp, "DB replacing #%d, ", ch5Data->indexDriedBouquet + 1); |
1601 |
| - } |
1602 |
| - |
1603 |
| - if (nulls) { |
1604 |
| - fprintf(fp, "CO filling null, "); |
1605 |
| - --nulls; |
1606 |
| - } |
1607 |
| - else { |
1608 |
| - fprintf(fp, "CO replacing #%d, ", ch5Data->indexCoconut + 1); |
1609 |
| - } |
1610 |
| - if (ch5Data->lateSort) { |
1611 |
| - if (nulls) { |
1612 |
| - fprintf(fp, "KM filling null, "); |
1613 |
| - } |
1614 |
| - else { |
1615 |
| - fprintf(fp, "KM replacing #%d, ", ch5Data->indexKeelMango + 1); |
1616 |
| - } |
1617 |
| - printCh5Sort(ch5Data, fp); |
1618 |
| - } |
1619 |
| - else { |
1620 |
| - printCh5Sort(ch5Data, fp); |
1621 |
| - fprintf(fp, "KM replacing #%d, ", ch5Data->indexKeelMango + 1); |
1622 |
| - } |
1623 |
| - fprintf(fp, "CS replacing #%d, use TR in #%d", |
1624 |
| - ch5Data->indexCourageShell + 1, ch5Data->indexThunderRage + 1); |
1625 |
| -} |
1626 |
| - |
1627 |
| -/*------------------------------------------------------------------- |
1628 |
| - * Function : printCh5Sort |
1629 |
| - * Inputs : CH5 *ch5Data |
1630 |
| - * FILE *fp |
1631 |
| - * |
1632 |
| - * Print to a txt file the data which pertains to Chapter 5 sorting |
1633 |
| - -------------------------------------------------------------------*/ |
1634 |
| -void printCh5Sort(const CH5 *ch5Data, FILE *fp) { |
1635 |
| - fprintf(fp, "sort "); |
1636 |
| - switch (ch5Data->ch5Sort) { |
1637 |
| - case ESort_Alpha_Asc: |
1638 |
| - fprintf(fp, "(Alpha), "); |
1639 |
| - break; |
1640 |
| - case ESort_Alpha_Des: |
1641 |
| - fprintf(fp, "(Reverse-Alpha), "); |
1642 |
| - break; |
1643 |
| - case ESort_Type_Asc: |
1644 |
| - fprintf(fp, "(Type), "); |
1645 |
| - break; |
1646 |
| - case ESort_Type_Des: |
1647 |
| - fprintf(fp, "(Reverse-Type), "); |
1648 |
| - break; |
1649 |
| - default: |
1650 |
| - fprintf(fp, "ERROR IN CH5SORT SWITCH CASE"); |
1651 |
| - }; |
1652 |
| -} |
1653 |
| - |
1654 |
| -/*------------------------------------------------------------------- |
1655 |
| - * Function : printCookData |
1656 |
| - * Inputs : BranchPath *curNode |
1657 |
| - * MoveDescription desc |
1658 |
| - * FILE *fp |
1659 |
| - * |
1660 |
| - * Print to a txt file the data which pertains to cooking a recipe, |
1661 |
| - * which includes what items were used and what happens to the output. |
1662 |
| - -------------------------------------------------------------------*/ |
1663 |
| -void printCookData(const BranchPath *curNode, const MoveDescription desc, FILE *fp) { |
1664 |
| - Cook *cookData = desc.data; |
1665 |
| - int nulls = curNode->prev->inventory.nulls; |
1666 |
| - fprintf(fp, "Use [%s] in slot %d ", getItemName(cookData->item1), |
1667 |
| - cookData->itemIndex1 - (cookData->itemIndex1 < 10 ? nulls : 0) + 1); |
1668 |
| - |
1669 |
| - if (cookData->numItems == 2) { |
1670 |
| - fprintf(fp, "and [%s] in slot %d ", getItemName(cookData->item2), |
1671 |
| - cookData->itemIndex2 - (cookData->itemIndex2 < 10 ? nulls : 0) + 1); |
1672 |
| - } |
1673 |
| - |
1674 |
| - fputs("to make ", fp); |
1675 |
| - |
1676 |
| - if (cookData->handleOutput == Toss) { |
1677 |
| - fputs("(and toss) ", fp); |
1678 |
| - } |
1679 |
| - else if (cookData->handleOutput == Autoplace) { |
1680 |
| - fputs("(and auto-place) ", fp); |
1681 |
| - } |
1682 |
| - |
1683 |
| - fprintf(fp, "<%s>", getItemName(cookData->output)); |
1684 |
| - |
1685 |
| - if (cookData->handleOutput == TossOther) { |
1686 |
| - fprintf(fp, ", toss [%s] in slot %d", getItemName(cookData->toss), cookData->indexToss + 1); |
1687 |
| - } |
1688 |
| - |
1689 |
| - if (curNode->numOutputsCreated == NUM_RECIPES) { |
1690 |
| - if (((Cook *) curNode->description.data)->handleOutput == Autoplace) { |
1691 |
| - fputs(" (No-Toss 5 Frame Penalty for Jump Storage)", fp); |
1692 |
| - } |
1693 |
| - else { |
1694 |
| - fputs(" (Jump Storage on Tossed Item)", fp); |
1695 |
| - } |
1696 |
| - } |
1697 |
| -} |
1698 |
| - |
1699 |
| -/*------------------------------------------------------------------- |
1700 |
| - * Function : printFileHeader |
1701 |
| - * Inputs : FILE *fp |
1702 |
| - * |
1703 |
| - * Print to a txt file the header information for the file. |
1704 |
| - -------------------------------------------------------------------*/ |
1705 |
| -void printFileHeader(FILE *fp) { |
1706 |
| - fputs("Description\tFrames Taken\tTotal Frames", fp); |
1707 |
| - for (int i = 0; i < 20; i++) { |
1708 |
| - fprintf(fp, "\tSlot #%d", i+1); |
1709 |
| - } |
1710 |
| - for (int i = 0; i < NUM_RECIPES; i++) { |
1711 |
| - fprintf(fp, "\t%s", getItemName(recipeList[i].output)); |
1712 |
| - } |
1713 |
| - fprintf(fp, "\n"); |
1714 |
| - recipeLog(5, "Calculator", "File", "Write", "Header for new output written"); |
1715 |
| -} |
1716 |
| - |
1717 |
| -/*------------------------------------------------------------------- |
1718 |
| - * Function : printInventoryData |
1719 |
| - * Inputs : BranchPath *curNode |
1720 |
| - * FILE *fp |
1721 |
| - * |
1722 |
| - * Print to a txt file the header information for the file. |
1723 |
| - -------------------------------------------------------------------*/ |
1724 |
| -void printInventoryData(const BranchPath *curNode, FILE *fp) { |
1725 |
| - int nulls = curNode->inventory.nulls; |
1726 |
| - int i; |
1727 |
| - for (i = nulls; i < 10; ++i) { |
1728 |
| - fprintf(fp, "\t%s", getItemName(curNode->inventory.inventory[i])); |
1729 |
| - } |
1730 |
| - for (i = 0; i < nulls; ++i) { |
1731 |
| - fprintf(fp, "\tNULL"); |
1732 |
| - } |
1733 |
| - for (i = 10; i < curNode->inventory.length - nulls; ++i) { |
1734 |
| - fprintf(fp, "\t%s", getItemName(curNode->inventory.inventory[i])); |
1735 |
| - } |
1736 |
| - for (; i < curNode->inventory.length; ++i) { |
1737 |
| - fprintf(fp, "\t(%s)", getItemName(curNode->inventory.inventory[i])); |
1738 |
| - } |
1739 |
| - for (; i < 20; ++i) { |
1740 |
| - fprintf(fp, "\tBLOCKED"); |
1741 |
| - } |
1742 |
| -} |
1743 |
| - |
1744 |
| -/*------------------------------------------------------------------- |
1745 |
| - * Function : printOutputsCreated |
1746 |
| - * Inputs : BranchPath *curNode |
1747 |
| - * FILE *fp |
1748 |
| - * |
1749 |
| - * Print to a txt file data pertaining to which recipes |
1750 |
| - * have been cooked thus far. |
1751 |
| - -------------------------------------------------------------------*/ |
1752 |
| -void printOutputsCreated(const BranchPath *curNode, FILE *fp) { |
1753 |
| - for (int i = 0; i < NUM_RECIPES; i++) { |
1754 |
| - if (curNode->outputCreated[i]) { |
1755 |
| - fprintf(fp, "\tTrue"); |
1756 |
| - } |
1757 |
| - else { |
1758 |
| - fprintf(fp, "\tFalse"); |
1759 |
| - } |
1760 |
| - } |
1761 |
| -} |
1762 |
| - |
1763 |
| -void printNodeDescription(const BranchPath * curNode, FILE * fp) |
1764 |
| -{ |
1765 |
| - MoveDescription desc = curNode->description; |
1766 |
| - enum Action curNodeAction = desc.action; |
1767 |
| - switch (curNodeAction) { |
1768 |
| - case ECook: |
1769 |
| - printCookData(curNode, desc, fp); |
1770 |
| - break; |
1771 |
| - case ECh5: |
1772 |
| - printCh5Data(curNode, desc, fp); |
1773 |
| - break; |
1774 |
| - case EBegin: |
1775 |
| - fputs("Begin", fp); |
1776 |
| - break; |
1777 |
| - default: |
1778 |
| - // Some type of sorting |
1779 |
| - printSortData(fp, curNodeAction); |
1780 |
| - } |
1781 |
| -} |
1782 |
| - |
1783 |
| -/*------------------------------------------------------------------- |
1784 |
| - * Function : printResults |
1785 |
| - * Inputs : char *filename |
1786 |
| - * BranchPath *path |
1787 |
| - * |
1788 |
| - * Parent function for children print functions. This parent function |
1789 |
| - * is called when a roadmap has been found which beats the current |
1790 |
| - * local record. |
1791 |
| - -------------------------------------------------------------------*/ |
1792 |
| -void printResults(const char *filename, const BranchPath *path) { |
1793 |
| - FILE *fp = fopen(filename, "w"); |
1794 |
| - if (fp == NULL) { |
1795 |
| - printf("Could not locate %s... This is a bug.\n", filename); |
1796 |
| - printf("Press ENTER to exit.\n"); |
1797 |
| - awaitKeyFromUser(); |
1798 |
| - exit(1); |
1799 |
| - } |
1800 |
| - // Write header information |
1801 |
| - printFileHeader(fp); |
1802 |
| - |
1803 |
| - // Print data information |
1804 |
| - const BranchPath *curNode = path; |
1805 |
| - do { |
1806 |
| - printNodeDescription(curNode, fp); |
1807 |
| - |
1808 |
| - // Print out frames taken |
1809 |
| - fprintf(fp, "\t%d", curNode->description.framesTaken); |
1810 |
| - // Print out total frames taken |
1811 |
| - fprintf(fp, "\t%d", curNode->description.totalFramesTaken); |
1812 |
| - |
1813 |
| - // Print out inventory |
1814 |
| - printInventoryData(curNode, fp); |
1815 |
| - |
1816 |
| - // Print out whether or not all 58 items were created |
1817 |
| - printOutputsCreated(curNode, fp); |
1818 |
| - |
1819 |
| - // Add newline character to put next node on new line |
1820 |
| - fprintf(fp, "\n"); |
1821 |
| - } while ((curNode = curNode->next) != NULL); |
1822 |
| - |
1823 |
| - fclose(fp); |
1824 |
| - |
1825 |
| - recipeLog(5, "Calculator", "File", "Write", "Data for roadmap written."); |
1826 |
| -} |
1827 |
| - |
1828 |
| -/*------------------------------------------------------------------- |
1829 |
| - * Function : printSortData |
1830 |
| - * Inputs : FILE *fp |
1831 |
| - * enum Action curNodeAction |
1832 |
| - * |
1833 |
| - * Print to a file data which pertains to sorting the inventory. |
1834 |
| - -------------------------------------------------------------------*/ |
1835 |
| -void printSortData(FILE *fp, enum Action curNodeAction) { |
1836 |
| - fprintf(fp, "Sort - "); |
1837 |
| - switch (curNodeAction) { |
1838 |
| - case ESort_Alpha_Asc: |
1839 |
| - fputs("Alphabetical", fp); |
1840 |
| - break; |
1841 |
| - case ESort_Alpha_Des: |
1842 |
| - fputs("Reverse Alphabetical", fp); |
1843 |
| - break; |
1844 |
| - case ESort_Type_Asc: |
1845 |
| - fputs("Type", fp); |
1846 |
| - break; |
1847 |
| - case ESort_Type_Des: |
1848 |
| - fputs("Reverse Type", fp); |
1849 |
| - break; |
1850 |
| - default: |
1851 |
| - fputs("ERROR IN HANDLING OF SORT", fp); |
1852 |
| - }; |
1853 |
| -} |
1854 |
| - |
1855 | 1577 | /*-------------------------------------------------------------------
|
1856 | 1578 | * Function : reallocateRecipes
|
1857 | 1579 | * Inputs : BranchPath *newRoot
|
|
0 commit comments