The Wiki for Tale 7 is in read-only mode and is available for archival and reference purposes only. Please visit the current Tale 11 Wiki in the meantime.
If you have any issues with this Wiki, please post in #wiki-editing on Discord or contact Brad in-game.
Guides/Mining/HelperTool
This is a helper tool to help find valid workloads for mining. Currently it only supports finding "All Same or All Different" workloads. Please read the comments in the file for help and usage information. Happy mining!
<nowiki>
- !/usr/bin/env python3.5
- Author: Lisanna
- Version: 0.1
- Date: 2016-02-27
- Copyright 2016
- You are free to use, modify, and redistribute this software, as long as you
- maintain the above accreditation. This software is provided without warranty
- and without guarantee. If your computer catches fire because of running this,
- don't blame me!
- This is a mining helper tool for ATITD. It uses set theory to determine all
- the valid workloads for a given haul of ore stones. Currently it only supports
- the "All Same or All Different" characteristic rule, but this will be expanded
- whenever I get around to actually needing to mine some ore that uses a
- different rule :p
- Note that this requires Python 3. In my environment the python binary is
- python3.5, but it may be different on your system.
- To adjust the minimum group size that it will return, edit the second
- parameter to find_workloads() on line 63. By default it's set to 3, but you
- can, e.g., lower it for ores that don't need a minimum.
- TO USE THE SOFTWARE: supply each ore stone as a command-line argument, with
- each characteristic of the ore stone separated by a comma. You can make up
- what these characteristics are, depending on how you view the world, just as
- long as the same text is used for identicial characteristics in the game.
- Here's an example for silver mining:
- ./atitd_mining_asad.py blob,cyan,pink brick,cyan,pink 3stone,green,purple
- 3stone,green,cyan smoosh,purple,cyan 3stone,purple,purple 3stone,yellow,purple
- 3stone,purple,green 3stone,cyan,purple 3stone,grey,pink
- Note that I just made all those labels up, you can use anything to describe
- the characteristic so long as it doesn't contain a comma or a space ^^
import itertools import sys
class OreStone:
def __init__(self, attributes):
self.attributes = attributes
def __str__(self): return ",".join([str(x) for x in self.attributes])
def check_if_valid(workload, nattributes):
if len(workload) >= 3:
nuniqueattributes = [len(set([x.attributes[y] for x in workload])) for y in range(nattributes)]
for n in nuniqueattributes:
if n != len(workload) and n != 1:
return False
return True
else:
return False
def set_to_string(s):
return "{" + ", ".join(["(" + str(x) + ")" for x in s]) + "}"
def find_workloads(ore_stones, min_size, nattributes):
subsets = [set(itertools.combinations(ore_stones, x)) for x in range(len(ore_stones), min_size - 1, -1)]
# print(subsets)
workloads = []
for subset in subsets:
for candidate in subset:
if check_if_valid(candidate, nattributes):
workloads.append(candidate)
# print(workloads)
workloads.sort(key=len, reverse=True)
for w in workloads:
print(set_to_string(w))
if __name__ == "__main__":
ore_stones = set()
for x in sys.argv[1:]:
ore_stones.add(OreStone(x.split(',')))
find_workloads(ore_stones, 3, len(list(ore_stones)[0].attributes))