rename references
This commit is contained in:
6
references/Minesweeper2/Bulk Runner/App.config
Normal file
6
references/Minesweeper2/Bulk Runner/App.config
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
84
references/Minesweeper2/Bulk Runner/Bulk Runner.csproj
Normal file
84
references/Minesweeper2/Bulk Runner/Bulk Runner.csproj
Normal file
@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{B19C6960-EC27-4425-BFB5-E7AA65D69C28}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Bulk_Runner</RootNamespace>
|
||||
<AssemblyName>Bulk Runner</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BulkRunner.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 and x64%29</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<Import Project="..\MinesweeperGame\MinesweeperGame.projitems" Label="Shared" />
|
||||
<Import Project="..\MinesweeperSolver\MinesweeperSolver.projitems" Label="Shared" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
158
references/Minesweeper2/Bulk Runner/BulkRunner.cs
Normal file
158
references/Minesweeper2/Bulk Runner/BulkRunner.cs
Normal file
@ -0,0 +1,158 @@
|
||||
using MinesweeperControl;
|
||||
using MinesweeperSolver;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
using static MinesweeperControl.GameDescription;
|
||||
using static MinesweeperControl.MinesweeperGame;
|
||||
|
||||
namespace Bulk_Runner {
|
||||
class BulkRunner {
|
||||
|
||||
private static readonly bool pauseOnWin = false;
|
||||
private static readonly bool playUntilWin = false;
|
||||
private static GameAction[] firstPlay;
|
||||
|
||||
private static int[] deathTable = new int[50];
|
||||
|
||||
static void Main(string[] args) {
|
||||
|
||||
GameDescription description = GameDescription.EXPERT_SAFE;
|
||||
//GameDescription description = new GameDescription(30, 24, 225, GameType.Safe);
|
||||
//GameDescription description = new GameDescription(100, 100, 1500, GameType.Zero);
|
||||
//GameDescription description = new GameDescription(50, 50, 500, GameType.Safe);
|
||||
//GameDescription description = new GameDescription(8, 8, 34, GameType.Safe);
|
||||
|
||||
if (description.gameType == GameType.Zero) {
|
||||
firstPlay = new GameAction[] { new GameAction(3, 3, ActionType.Clear) };
|
||||
} else {
|
||||
firstPlay = new GameAction[] { new GameAction(0, 0, ActionType.Clear) };
|
||||
}
|
||||
|
||||
int seedGen = new Random().Next();
|
||||
//int seedGen = 1104105816;
|
||||
|
||||
Random rng = new Random(seedGen);
|
||||
|
||||
int run = 100000;
|
||||
int steps = 100;
|
||||
|
||||
int won = 0;
|
||||
int lost = 0;
|
||||
int deaths = 0;
|
||||
|
||||
SolverMain.Initialise();
|
||||
|
||||
Write("using generation seed " + seedGen + " to run " + run + " games of minesweeper " + description.AsText());
|
||||
Write("--- Press Enter to start ---");
|
||||
|
||||
Console.ReadLine();
|
||||
|
||||
long start = DateTime.Now.Ticks;
|
||||
|
||||
for (int i=0; i < run; i++) {
|
||||
|
||||
int seed = rng.Next();
|
||||
|
||||
MinesweeperGame game = new MinesweeperGame(description, seed, !playUntilWin);
|
||||
|
||||
//Write("Seed " + game.seed + " starting");
|
||||
|
||||
GameStatus status = AutoPlayRunner(game);
|
||||
|
||||
int died = game.GetDeaths();
|
||||
if (died < deathTable.Length) {
|
||||
deathTable[died]++;
|
||||
} else {
|
||||
deathTable[deathTable.Length - 1]++;
|
||||
}
|
||||
|
||||
|
||||
deaths = deaths + died;
|
||||
|
||||
if (status == GameStatus.Lost) {
|
||||
lost++;
|
||||
} else if (status == GameStatus.Won) {
|
||||
won++;
|
||||
if (pauseOnWin) {
|
||||
Write("Seed " + game.seed + " won");
|
||||
Write("--- Press Enter to continue ---");
|
||||
Console.ReadLine();
|
||||
}
|
||||
} else {
|
||||
Write("Seed " + game.seed + " : Unexpected game status from autoplay " + status);
|
||||
}
|
||||
|
||||
if ((i + 1) % steps == 0) {
|
||||
Write("Seed " + game.seed + " finished. Games won " + won + " out of " + (i + 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
long duration = (DateTime.Now.Ticks - start ) / 10000;
|
||||
|
||||
|
||||
Write("Games won " + won + ", lost " + lost + " out of " + run + " in " + duration + " milliseconds.");
|
||||
|
||||
double winRate = (won * 10000 / run) / 100d;
|
||||
|
||||
Write("Win rate " + winRate + "%");
|
||||
|
||||
Write("Deaths " + deaths + " average deaths per game " + (deaths * 1000 / run) / 1000d);
|
||||
|
||||
for (int i=0; i < deathTable.Length - 1; i++) {
|
||||
Write("Died " + i + " times in " + deathTable[i] + " games");
|
||||
}
|
||||
Write("Died >=" + (deathTable.Length - 1) + " times in " + deathTable[deathTable.Length - 1] + " games");
|
||||
|
||||
Console.ReadLine();
|
||||
|
||||
|
||||
}
|
||||
|
||||
// this method runs on a different thread. gameNumber can be changed by clicking chosing a new game from the UI thread.
|
||||
private static GameStatus AutoPlayRunner(MinesweeperGame game) {
|
||||
|
||||
//long start = DateTime.Now.Ticks;
|
||||
|
||||
SolverActionHeader solverActions;
|
||||
|
||||
GameResult result = game.ProcessActions(firstPlay);
|
||||
|
||||
SolverInfo solverInfo = new SolverInfo(game.description);
|
||||
|
||||
while (result.status == GameStatus.InPlay) {
|
||||
|
||||
solverInfo.AddInformation(result); // let the solver know what has happened
|
||||
|
||||
solverActions = SolverMain.FindActions(solverInfo); // pass the solver info into the solver and see what it comes up with
|
||||
|
||||
if (solverActions.solverActions.Count == 0) {
|
||||
Write("No actions returned by the solver!!");
|
||||
break;
|
||||
}
|
||||
|
||||
result = game.ProcessActions(solverActions.solverActions);
|
||||
|
||||
//Write("Game controller returned " + result.actionResults.Count + " results from this action");
|
||||
|
||||
//foreach (SolverAction action in solverActions) {
|
||||
// Write("Playing " + action.AsText() + " probability " + action.safeProbability);
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
//long end = DateTime.Now.Ticks;
|
||||
|
||||
//Write("game took " + (end - start) + " ticks");
|
||||
|
||||
|
||||
return result.status;
|
||||
}
|
||||
|
||||
private static void Write(String text) {
|
||||
Console.WriteLine(text);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Bulk Runner")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Bulk Runner")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2019")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("b19c6960-ec27-4425-bfb5-e7aa65d69c28")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
Reference in New Issue
Block a user