/
Bot_610.cs
145 lines (132 loc) · 31 KB
/
Bot_610.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
namespace auto_Bot_610;
/*
--------------------------------------------------------------------------------
TinyHugeBot - by Popax21 & atpx8
--------------------------------------------------------------------------------
TinyHugeBot consists of a 1.6KLOC custom chess engine, compressed into just
about 1000 tokens. It does this by leveraging APIs provided by the
System.AppDomain class, which allows it to load compiled C# code at runtime.
The uncompressed chess engine, called HugeBot, is first compiled into a 18KB
.dll file. The .dll file is then shrank down to ~11KB using a custom .dll
compressor called BotBuilder (1.8KLOC), which strips of all unnecessary
metadata in addition to performing some other optimizations (inlining
methods, etc.). This .dll is the compressed further into about 850 `decimal`
literal tokens (100 bits per token) using a custom RLE-like encoding scheme,
and embedded into LaunchPad, which decompresses, loads and runs HugeBot.
All in all, TinyHugeBot was in active development for about one to two
months, split about evenly between developing the chess engine and the
surrounding infrastructure. Note that the everything is rule compliant -
HugeBot is loaded through the AppDomain class, which is in the allowed
System namespace, and HugeBot itself also only uses allowed APIs. Special
care was also taken to ensure that BotBuilder doesn't enable any language
features which would provide an unfair advantage, like setting the
aggressive method optimization flags, which would usually require a
(disallowed) compiler intrinsic attribute to enable. We know that we still
might be disqualified, but we had a lot of fun making this bot, and we hope
that it will at least be interesting enough to deserve a shoutout. :)
HugeBot contains a chess engine with the following features:
- a fail-soft NegaMax search inside a Iterative Deepening framework
- a 240MB Transposition Table with 25165824 available slots
- Quiescence Search (folded into the main search function)
- Principle Variation Search
- Late Move Reductions
- check extensions
- for non-PV nodes:
- Null Move Pruning
- Late Move Pruning
- (Reverse) Futility Pruning
- for Q-search nodes:
- Delta Pruning
- SEE forward pruning
- two-stage move ordering with selection sort:
- stored move from the TT (if available)
- MVV-LVA for captures, with promotions being ordered first
- for quiet moves:
- 4 slot killer table
- threat escape move check (determined by NMP earlier)
- Relative History Heuristic, including continuation / followup history
tables
- incremental evaluation function using PeSTO PST tables
Shoutouts to the following engines / resources, as they served as invaluable
references during the development of TinyHugeBot:
- STRO4K by ONE-RANDOM-HUMAN (https://github.com/ONE-RANDOM-HUMAN/STRO4K)
- an awesome engine, served as a great reference for the first drafts of
THB in addition to being a strong test opponent
- ice4 by MinusKelvin (https://github.com/MinusKelvin/ice4)
- same as STRO4K, served as a great reference for figuring out details
while also being considerably stronger than STRO4k
- LiteBlue by Sidhant-Roymoulik
(https://github.com/Sidhant-Roymoulik/Chess-Challenge)
- an open-source bot submission for this challenge, served as a great
comparison tool to check how well we were doing
- the Chess Programming Wiki (https://www.chessprogramming.org)
- the go-to source for all things chess programming, without it this bot
would have not made it far at all
- the #tas_offtopic community from the Celeste Discord - this is where this
project started, and they also helped throughout the entire development
process
Our bot is also on LiChess (2254 elo at the time of writing):
- https://lichess.org/@/TinyHugeBot
You can find our source code here (repo
will be made public after the deadline):
- https://github.com/Popax21/TinyHugeBot
Thanks for hosting this challenge, we all had a great time and are looking
forward to the final video! :)
- Popax21 & atpx8
*/
using ChessChallenge.API;
using static System.AppDomain;
class Bot_610 : IChessBot
{
//TinyBot_asmBuf either holds the TinyBot IChessBot instance, or the assembly buffer during decoding
dynamic TinyBot_asmBuf = new byte[10752];
int asmBufOff, scaleParity, asmLoadCount;
byte scaleAccum;
public Bot_610()
{
//Decode the assembly
//The assembly is encoded in a semi-RLE-like format
//There are two types of tokens:
// - scaling factors 0-15: regular tokens
// - the decimal integer number encodes 12 bytes, which are copied to the assembly buffer
// - the decimal scaling factor encodes an additional 4 bits - two regular tokens are paired up, and their scaling factors are combined to form an extra byte
// - scaling factor 16: skip tokens (can skip up to 255 bytes forward to efficiently encode a stretch of zero bytes)
// - the lowest byte of the decimal integer number contains the amount of bytes to skip forward by
// - the remaining 11 integer number bytes are copied to the assembly buffer
// - skip tokens are invisible to the scalar accumulator; they don't contribute their scale value, nor do they affect parity
// - the sign bit is unused as a minus sign would require an extra token
foreach (decimal dec in new[] {
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> BEGIN ENCODED ASSEMBLY <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
73786.976307732568653M,19807040628566.084401472995583M,31105283551.3167525259001891M,755801456384M,181921803566869775515872M,7737125245.5336267181203469M,73786978493861462528M,5077488442.3814425337660420M,41277563240262130762296328704M,7555786.3725983042899970M,1152921504606846992M,0.0000309237645936M,4657197825.4188501544480260M,9444733009719755538944M,0.0000412316868620M,3834561620.1191688348125337M,1099512204800M,944473.2966838802055477M,326431738453956854441574404M,11363902737591853555279511.4M,4722367512021.118822657M,103892062638525357493248M,2775703108121453200379215912M,576664349112622439793756663M,1084181218329891315422068736.4M,983683948207616965215104.8M,31831405518539407403756.46242M,25218622223359216663570025.09M,14551982077674247092598.948867M,149037368037562188881283778.57M,7751751374639693141003212073M,18988901930239290895055349.277M,32049240454754771.328116199258M,10841812183281778010285187483M,790263103275429213814.05722659M,240120837853411429194.37811613M,508638694409746815.64819592273M,48991190960093774542264.182366M,24013270170701829222305981107M,361256680199709077.69030791578M,63282263193841653.994459602791M,63231520512671285690372.123769M,2301580754917457.6867144592616M,23422082515176722098.742582142M,21747235661032022549925.003311M,2445438759561527482428664020.0M,31686992592949182393324022.44M,569539757322231036556.5619542M,29755749920356197552011367.180M,294377927252935746575431386.00M,75220230404142237586.59956332M,93923216182963620344006.66711M,40882797447200520285531750941M,21395871818336778433976825633M,1960940048803.267798553663600M,10179644068488869.48823371776M,26948581442749708197.500546303M,1580092045271978279652761959.9M,498327250934853690893940.0766M,37936483115589975344419359.18M,19825552752952769037972.480772M,3006030927790879471493947726.2M,84650273119214232808536.20319M,5366494984994456643465.583457M,300485032575804622043758855.99M,415138805568644369513997565.72M,3155295614416885279239839824M,7141177226411568399504707360M,20149441034585842105892278018M,14925582640157583231301398.292M,2200256873593913393041822212.5M,2048321837902115748594111236.1M,1495593956123696673501.6433454M,245608118118986161029643.76420M,2326607511236701749.5267200618M,10549291687459635880024757.299M,294655893320416335585052792.97M,3468772543847099059505446.719M,19584821448722.873665573957193M,17729224358629297768882064.953M,15583220888533616503474828.087M,5998814453654994009421.063761M,303940582129866122203003.86581M,260648048352863965557515.48198M,13450921715221516313.958630235M,1898886870643437484654.9745239M,17391872790520381944786870555M,2166415973039774953505767177M,58223614932706880517.66898961M,123794063880.7377420464161794M,12379402756447043929537610.53M,58804135997848499595.15324430M,4662826886325682337690420528M,713029170775260980170247402.4M,16214835360364735956586M,2101171493439.5272961804M,12404868171943086653139455242M,65201529442713209829742.34624M,536405108529674924883223272.8M,328330236410985598017142.35415M,309485019333567064271283.9187M,9710087442259134.415047106823M,394587319188689053881408.80905M,7121867080959.574719835694109M,78917463821743.361412502127912M,394587319120616.82245682790142M,5996722468056076384483639167M,566265576274120320925525.7105M,10268201100381581547673859M,1595914364791246979037791748M,2353295000498.9950383117568514M,5687146139787360137809957472M,1863046189355941054334372.127M,71278550786979984108300590.16M,38161154181738228.12028930M,185691009871090801770096384.0M,2496885295040459909638656.265M,12410846963598309406699753824M,30948501933370780188038.92224M,2980248652880611859555800686.0M,31182744386416096919594677.79M,248318593044024286921058099.8M,9769444365198374.93343814184M,185691009871.2033917691692546M,5377359028435743935118249491M,95023489757136.3626421195104M,34418263130628830928321930.55M,18617457627465038140.80102405M,605054291853815180189590M,4974776971381124657002315488M,30659209226480686338066M,257813040107821608090835.3807M,95067516643906245135748379.4M,12391636101075573592.125605160M,1595834599993034672613359621M,47961610890138457213440M,681008262815192686293005697.0M,767715119123258432153065.235M,2726255730866.8002883076033026M,39007200496273361268399804179M,27572042318200890744767.774720M,46629027822367145468603945.36M,46629027774690344917.76335880M,411323254187875298078906647M,30044304897160610762964865280M,29421708322356668913906028.812M,1875253483225375818.844733635M,158633846943804700909639176M,12407243577194447130814845184M,24965265865110776262678.28226M,2498878003343.224230598020140M,77468252108476540833151951.79M,34249816132369264580.24165378M,5887468741750704483764808799M,83657952304903475.19299630891M,5285504630770029349170053672M,588746874175070.6682788064351M,248318167565944712567935258.9M,156801464198795.3956403282472M,297215233269246495306110.77471M,5274625384374.892704160813920M,126136473640258949911526606.0M,5264957761779830918409.884522M,714157351631284563811428968.6M,528913107448033974273619867.9M,682927941805743461167596111.1M,179743931698960861189.21016152M,2524308261605279034251411098M,2524657827333101466898008576M,1248710368315.9274442082355714M,38517887292560380002312M,1488194802813267319.1605986634M,51124524010996484440855238M,5261245203856354466064510995M,465291480549602538012111036.14M,448263114898045607.85155M,5880415326165427869045425.156M,2937770021894602103437721604M,1953508231617.0963047992787970M,27556255133243971138588967686M,272435695592724072.24323505670M,6271358029483290.462413206M,5454904462.3666877300740M,30948503593512973808.03683585M,18799740969148620031918081M,73256643661718.54471424M,438116605975436.1539669262352M,8288323.9861710042958338M,30948503593512973808.87569665M,64417617020536938669933592580M,6649276475336762584989709M,3096059025369789980846596100M,204635204789691882640881.11894M,2793358651079202957.6880744595M,1081087430060462826191018007M,45600701125272316116373799936M,651067000154176655289949.89331M,60063629210543773775.05088360M,984673417783985800918329088.7M,1261325622676854042733711714M,8674096326739252994239300.625M,10812149342437064359445874.10M,7895740594599.8556099513484290M,9994364496760.770044861874177M,30967991574784.082494653202687M,2943660720514867090143701079.2M,40608246437759.64165199915106M,342493915100656.7767042104676M,2726252425673610406714474908.7M,15601858351954337123.877849107M,13323661588764372860.066861846M,373440288508260210123921778.2M,32301288992729775.343640842594M,45199398897768946701681518680M,32307409743857759741894.462481M,8680167738850225293639.247960M,43538052609083887673136939.69M,86801677388502252960602.14993M,323086136852377507981.59536668M,29844531683344815989.087760081M,40912770391643.798646526774545M,79055584148526.189953357909009M,69952719.939961193569535M,959887100820854100353077.4532M,19844536218442180448003035021M,2514584594266752703566712717M,12379402145297304503774740.48M,12379403309849366140826125.10M,49748337135638100259.88685838M,29477384949427218040158.832952M,188094820752799749162969.79M,2319122901129440984054432000M,5353298275260205343305696256M,49723307855430105041.38825233M,78917459743862.814483832373263M,2319122901129246291892567806M,5353298275260205343305696256M,7234207363688373865248.858385M,1880948207527997491631.4464M,78917463837675.343204434903296M,353870071.60456251965182M,52821564883506013454435658.28M,3034055944985720630944566463.9M,18809482075279974916314464M,39458731918868801561337537793M,123794017751587698708050726.3M,3934457139866975734837697307.2M,2642275549198255928569.8592639M,114521542903305.14669497745416M,789174638377378107757282.63500M,78917463837737.566765488148255M,10267999651665524115373822M,5282156488350601345443565828M,5299172844110491600581.263137M,295552116045858631905266281.13M,526608087085334515681146038.3M,78295027934456839705125195663M,10233639153093.594890748361980M,29831501327241165.787738471676M,18809482075279974933091680M,19574016621171156104128505089M,19574016064441308156595748.671M,5907214733621.260864295223103M,526608087099736647247444174.6M,136452264318915083514331186.08M,133334606300056595381747100.28M,39458731918842339726741170709M,78917463821746.139930252246911M,52879332168988.74689202355966M,2942533511826281948139513935.0M,19535122359228622370034094.357M,29477386517519526094764.204639M,526608087092533765506132.0979M,3094852968515295864569935.54M,59867096064814944165909.67116M,71375830416012943468875.00050M,133078553795334305223.26880275M,2361183.2921223207066371M,6650319860347725175912071697M,28199550246159266794776429568M,96061245637699554704254623.97M,39614081266355540834180.532827M,5907256250878296060276901395M,616656208889810825.274150443M,39002445979629147057175922287M,31158651519143934781053992.96M,218697549875329391330.6434600M,31154352505831.53411792830465M,6287990619360121401608025140.9M,249724971126311401839709978.5M,7862257858091163187947892534.0M,30948504013606054017116.40579M,46529588864274188325627005M,3424905736444727973965926916M,68135059210399983298548911.33M,124060156503581467180.98259969M,12406015650358428193074970626M,6674310182769038470903889.92M,260717086.1888233657215746M,2554779514645399434439424M,22303736898874947028310273M,309485045670617465229902080.0M,38695164569645457674.671628M,5597345747880817410713841664M,33632931143942594334036.56214M,3435767588956312031136770077.4M,7922762756099431921679505.8176M,125852097941482220767832017.7M,1275005167.479900535796287M,3094850506926938820497116177M,99908435379418.520490547M,2726254314222372095821417293.8M,3094850525370869303693021.452M,40438615889780045898760049.14M,30948499866818507.2670540817M,40754024973.7446939662483714M,2002283834613987696186378M,4642275176375160116743241734M,309485054860156092551792129M,46618588943699778.84790489362M,31635574205769613795454879234M,1393891470189731564487062323.2M,78635836086325078849290632718M,575999754129339305194.7M,78662597885470948826018087439M,32640233636433.0744684216321M,4330511012443728084877256704M,3039617023822905340753675264.0M,3806927791499909145975540895.2M,433106809741123405083.6004864M,15681187025200851332476.43649M,7124280135219451849.142968170M,38057603381016535983526744M,13487078751071889605723396M,148662457419963161053696M,36157749353585916896690.6629M,77371252455336267735772.182M,50859698125901596896.47390862M,681008220364.8532623376845314M,29829168083900.332510776724990M,117144030.62750910611725M,3422352360255588634499674113.0M,120328256852708168172.804M,9773377041018165212642738692M,872492634711528075.6927105378M,34430811208321220556751889M,34223934547738083143578027268M,33221892167783919074415448M,4655777967438876920478238980M,71258121389026219074618.67010M,787255470668605388421.94052618M,2166395290758871714502475775M,4978371560856228812481761536M,590360076999207099125320960.3M,1933868241704531522895797.1M,6323909851876102914922340096M,8495150991256330586713885184M,1986706958.0430311295683074M,34374179415805861384817152M,13936553553670808260900621066M,4348610086763070085471339272M,3558310523542049055986.1014M,1237940398637210966013.250048M,38704829653.607864822923294M,41684366347342077560455168M,39044656528702329021862404M,3311368712507.3319396293410562M,187917681171316819129474620.7M,3261127571935863565226.9150802M,152518189565881471938309M,309485602499877472542091.776M,500737078173731751544462899.2M,590817711328677998120194051.3M,78635803000374519411588934432M,681228761165109153366088910.7M,13965591940089505588844888574M,4353573678510505296788531.990M,2586561969068945257157276518.9M,3805758896085777461925683.9M,12379404171561390776295106.56M,12379405831046154064.04370442M,44169465270168.155335305528334M,534957886.251134345548287M,5282033467234497118751228975M,78788534249555621165.278264066M,3736889082414441665669442306M,27853651116109841439.66521402M,19497553529083523827052395.578M,960012274989900585875642777.7M,558425084736427528071108053.8M,98175167913548348489977.1466M,2806077744640820390312678417M,2819982914284968103719554.7954M,66016485236603406185.7722712M,235504899348558.33823215644M,96734872852471259005952M,681350592197674923419267.7890M,31262831510200320264584888830M,712305868651521905985428.4645M,20018186317792937865052760M,38069472602002730801323970049M,6339616627259557529725698067M,172274431134837634106368M,1924137203320256036062455962.0M,532191859307550919527773083.6M,154791290122068606603205099.72M,2726283572501226871855317.1471M,4743957254191833481916845908M,1649392030491951539046449.935M,78613236500926420097919037466M,9890289173715302671252188.38M,31160866728088663660272135.89M,528200483846565.3025731713027M,1300933108404748112473731968.9M,65402355574922225521374413.7M,570975664611.1986439247429890M,404508468190.1963970444724738M,109353240695217413385992M,681130070635672935.0000743469M,38885589225879643966414890M,13769665086131554771.00953600M,63610287715.8138835794856450M,1335146919840389202501331442.7M,7433703809765755315.675343881M,18569101909392870877767962.49M,1861812134820363109896.758289M,49748008972384369423264028.33M,5880229353714030891557191680M,22611833532670899608282666.514M,4330920876325169512.910422158M,26785447158300626929123341M,6830823244227188770244399626M,34983895369532649385969389054M,157821119643198116772577.28M,526130681584026006768898203.3M,7749261727401474083489.10888M,2435244.5151005017768194M,309485019333540448375708.0074M,5986709975362003.577851090773M,3094850525370882497834258.726M,11474014443240.225441174257532M,1699104031809660945950849.7M,526131153822533128055876202.3M,59274436515002250937859543.41M,157821147073364130041.13681M,52613115382622485259223099.28M,68304838121757833331348.61608M,78635875344094056940946200062M,295166351925.7527518822413M,52613068158377267925856422.40M,124048681162366059617221.39944M,3027055362266200813862933M,3094850193339908083384450561M,235329500049899416468480.36350M,43497956202368595614060.52887M,497354915609521457197488.6916M,78749631709147238810.125372985M,6857074472524960506740477197M,5671175208344898124599396864M,309485048848893916262.7341846M,404022066286587178937797837.0M,1578211261283823813244134.4M,3992477519294906135023328667.7M,1595976012515713453391872002M,24351220171906372995584M,71678014647255587069669.73450M,1093523025435101.81062931M,652012930858641247050899431.4M,4349706321433576446564307.240M,4349707056913595595756278016M,13018942042499244938043598865M,4330570941878395312622610451M,1699105264188.3545864185856M,346890915862911680297095374.5M,68308094649368281220638305.50M,34983895369532651584992644606M,157821119643198116772577.28M,526130681584026006768898254.5M,7749261727401474083489.10888M,2435258.9266193093624066M,309485019333540448375708.0074M,12379504543026727.747495466837M,7785482685154840459899568152M,7138815931327224510330309120M,1564619408225953613893143596M,18038406025145663499904160000M,40489737478011287288939755M,27412440183429122488540200452M,24758801670017561737876597.79M,38069169337818389.504117314077M,185691008025883135977298331.5M,4337625842829525733066.713919M,6810082203648.532623376844292M,787257126824493.83129964615181M,11714403062750910617101M,1065678530584845902.0111879776M,13427413.8342991646034434M,64928296388322920346.3148298M,3143207537834704.999188267028M,17227782.2674106140002818M,5322981477025448304293653.764M,13328426050717919635314845.307M,13487080264281647597759505M,46531129551608873010494218M,38999946943468745726524195840M,123794073084732444251075379.2M,2998887184064233117978110M,3094850562264380540858471178M,8094967694976182222054294573M,11909369406988760636171160064M,2728795473034.7950904669242370M,123794074929378946837075612.4M,704694446669418116331.5M,433039117533608557591331251.6M,26662451703121949457.131520M,5934697997109565758315170.088M,5284422726128267579809467902M,13344138194397439289109713200M,465209742460498548249702.71M,8718854159513990854891.930624M,18176222481113566059631.2M,461828552569269856719016196M,78614028200601519817265054720M,1394784078518661334841059482.9M,29436347605491.265838379130680M,5275956262290352385949184.792M,1580452371555951198510746012.5M,123794008525925117164959822.5M,11911969165222868127.816625169M,3899994694354.0803320562123778M,15495265544778329394759.335938M,38128392647066051083411216534M,1237940712375927028670529572M,59068115546942.80257197197573M,74484378897762440387856978.19M,4365521820061929.372520812806M,598783817902392803285395482.2M,53944399575911790.36646446865M,15508199901284521500694550.043M,786492975427577307424274173.46M,11714403062793860290061M,971385389882862002.8008430338M,13310264236638067017483771711M,3126162271360392362235443099.8M,125528106832262328579072642.3M,600234502858754540159.6121688M,3126162271358514295849366761.0M,712305866756407182788.0084313M,33800783829853311668824M,14550754263981843967037.281125M,13732302035536387382243956274M,10505754656275183388.81816078M,567722433815998787641455549.3M,600234502858754.5754017531406M,44045919240199801396724250M,5292757592290054133194490378M,1240608185672934900680767515.3M,6663743054526139.727872M,21732968387235945398531267089M,589230444639822876014477312.0M,123794047242420604361422213.3M,1368391264842968856.4032865294M,110883530398383576912134M,11088354757150229371.6506M,71835177064373502806766.45380M,1108835768405398.76701715M,133442133390258004913090.79044M,2951663519257527401385234M,94470408285776554887.68M,86776695339256432.88867378689M,38078745466304906471380246626M,12379405462111789375423774.72M,2610323629772039712500345857.7M,175317894538042350230254979.0M,94470408285780917191.73M,86776695339256432.50212673025M,38078745466304906432725540962M,12379404908709489154369781.76M,273036713023988266776154.09681M,62380572475721227310766.5934M,3133027352279657432427.273339M,176615521588379212376797496.49M,125050631814989256479832M,977337705939567083965202.3042M,2325611071429832849650256333.8M,964610446779051818957172536.9M,528309555675116174821976321.7M,1093532407073854080.51223M,5281877299980055502845394698M,5994354812166631878.657401393M,100855119633838779344320.59963M,3311368712507.3319396293410563M,5428355863575.054080805044734M,5608707547220554533657.733137M,493246240388223012377285144.00M,63490328437206524025.6416044M,26660262582849419.90460129315M,531206286650965949436507166.0M,308060687611761105309.8M,30948531512.9371024607412740M,4363738645860564040049020710.1M,1511529091704573940858.88M,1237940509461462847666847760M,81977307051785048843165368.64M,8760358.7610445244138498M,47246728932268.60641537M,3869514474764.1490932498443M,139254543070077053304833M,3868683515468035769611217.3058M,4812740771435598242002239519M,39614081847573220244038942976M,6238057254783499170774090.25M,713267006083521350.80312869M,309968580419.2663877523081218M,46520069843602460808584966M,32307485291246098719915010052M,74655341709926355572313.30827M,131205097577933832.43602133516M,4722457199533596092.936M,1491715380585.6252695343533059M,1475740370321694275.889M,2025452513.1621876630522M,139514909743529.458344656898M,3350433544762.7199578320086531M,9444732965739290452591M,1578612501832893938086094600.7M,387381625552195556864M,30948501054192100974159.4624M,3777893.1864056673346819M,4722366491665738236672M,8589934594M,35060140042598255595356161M,3094987084095236622124.135168M,1858827384900237952014090496M,7261044359676563791086253M,120897932012640509968.38647M,30948548235054728644101.543938M,40542583539517197631732459522M,26596552613241483908743574M,9671591138636709.822595478M,46424867094107108256637.782529M,49827086608907118581756463617M,60918642.9212788367819013M,195846278000065995959631893M,4951760157256.8143496292080898M,2104498067152.6414064501660931M,23520860747791398674641195776M,96714065574518702131380243M,87042659026608816448864.275M,15784075511275421195720196.096M,144977285.1309261568889859M,1449772851309261568890880M,5663176326326709846104M,56631752004268030.03480M,306390159725294390394.71747840M,33114896051100208385363018496M,132981840158453960565325827M,132981840158454106594213891M,928776150384873642429251.584M,1417480.9611171044279299M,240848905192072548469760M,55360498419452018764M,55373446268380.708940M,1098159063.54709136128M,11994810938547592392381952M,1222148452.9735230967288579M,1250482651.8707409680110339M,1815277683.2227210813772547M,2047618114.1803471904826883M,2253513292.8344526346552835M,3715557955.9329838649083395M,697493536.7322039492314627M,3800560552.6211199292183299M,773713469033.8720420192093699M,129367883204192955909603345M,168050336576962259157057545M,6190422723975167.475150064896M,5261934661076251962144590592M,20554801145319350449078437M,979267916058083046.85318398M,2568737389018715389.2909829634M,42090457202630717780806090753M,5802860540132613180437325.2M,479944066913858327.796056349M,198087642943502710117698152.96M,2040063545860264883654912M,7254519686934648480622184.1M,309492628329181885096263689M,2785648463383465764.375940352M,2786574059896253560448473088M,10885054907395991652991279M,121003277147064068309025.0M,7056359756326483300.1529278467M,49518229676277881905550011648M,11215623493040189473046M,11695239401906593726476M,49517602051318.95221531087360M,5570730282853008352573826560M,4295000068M,0.0001099511660806M,43.2345564227597063M,1083325038521.9468000902551049M,34161147320976416107829.203456M,34132004069948232352056803377M,20735751578100377962432.181876M,313830266826231524058.52943205M,30145043681445285854993.989934M,34483911301263862.616240320333M,24899514449544774810268.205155M,121432729100790688.213459813M,3137814854981572365171.7424487M,31384030682988080323760515.394M,31383026682623152405848355699M,31079543871648365252010997074M,31398766697213603674887.971144M,3602284905811345.4811259425326M,30761614811624500848048.030559M,366537873079430330454523.55924M,31877435045391372422499.356773M,248923087538429859335629.94548M,3354205299603488884031.8772585M,301220464934630950396929.85445M,31877435080564780112911.099762M,353991115315100901075763.44436M,3603612014486083367495.1065701M,360228490581154425130734.31922M,30113135112363194381341.119071M,356794784862315453.55917282661M,1226608001944196045975.98295M,295417901871610471324308.85998M,357121902264801113425846.21389M,360228490582578514484569982.45M,3413214708396707426463680.4191M,21664458017445083103161967.976M,33856516726310254321253248105M,34784811968459213678608349523M,34480323040966934739048.227173M,344851352959127.77961680758528M,32636692201651316720411.830644M,26132638345081.460061058236526M,347897651433702706776898.56629M,3355544232498187638549239.8709M,3478009820121364997148.4914537M,25997262396689435133784384.613M,14236850857536109993202.642281M,14368562473277723173786186.851M,3573744811836073649114.6933582M,2079158522304108633655439.7029M,32639119496868937011729.296751M,35708360459174295142548927.333M,35403922998141586955246.595188M,3386135311369382948754262667.6M,32924258846655780641155.926117M,248921105958151736557431.98307M,32617278551349190098135.774049M,259972906571089.03130569202279M,20870226643421838812255.969650M,34433170395092.131016007249525M,36027719157294885556416.217204M,31877529215523870227.319843937M,3134920535191277423647.3619557M,1859370725825658079.316279296M,9913196443207295370638590720M,52866374445326446227327572.65M,2168850902311553958075760913M,9381597883129588891458027.62M,938263495547844620957319200M,1860565705974587465715.092253M,5577998083701714537607791645M,9381548080551594870933.43747M,1859337466126284326863183110M,52866564239303831.79830009860M,9910811667660484727221715217M,155001794269370172655534568.0M,220767358777983993462764776.5M,34176854417889868282.55857416M,330117416946197215669062411M,34140112372495310905.48819979M,619003224575227012908648195M,186420156089475124798850382.6M,1864201540785618078388324104M,27877835305455819595.63184139M,321588437278700900465115408M,341529574031806756513.7037827M,9309156960731209951955522.88M,2805921864517585366697838336M,249046767212925109024116096.8M,155714854941557372182010496.9M,621397357233882851444850976M,3301174169436540.32305226251M,2485589393694249612146444561M,24843804863937356532.05020936M,2485589412211933037761530129M,24904677643629714459.20794632M,1866595762075037600464701447M,0.00000000M
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> END ENCODED ASSEMBLY <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
})
{
//Get the bits of the decimal
var bits = decimal.GetBits(dec);
//Skip forward if the highest scalar bit is set
dynamic idx = bits[3] >> 16; //16 for skip tokens, <16 otherwise
if (idx == 16) asmBufOff += (byte)bits[0];
else
{
//Accumulate two 4 bit scales, then add to the buffer
//Note that for even parity tokens, the byte we write here is immediately overwritten again
scaleAccum <<= 4;
TinyBot_asmBuf[asmBufOff++] = scaleAccum |= idx;
asmBufOff -= scaleParity ^= 1;
}
//Add the 88/96 bits of the integer number to the buffer
idx >>= 4; //1 for skip tokens, 0 otherwise
while (idx < 12) TinyBot_asmBuf[asmBufOff++] = (byte)(bits[idx / 4] >> idx++ * 8);
}
//Load the tiny bot from the assembly
//We can't just load it and be done with it, because the byte[] overload doesn't add the assembly to the regular load path
//As such load it whenever any assembly fails to load >:)
//If this is our second load call, assume that the Chess-Challenge assembly has been renamed, and as such return it
//Note that this only uses allowed APIs, not invoking any method not in an allowed namespace!
System.ResolveEventHandler asmResolveCB = (_, _) => asmLoadCount++ == 0 ? CurrentDomain.Load(TinyBot_asmBuf) : typeof(Board).Assembly;
CurrentDomain.AssemblyResolve += asmResolveCB;
TinyBot_asmBuf = CurrentDomain.CreateInstanceAndUnwrap(ToString(), "e");
CurrentDomain.AssemblyResolve -= asmResolveCB;
}
public Move Think(Board board, Timer timer) => TinyBot_asmBuf.Think(board, timer);
}