-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRemixCC.cs
85 lines (77 loc) · 2.68 KB
/
RemixCC.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.IO;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Mime;
using System.Threading.Tasks;
using SeedFinding.Bundles1_6;
using SeedFinding.Cart;
using SeedFinding.Locations;
using SeedFinding.Trash;
using System.Numerics;
namespace SeedFinding
{
public class RemixCC
{
public static BigInteger requiredBundles = (
CompressedFlags.CRAFTS_FOREST |
CompressedFlags.CRAFTS_WILD_MEDICINE |
CompressedFlags.PANTRY_GARDEN |
CompressedFlags.PANTRY_RARE |
CompressedFlags.PANTRY_BREWER |
CompressedFlags.BULLETIN_FORAGER
);
public static BigInteger KillerBundles = (
CompressedFlags.BULLETIN_CHEF |
CompressedFlags.BULLETIN_ENCHANTER |
CompressedFlags.BULLETIN_HOME_COOK |
CompressedFlags.BULLETIN_DYE_DUCK_FEATHER
);
static bool ValidSeed(int gameId, bool curate)
{
var bundles = RemixedBundles.Generate(gameId);
if (bundles.Contains(KillerBundles))
{
return false;
}
if(!bundles.Satisfies(requiredBundles))
{
return false;
}
if (curate)
{
var bundle = string.Join(", \n", bundles.Curate().ToArray());
Console.WriteLine($"Seed: {gameId}{Environment.NewLine}Bundle Flags:{Environment.NewLine}{bundle}");
}
return true;
}
// parallel search
public static double Search(int numSeeds, int blockSize, out List<int> validSeeds, bool curate)
{
Stopwatch stopwatch = Stopwatch.StartNew();
var bag = new ConcurrentBag<int>();
var partioner = Partitioner.Create(0, numSeeds, blockSize);
Parallel.ForEach(partioner, (range, loopState) =>
{
for (int seed = range.Item1; seed < range.Item2; seed++)
{
if (ValidSeed(seed, curate))
{
bag.Add(seed);
if (!curate)
{
Console.WriteLine(seed);
}
}
}
});
double seconds = stopwatch.Elapsed.TotalSeconds;
Console.WriteLine($"Found: {bag.Count} sols in {seconds.ToString("F2")} s");
validSeeds = bag.ToList();
validSeeds.Sort();
return seconds;
}
}
}