Morpion solitaire/Unicon: Difference between revisions

fix for move log offset error, update help, change a default
m (fix v-space)
(fix for move log offset error, update help, change a default)
Line 35:
 
record morpioncell(symbol,direction,row,col) # a grid cell
record morpionmove(direction,move,line,roff,coff) # move & line
record morpiongame(grid,log,history,roff,coff,center,pool,move,count) # all game data
 
Line 66:
end
 
procedure MorphionMove(MG) #: make a move
put(MG.history,M := MG.move).roff := MG.roff
logM.coff := FormatMoveLog(M,MG.roff,MG.coff)
put(MG.history,M)
log := FormatMoveLog(M)
log ||:= sprintf(" - of %i choices.",*MG.pool) # append # choices
log ||:= sprintf(" Metric=%i",M_Eval(MG)) # append score (opt)
Line 191 ⟶ 193:
 
procedure FormatMoveLog(M,roff,coff) #: format a log entry
every /(M.roff|coff) := \roff | 0
log/M.coff := sprintf("\"%s\"coff [%i,%i]| 0 : ",
log ||:= sprintf("\"%s\" [%i,%i] : ",x[1]-roffM.direction,x[2]-coff)
M.direction,M.line[M.move,1]-roff,M.line[M.move,2]-coff)
every x := !M.line do M.line[M.move,1]-M.roff,M.line[M.move,2]-M.coff)
every x := !M.line do
log ||:= sprintf("[%i,%i] ",x[1]-roff,x[2]-coff)
log ||:= sprintf("[%i,%i] ",x[1]-M.roff,x[2]-M.coff)
return log
end
Line 212 ⟶ 215:
Arguments : ")
every fprintf(&errout," %s",!M_CommandLine)
fprintf(&errout,"_
Morphion [options] Plays the 5T variant of Morphion Solitaire\n_
Where options are:\n_
\t-P|-print<n>\tcontrols how much is printed \n_
\t\t\tn=2 shows\tshows all boards and a log of all moves (every game)\n_
\t\t\tn=1 shows\tshows a log of the moves and final board (default single game)\n_
\t\t\tn=0 produces\tproduces no per game output (default for multigames)\n_
\t-A <a> choose\tchoose player strategy approach (default=random, future)\n_
\t-E\tSpecifiy an position fitness evaluation function (default none, future)\n_
\t-SW <n> Search\tSearch width (strategy dependent, future)\n_
And where these options affect multigame simulations:\n_
\t-SD\tSearch depth (strategy dependent, future)\n_
\t-S <n> runs n games (e.g. -S10) and shows summary of all runs and the board and log for the best result_
\t\tnote for larger n this benefits from larger BLKSIZE, STRSIZE environment variables\n_
\t-UN <n> Give status update notifications every n simulations\n_
\t-B <n> Keep best n games of unique length (default 5)\n_
\t-W <n> Keep worst n games of unique length (default 3)\n_
\t-R|-replay\treplay\n_
\t-RF\tfile containing game record to be replayed\n_
\t-RN\tnumber of moves to replay (0=all)\n_
\t-E\n_
\t-L|-limit\tgames to play (if 0 or less then play until any of 'XxQq' is pressed\n_
\t\tnote for larger n this benefits from larger BLKSIZE, STRSIZE environment variables\n_
\t-UN <n> Give\tGive status update notifications every n simulations\n_
\t-B <n> Keep\tKeep best n games of unique length (default 5)\n_
\t-W <n> Keep\tKeep worst n games of unique length (default 3)\n_
\t-?|-h|-help\tthis help text")
stop()
Line 261 ⟶ 263:
M_SrchDep := (0 < \opt["SD"]) | 5
M_Eval := case opt["E"] of {
"01" : ScorefailScore1 # test
default : Score1&null # also 1"0"
}
c := sprintf("# --- Morpion Solitaire 5 (v%s) ---\n#\n",MORPVER)
c ||:= "# Command line options :"
Line 281 ⟶ 282:
c ||:= sprintf("# - Moves to replay = %i\n",0 ~= \M_ReplayAfter)
c ||:= sprintf("# Player Strategy = %i\n",M_Strategy)
c ||:= sprintf("# - PlayPosition Fitness Evaluator = %i\n",\M_Eval | "* None *")
c ||:= sprintf("# - Search Width (strategy dependant) = %i\n",M_SrchWid)
c ||:= sprintf("# - Search Depth (strategy dependant) = %i\n",M_SrchDep)
Line 288 ⟶ 289:
if \opt["Q"] then stop(M_Config,"-Q Stops run after processing options")
else write(M_Config)
/M_Eval := Scorefail
end</lang>
== Multigame Simulation and Monitoring Support ==
Line 477 ⟶ 479:
if \M_ReplayFile then {
M_ReplayFile ? (="Games/", savegame ||:= "-RF" || tab(find(".txt")))
savegame ||:= "-RN" || (0 < \M_ReplayAfter)
}
savegame ||:= sprintf("_%s-%s.txt",deletec(&date,'/'),deletec(&clock,':'))
Line 498 ⟶ 500:
/l := ""
l ||:= sprintf("%i:%i,%i^%i,%i;",
i,m.line[m.move,1]-m.roff,m.line[m.move,2],-m.line[ecoff,1],m.line[e,2])
M.direction,M m.line[M.movee,1]-m.roff,Mm.line[M.movee,2]-m.coff)
if *l > 70 then {
c ||:= l || "\n"
Anonymous user