dev.new(xpos=650,ypos=10,width=5.2,height=5.7) plot(c(0,15),c(0,15),type="n",xlab="",ylab="",asp=1) mtext("Batti Svolta (D,S) o batti Passi (1,...,15)",cex=0.8,side=3) abline(h=seq(0,15,1),v=seq(0,15,1),lty=3,col="red") x <- 9; y <- 12; rect(x-2.5,y-1.5,x+2.5,y+1.5,,col="yellow") symbols(5, 3, circles=1.5, inches=FALSE, add=TRUE, bg="yellow") symbols(4, 7, circles=1.5, inches=FALSE, add=TRUE, bg="yellow") symbols(8, 8, circles=1.5, inches=FALSE, add=TRUE, bg="yellow") text(4,7,"A"); text(5,3,"B"); text(8,8,"C"); text(9,12,"D") x <- 5; y <- 10; points(x,y,pch=19); v <- "S"; rect(0,14,1,15,,col="grey"); arrows(1/2,15,1/2,14,length=0.1) ruotaD <- function(v) { if(v=="S") v1 <- "O"; if(v=="O") v1 <- "N"; if(v=="N") v1 <- "E"; if(v=="E") v1 <- "S"; v1} ruotaS <- function(v) { if(v=="N") v1 <- "O"; if(v=="E") v1 <- "N"; if(v=="S") v1 <- "E"; if(v=="O") v1 <- "S"; v1} freccia <- function(v) {rect(0,14,1,15,col="grey"); if(v=="N") arrows(1/2,14,1/2,15,length=0.1); if(v=="S") arrows(1/2,15,1/2,14,length=0.1); if(v=="O") arrows(1,14.5,0,14.5,length=0.1); if(v=="E") arrows(0,14.5,1,14.5,length=0.1)} via <- function() {v <- "S"; while(TRUE) {d <- scan(file="",what="character",n=1); d <- toupper(d); if(d=="D") {v <- ruotaD(v);freccia(v)} else {if(d=="S") {v <- ruotaS(v);freccia(v)} else { n = strtoi(d); if(v=="O") {x <- x-n; arrows(x+n,y,x,y,length=0.1)}; if(v=="E") {x <- x+n; arrows(x-n,y,x,y,length=0.1)}; if(v=="N") {y <- y+n; arrows(x,y-n,x,y,length=0.1)}; if(v=="S") {y <- y-n; arrows(x,y+n,x,y,length=0.1)} }}; }}