Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » Finished MUD Scripts
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Nov 10, 2007 3:01 pm   

Godwars2 Map Solver
 
There is still a bug somewhere in the math section. This bug triggers a debugging message, but for the most part you can simply start it going and it will solve them in short order.

Usage is wield the the map and get both your hands involved:
Decypher -- starts the process
Decypher stop -- will pause the solving of the map and retain the values
Decypher slow -- will start the process but run it in a single step mode
Decypher step -- does the single stepping for slow and after stop
Code:
#CLASS {CypherSystem}
#ALIAS CypherAdj {AdjResults="";AdjBest="";#LOOPDB @CypherMoves {CypherTemp=1;#LOOP 5 {#IF (%abs(%eval(%concat(@{Cypher%i},%word(%val,%i))))>4) {CypherTemp=0}};#IF (@CypherTemp) {CypherTemp="";NewCypher1=0;#LOOP 5 {CypherTemp=%concat(@CypherTemp,%eval(%concat(@{Cypher%i},%word(%val,%i)))," ");#IF (%ismember(%i,@KnownCorrect)=0) {#IF (%abs(%word(%val,%i))=2) {#ADD NewCypher1 4} {#IF (%word(%val,%i)!="+0") {#ADD NewCypher1 1}}}};#ADDKEY AdjResults {%key} {%trim(@CypherTemp)};#ADDITEM AdjBest {%concat(%rightback(%concat(%repeat("0",3),@NewCypher1),3)," ",%key)}}};AdjBest=%sort(@AdjBest,1);#IF (%numitems(@KnownCorrect)<5) {#LOOP 5 {#IF (%ismember(%i,@KnownCorrect)) {#VAR NewCypher%i {%word(%db(@AdjResults,%word(%item(@AdjBest,1),2)),%i)}} {#VAR NewCypher%i {@{Cypher%i}}}};#T+ CypherUpdate;CypherTemp=2;CypherTemp2=%word(%item(@AdjBest,1),2);#WHILE (@CypherTemp<=%len(@CypherTemp2)) {#IF (@CypherPause=0) {#EXEC {%left(@CypherTemp2,1)%copy(@CypherTemp2,@CypherTemp,1)}} {CypherDelayed=%additem(%left(@CypherTemp2,1)%copy(@CypherTemp2,@CypherTemp,1),@CypherDelayed)};#ADD CypherTemp 1}} {#IF (@FinalCypherMoves="") {#SHOW Got all known, time to make right.;CypherTemp="";#NOOP Check for within 1;#LOOPDB @AdjResults {#IF (%subchar(%val," 0","")="") {CypherTemp=%key};#IF (@CypherTemp="") {#IF (%eval(%subchar(%val," 234-","+999"))<3) {#SHOW Close enough %val;CypherTemp=%key}}};#IF (@CypherTemp) {#SHOW LuckyWinner @CypherTemp;CypherTemp2=2;#WHILE (@CypherTemp2<=%len(@CypherTemp2)) {#IF (@CypherPause=0) {#EXEC {%left(@CypherTemp,1)%copy(@CypherTemp,@CypherTemp2,1)}} {CypherDelayed=%additem(%left(@CypherTemp2,1)%copy(@CypherTemp2,@CypherTemp,1),@CypherDelayed)};#ADD CypherTemp2 1}} {#NOOP Check for within many;AdjBest=%expanddb(@AdjResults,"|","=");CypherTemp3="";CypherBrute}}}}
#ALIAS CypherBrute {#T+ BruteStat status;#WHILE (@AdjBest) {#LOOPDB @CypherMoves {CypherTemp2=1;#LOOP 5 {#VAR NewCypher%i {%eval(%word(%val,%i)+%word(%word(%item(@AdjBest,1),2,"="),%i))};#IF (%abs(@{NewCypher%i})>4) {CypherTemp2=0}};#IF (@CypherTemp2) {CypherTemp2="";#LOOP 5 {CypherTemp2=%concat(@CypherTemp2," ",@{NewCypher%i})};#IF (%subchar(@CypherTemp2," 0","")="") {CypherTemp=%concat(%word(%item(@AdjBest,1),1,"=")," ",%key);#WHILE (%numitems(@AdjBest)>1) {#DELNITEM AdjBest 1};CypherTemp3="";#ADDKEY CypherTemp3 {%word(%item(@AdjBest,1),1,"=") %key} {%trim(@CypherTemp2)}} {#IF (%eval(%subchar(@CypherTemp2," 234-","+999"))<3) {CypherTemp=%concat(%word(%item(@AdjBest,1),1,"=")," ",%key);#SHOW Close enough value of @CypherTemp2;CypherTemp3="";#ADDKEY CypherTemp3 {%word(%item(@AdjBest,1),1,"=") %key} {%trim(@CypherTemp2)};#WHILE (%numitems(@AdjBest)>1) {#DELNITEM AdjBest 1}} {#ADDKEY CypherTemp3 {%word(%item(@AdjBest,1),1,"=") %key} {%trim(@CypherTemp2)}}}}};#DELNITEM AdjBest 1;#IF (@AdjBest="") {#IF (@CypherTemp) {#SHOW LuckyWinner @CypherTemp;#T- BruteStat status;#T+ CypherUpdate;FinalCypherMoves=%replace(@CypherTemp," ","|");CypherTemp2=%db(@CypherTemp3,@CypherTemp);#IF (@CypherTemp2!="0 0 0 0 0") {#SHOW Adding needed raise and lower data.;#LOOP 5 {#IF (%word(@CypherTemp2,%i)="1") {FinalCypherMoves=%concat(@FinalCypherMoves,"|",%replace(%db(@PosSpecData,%concat("-",%i))," ","|"))} {#IF (%word(@CypherTemp2,%i)="-1") {FinalCypherMoves=%concat(@FinalCypherMoves,"|",%replace(%db(@PosSpecData,%concat("+",%i))," ","|"))}}}}} {AdjBest=%expanddb(@CypherTemp3,"|","=");#IF (%numwords(%word(%item(@AdjBest,1),1,"="))<3) {CypherTemp3="";#SHOW Stepping deeper %numwords(%word(%item(@AdjBest,1),1,"="))} {#SHOW Sorry, brute didn't get far enough. Picking route for low values and working it.;AdjBest=99;CypherTemp2="";#LOOPDB @CypherTemp3 {CypherTemp=%eval(%subchar(%val,"- ","++"));#IF (@CypherTemp<@AdjBest) {AdjBest=@CypherTemp;CypherTemp2=%key}};FinalCypherMoves=%replace(@CypherTemp2," ","|");CypherTemp="";AdjBest="";#T- BruteStat status}}}}}
#ALIAS ComputeCypherTemp {CypherTemp=%replace(%replace(@CypherTemp,", ","|")," and ","|");CypherTemp=%replace(@CypherTemp,"correct","0");CypherTemp=%replace(@CypherTemp,"low","*-1-3");CypherTemp=%replace(@CypherTemp,"high","*1+3");CypherTemp=%replace(@CypherTemp,"very ","1");#LOOP 5 {#VAR Cypher%i {%eval(%concat("0",%item(@CypherTemp,%i)))}}}
#ALIAS Decypher {#IF ("%1"="stop") {CypherPause=1} {#IF ("%1"="off") {#T- CypherSpot;#T- CypherUpdate;#T- CypherConfusion;#T- CypherFinish;#T- CypherReport status;#T- CypherBrute status;#RESET CypherSystem} {#IF ("%1"="step") {#IF (@CypherDelayed) {#T+ CypherUpdate;#EXEC {%item(@CypherDelayed,1)};#DELNITEM CypherDelayed 1} {#SHOW No steps to do on the cypher queue}} {#RESET CypherSystem;#IF ("%1"="slow") {CypherPause=1};#T+ CypherReport status;#T+ CypherSpot;#T- CypherUpdate;#T+ CypherConfusion;#T+ CypherFinish;le}}}}
#VAR Cypher1 {} {}
#VAR Cypher2 {} {}
#VAR Cypher3 {} {}
#VAR Cypher4 {} {}
#VAR Cypher5 {} {}
#VAR CypherTemp {} {}
#VAR CypherTemp2 {} {}
#VAR CypherTemp3 {} {}
#VAR NewCypher1 {} {}
#VAR NewCypher2 {} {}
#VAR NewCypher3 {} {}
#VAR NewCypher4 {} {}
#VAR NewCypher5 {} {}
#VAR AdjResults {} {}
#VAR AdjBest {} {}
#VAR KnownCorrect {} {}
#VAR FinalCypherMoves {} {}
#VAR CypherPause {0} {0}
#VAR CypherDelayed {} {}
#VAR PosSpecData {}
#ADDKEY PosSpecData {-1=rat rsd lat lsd ld rd lad|-2=rsd rst|-3=rat ld rad rsd|-4=lst lt rd lsd lat rad lad|-5=lat rd ld lsd rat ld rsd|+1=rad rat rst rsd|+2=rd lsd lat lst lad|+3=rst lsd rd rat rsd lat lad|+4=rt lat rd ld lsd rat ld rsd|+5=rad rad rat lsd rat}
#VAR CypherMoves {}
#ADDKEY CypherMoves {rasd=+3 -3 -3 +0 +0|rast=+0 +4 +4 -4 +0|rsad=+4 +4 +4 +0 -4|rsat=-3 -3 +4 +0 -4|rad=+1 +0 +1 +0 +1|rat=+0 +1 -1 +0 -1|rsd=-1 -2 +0 +1 +0|rst=+1 +1 +0 -1 +0|rd=-1 +2 +3 +2 -1|rt=+0 +0 +0 +1 +1|lasd=+0 +0 -3 -3 +3|last=+0 -4 +4 +4 +0|lsad=+4 -3 +4 +0 -4|lsat=-4 +3 +4 +0 -4|lad=-1 +1 -1 -1 +1|lat=+4 -1 +0 -1 +0|lsd=-2 -2 +0 +0 +1|lst=+0 +1 -2 +0 -1|ld=+0 +1 -1 -1 +0|lt=-1 -1 -1 -1 -1}
#TRIGGER "CypherUpdate" {^The cyphers are &{CypherTemp}.$} {#T- CypherUpdate;ComputeCypherTemp;CypherTemp="";#LOOP 5 {#IF (%ismember(%i,@KnownCorrect)) {#IF (@{Cypher%i}!=0) {#IF (%abs(@{Cypher%i})!=4) {#VAR Cypher%i {@{NewCypher%i}}}}} {#IF (@{Cypher%i}=0) {#ADDITEM KnownCorrect {%i}} {#IF (%abs(@{Cypher%i})=4) {#ADDITEM KnownCorrect {%i}} {#IF (%eval(@{NewCypher%i}*10/@{Cypher%i})<0) {#NOOP Changed Sign check adjust amount and we might know what it is.;#IF (%abs(%word(%db(@CypherMoves,%word(%item(@AdjBest,1),2)),%i))=2) {#VAR Cypher%i {%eval(@{Cypher%i}/3)};#ADDITEM KnownCorrect {%i}} {#IF (%abs(%word(%db(@CypherMoves,%word(%item(@AdjBest,1),2)),%i))=3) {#VAR Cypher%i {%eval(@{Cypher%i}/3*2)}} {#IF (%abs(%word(%db(@CypherMoves,%word(%item(@AdjBest,1),2)),%i))=4) {#VAR Cypher%i {%eval(@{Cypher%i}/3*2)}} {#SHOW Uncovered circumstance you missed something dumbass %i %word(%db(@CypherMoves,%word(%item(@AdjBest,1),2)),%i).;CypherTemp="idiot"}}}} {#NOOP No Sign change have to figure here.;#IF (%abs(%word(%db(@CypherMoves,%word(%item(@AdjBest,1),2)),%i))=2) {#IF (%eval(%word(%db(@CypherMoves,%word(%item(@AdjBest,1),2)),%i))/@{Cypher%i})=-1) {#VAR Cypher%i {%eval(@{Cypher%i}/3)}};#ADDITEM KnownCorrect {%i}} {#IF (%abs(%word(%db(@CypherMoves,%word(%item(@AdjBest,1),2)),%i))=1) {#VAR Cypher%i {%eval(@{Cypher%i}/3*2)}} {#IF (%word(%db(@CypherMoves,%word(%item(@AdjBest,1),2)),%i)="+0") {#NOOP Just checking to cover the error} {#SHOW Uncovered circumstance you missed something dumbass %i.;CypherTemp="idiot"}}}}}}}};#IF (@CypherTemp="") {CypherAdj;#IF (@FinalCypherMoves) {#T+ CypherUpdate;CypherTemp2=%item(@FinalCypherMoves,1);#IF (@CypherTemp2="Report") {CypherTemp="";#LOOP 5 {CypherTemp=%concat(@CypherTemp," ",@{Cypher%i});#VAR NewCypher%i {@{Cypher%i}}};#SHOW {Cypher values are:@CypherTemp};le} {#LOOP 5 {#VAR NewCypher%i {%word(%db(@AdjResults,@CypherTemp2),%i)}};CypherTemp="";#LOOP 5 {CypherTemp=%concat(@CypherTemp," ",@{Cypher%i})};#SHOW {Cypher values are:@CypherTemp};#SHOW CypherValues set to %db(@AdjResults,@CypherTemp2) for @CypherTemp2;CypherTemp=2;#WHILE (@CypherTemp<=%len(@CypherTemp2)) {#IF (@CypherPause=0) {#EXEC {%left(@CypherTemp2,1)%copy(@CypherTemp2,@CypherTemp,1)}} {CypherDelayed=%additem(%left(@CypherTemp2,1)%copy(@CypherTemp2,@CypherTemp,1),@CypherDelayed)};#ADD CypherTemp 1}};#DELNITEM FinalCypherMoves 1}}} "" {disable}
#TRIGGER "CypherSpot" {^The cyphers are &{CypherTemp}.$} {KnownCorrect="1|2|3|4|5";ComputeCypherTemp;#LOOP 5 {#IF (%abs(@{Cypher%i})=3) {#DELITEM KnownCorrect {%i}}};#T- CypherSpot;CypherAdj} "" {disable}
#TRIGGER "CypherConfusion" {^You're confused, and unable to make any sense of the map.$} {#RESET CypherSystem;#T+ CypherSpot;#T- CypherUpdate;le} "" {disable}
#TRIGGER "CypherFinish" {^You've finished deciphering the map.$} {#T- CypherUpdate;#T- CypherConfusion;#T- CypherFinish;#T- CypherSpot;#T- CypherReport status;#RESET CypherSystem;#BEEP} "" {disable}
#STAT {CypherBrute at %numkeys(@CypherTemp3)} "" "BruteStat"
#T- BruteStat status
#STAT {Correct: %sort(@KnownCorrect) Cyphers: @Cypher1 @Cypher2 @Cypher3 @Cypher4 @Cypher5} "" "CypherReport"
#T- CypherReport status
#CLASS 0
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Sorin
Beginner


Joined: 28 Mar 2004
Posts: 10
Location: USA

PostPosted: Sat Nov 10, 2007 6:31 pm   Problem with the Script
 
At the beggining, ,it only wants to use a single exploratory value, this doesnt always work, like if the map starts out with

low high high low high

it merely loops because of the confused message.
Reply with quote
Sorin
Beginner


Joined: 28 Mar 2004
Posts: 10
Location: USA

PostPosted: Sat Nov 10, 2007 6:35 pm   
 
Ahh nevermind, you just assumed that everyone on the mud used right as their dominant hand, i just added a swap to the beggining to make it work allright
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » Finished MUD Scripts All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net