Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,16 +0,0 @@
generic
Rows, Cols: Positive;
with function Name(N: Natural) return String; -- with Pre => (N < Rows*Cols);
-- Name(0) shall return the name for the empty tile
package Generic_Puzzle is
subtype Row_Type is Positive range 1 .. Rows;
subtype Col_Type is Positive range 1 .. Cols;
type Moves is (Up, Down, Left, Right);
type Move_Arr is array(Moves) of Boolean;
function Get_Point(Row: Row_Type; Col: Col_Type) return String;
function Possible return Move_Arr;
procedure Move(The_Move: Moves);
end Generic_Puzzle;

View file

@ -1,57 +0,0 @@
package body Generic_Puzzle is
Field: array(Row_Type, Col_Type) of Natural;
Current_R: Row_Type := Rows;
Current_C: Col_Type := Cols;
-- invariant: Field(Current_R, Current_C=0)
-- and for all R, C: Field(R, C) < R*C
-- and for all (R, C) /= (RR, CC): Field(R, C) /= Field(RR, CC)
function Get_Point(Row: Row_Type; Col: Col_Type) return String is
(Name(Field(Row, Col)));
function Possible return Move_Arr is
(Up => Current_R > 1, Down => Current_R < Rows,
Left => Current_C > 1, Right => Current_C < Cols);
procedure Move(The_Move: Moves) is
Old_R: Row_Type; Old_C: Col_Type; N: Natural;
begin
if not Possible(The_Move) then
raise Constraint_Error with "attempt to make impossible move";
else
-- remember current row and column
Old_R := Current_R;
Old_C := Current_C;
-- move the virtual cursor to a new position
case The_Move is
when Up => Current_R := Current_R - 1;
when Down => Current_R := Current_R + 1;
when Left => Current_C := Current_C - 1;
when Right => Current_C := Current_C + 1;
end case;
-- swap the tiles on the board
N := Field(Old_R, Old_C);
Field(Old_R, Old_C) := Field(Current_R, Current_C);
Field(Current_R, Current_C) := N;
end if;
end Move;
begin
declare -- set field to its basic setting
N: Positive := 1;
begin
for R in Row_Type loop
for C in Col_Type loop
if (R /= Current_R) or else (C /= Current_C) then
Field(R, C) := N;
N := N + 1;
else
Field(R, C) := 0;
end if;
end loop;
end loop;
end;
end Generic_Puzzle;

View file

@ -1,72 +0,0 @@
with Generic_Puzzle, Ada.Text_IO,
Ada.Numerics.Discrete_Random, Ada.Command_Line;
procedure Puzzle_15 is
function Image(N: Natural) return String is
(if N=0 then " " elsif N < 10 then " " & Integer'Image(N)
else Integer'Image(N));
package Puzzle is new Generic_Puzzle(Rows => 4, Cols => 4, Name => Image);
package Rnd is new Ada.Numerics.Discrete_Random(Puzzle.Moves);
Rand_Gen: Rnd.Generator;
Level: Natural := (if Ada.Command_Line.Argument_Count = 0 then 10
else Natural'Value(Ada.Command_Line.Argument(1)));
Initial_Moves: Natural := (2**(Level/2) + 2**((1+Level)/2))/2;
Texts: constant array(Puzzle.Moves) of String(1..9) :=
("u,U,^,8: ", "d,D,v,2: ", "l,L,<,4: ", "r,R,>,6: ");
Move_Counter: Natural := 0;
Command: Character;
begin
-- randomize board
for I in 1 .. Initial_Moves loop
declare
M: Puzzle.Moves := Rnd.Random(Rand_Gen);
begin
if Puzzle.Possible(M) then
Puzzle.Move(M);
end if;
end;
end loop;
-- read command and perform move
loop
-- Print board
for R in Puzzle.Row_Type loop
for C in Puzzle.Col_Type loop
Ada.Text_IO.Put(Puzzle.Get_Point(R, C));
end loop;
Ada.Text_IO.New_Line;
end loop;
Ada.Text_IO.Get(Command);
begin
case Command is
when 'u' | 'U' | '^' | '8' =>
Ada.Text_IO.Put_Line("Up!"); Puzzle.Move(Puzzle.Up);
when 'd' | 'D' | 'v' | '2' =>
Ada.Text_IO.Put_Line("Down!"); Puzzle.Move(Puzzle.Down);
when 'l' | 'L' | '<' | '4' =>
Ada.Text_IO.Put_Line("Left!"); Puzzle.Move(Puzzle.Left);
when 'r' | 'R' | '>' | '6' =>
Ada.Text_IO.Put_Line("Right!"); Puzzle.Move(Puzzle.Right);
when '!' =>
Ada.Text_IO.Put_Line(Natural'Image(Move_Counter) & " moves!");
exit;
when others =>
raise Constraint_Error with "wrong input";
end case;
Move_Counter := Move_Counter + 1;
exception when Constraint_Error =>
Ada.Text_IO.Put_Line("Possible Moves and Commands:");
for M in Puzzle.Moves loop
if Puzzle.Possible(M) then
Ada.Text_IO.Put(Texts(M) & Puzzle.Moves'Image(M) & " ");
end if;
end loop;
Ada.Text_IO.Put_Line("!: Quit");
end;
end loop;
end Puzzle_15;

View file

@ -1 +0,0 @@
package Puzzle is new Generic_Puzzle(Rows => 3, Cols => 3, Name => Image);

View file

@ -107,17 +107,13 @@ validMovement?: $[
movement :literal
][
pos: game\playerPosition
case [movement]
when? [='up]
-> return (not? in? pos [0..3])
when? [='down]
-> return (not? in? pos [12..15])
when? [='left]
-> return (not? in? pos [0 4 8 12])
when? [='right]
-> return (not? in? pos [3 7 11 15])
else
-> return false
case movement [
'up -> return (not? in? pos [0..3])
'down -> return (not? in? pos [12..15])
'left -> return (not? in? pos [0 4 8 12])
'right -> return (not? in? pos [3 7 11 15])
any -> return false
]
]
@ -130,13 +126,14 @@ validMovement?: $[
;; will be returned the same input as a :string
parseInput: $[inp :string][
lowerInp: lower inp
case [lowerInp]
when? [="w"] -> return 'up
when? [="a"] -> return 'left
when? [="s"] -> return 'down
when? [="d"] -> return 'right
when? [="q"] -> return 'quit
else -> return inp
case lowerInp [
"w" -> return 'up
"a" -> return 'left
"s" -> return 'down
"d" -> return 'right
"q" -> return 'quit
any -> return inp
]
]
;; Moves the player in Game's Table
@ -155,7 +152,7 @@ movePlayer: $[
playerPosition :integer
relativePosition :integer
][
try [
if throws? [
; 'otherPosition is the real index of the 'relativePosition
otherPosition: + playerPosition relativePosition
@ -168,20 +165,16 @@ movePlayer: $[
; -- Updates player's status
game\playerPosition: otherPosition
game\movements: inc game\movements
] else -> panic "'movement didn't checked."
] -> panic "'movement didn't checked."
]
case [movement]
when? [='up]
-> (updateGame game position (neg 4))
when? [='down]
-> (updateGame game position (4))
when? [='left]
-> (updateGame game position (neg 1))
when? [='right]
-> (updateGame game position (1))
else -> panic "'movement didn't checked."
case movement [
'up -> updateGame game position neg 4
'down -> updateGame game position 4
'left -> updateGame game position neg 1
'right -> updateGame game position 1
any -> panic "movement didn't check."
]
]
endGame: $[
@ -209,13 +202,12 @@ runGame: $[sampleTable :block][
-> endGame "Exiting game..."
validInp: validInput? command
if? validInp [
switch validInp [
validMov: validMovement? game command
(validMov)?
-> movePlayer game command
-> printWrongMovement command
] else
-> printWrongInput command
] -> printWrongInput command
if sampleTable = game
-> endGame "Congratulations! You won!"

View file

@ -1,151 +0,0 @@
>>SOURCE FORMAT FREE
*> This code is dedicated to the public domain
*> This is GNUCOBOL 2.0
identification division.
program-id. fifteen.
environment division.
configuration section.
repository. function all intrinsic.
data division.
working-storage section.
01 r pic 9.
01 r-empty pic 9.
01 r-to pic 9.
01 r-from pic 9.
01 c pic 9.
01 c-empty pic 9.
01 c-to pic 9.
01 c-from pic 9.
01 display-table.
03 display-row occurs 4.
05 display-cell occurs 4 pic 99.
01 tile-number pic 99.
01 tile-flags pic x(16).
01 display-move value spaces.
03 tile-id pic 99.
01 row-separator pic x(21) value all '.'.
01 column-separator pic x(3) value ' . '.
01 inversions pic 99.
01 current-tile pic 99.
01 winning-display pic x(32) value
'01020304'
& '05060708'
& '09101112'
& '13141500'.
procedure division.
start-fifteen.
display 'start fifteen puzzle'
display ' enter a two-digit tile number and press <enter> to move'
display ' press <enter> only to exit'
*> tables with an odd number of inversions are not solvable
perform initialize-table with test after until inversions = 0
perform show-table
accept display-move
perform until display-move = spaces
perform move-tile
perform show-table
move spaces to display-move
accept display-move
end-perform
stop run
.
initialize-table.
compute tile-number = random(seconds-past-midnight) *> seed only
move spaces to tile-flags
move 0 to current-tile inversions
perform varying r from 1 by 1 until r > 4
after c from 1 by 1 until c > 4
perform with test after
until tile-flags(tile-number + 1:1) = space
compute tile-number = random() * 100
compute tile-number = mod(tile-number, 16)
end-perform
move 'x' to tile-flags(tile-number + 1:1)
if tile-number > 0 and < current-tile
add 1 to inversions
end-if
move tile-number to display-cell(r,c) current-tile
end-perform
compute inversions = mod(inversions,2)
.
show-table.
if display-table = winning-display
display 'winning'
end-if
display space row-separator
perform varying r from 1 by 1 until r > 4
perform varying c from 1 by 1 until c > 4
display column-separator with no advancing
if display-cell(r,c) = 00
display ' ' with no advancing
move r to r-empty
move c to c-empty
else
display display-cell(r,c) with no advancing
end-if
end-perform
display column-separator
end-perform
display space row-separator
.
move-tile.
if not (tile-id numeric and tile-id >= 01 and <= 15)
display 'invalid tile number'
exit paragraph
end-if
*> find the entered tile-id row and column (r,c)
perform varying r from 1 by 1 until r > 4
after c from 1 by 1 until c > 4
if display-cell(r,c) = tile-id
exit perform
end-if
end-perform
*> show-table filled (r-empty,c-empty)
evaluate true
when r = r-empty
if c-empty < c
*> shift left
perform varying c-to from c-empty by 1 until c-to > c
compute c-from = c-to + 1
move display-cell(r-empty,c-from) to display-cell(r-empty,c-to)
end-perform
else
*> shift right
perform varying c-to from c-empty by -1 until c-to < c
compute c-from = c-to - 1
move display-cell(r-empty,c-from) to display-cell(r-empty,c-to)
end-perform
end-if
move 00 to display-cell(r,c)
when c = c-empty
if r-empty < r
*>shift up
perform varying r-to from r-empty by 1 until r-to > r
compute r-from = r-to + 1
move display-cell(r-from,c-empty) to display-cell(r-to,c-empty)
end-perform
else
*> shift down
perform varying r-to from r-empty by -1 until r-to < r
compute r-from = r-to - 1
move display-cell(r-from,c-empty) to display-cell(r-to,c-empty)
end-perform
end-if
move 00 to display-cell(r,c)
when other
display 'invalid move'
end-evaluate
.
end program fifteen.

View file

@ -1,259 +0,0 @@
#15 Puzzle Game
$Script:Neighbours = @{
"1" = @("2","5")
"2" = @("1","3","6")
"3" = @("2","4","7")
"4" = @("3","8")
"5" = @("1","6","9")
"6" = @("2","5","7","10")
"7" = @("3","6","8","11")
"8" = @("4","7","12")
"9" = @("5","10","13")
"10" = @("6","9","11","14")
"11" = @("7","10","12","15")
"12" = @("8","11","0")
"13" = @("9","14")
"14" = @("10","13","15")
"15" = @("11","14","0")
"0" = @("12","15")
}
$script:blank = ''
#region XAML window definition
$xaml = @'
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
MinWidth="200"
Width ="333.333"
Title="15 Game"
Topmost="True" Height="398.001" VerticalAlignment="Center" HorizontalAlignment="Center">
<Grid HorizontalAlignment="Center" Height="285" Margin="0" VerticalAlignment="Center" Width="300">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Button x:Name="B_1" Content="01" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Height="72" FontSize="24"/>
<Button x:Name="B_2" Content="02" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Height="72" FontSize="24" Grid.Column="1"/>
<Button x:Name="B_3" Content="03" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Height="72" FontSize="24" Grid.Column="2"/>
<Button x:Name="B_4" Content="04" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Height="72" FontSize="24" Grid.Column="3"/>
<Button x:Name="B_5" Content="05" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Height="72" FontSize="24" Grid.Row="1"/>
<Button x:Name="B_6" Content="06" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Height="72" FontSize="24" Grid.Column="1" Grid.Row="1"/>
<Button x:Name="B_7" Content="07" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Height="72" FontSize="24" Grid.Column="2" Grid.Row="1"/>
<Button x:Name="B_8" Content="08" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Height="72" FontSize="24" Grid.Column="3" Grid.Row="1"/>
<Button x:Name="B_9" Content="09" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Height="72" FontSize="24" Margin="0,71,0,0" Grid.Row="1" Grid.RowSpan="2"/>
<Button x:Name="B_10" Content="10" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Height="72" FontSize="24" Grid.Column="1" Grid.Row="1" Margin="0,71,0,0" Grid.RowSpan="2"/>
<Button x:Name="B_11" Content="11" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Height="72" FontSize="24" Grid.Column="2" Grid.Row="1" Margin="0,71,0,0" Grid.RowSpan="2"/>
<Button x:Name="B_12" Content="12" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Height="72" FontSize="24" Grid.Column="3" Grid.Row="1" Margin="0,71,0,0" Grid.RowSpan="2"/>
<Button x:Name="B_13" Content="13" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Height="72" FontSize="24" Margin="0,71,0,0" Grid.Row="2" Grid.RowSpan="2"/>
<Button x:Name="B_14" Content="14" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Height="72" FontSize="24" Grid.Column="1" Grid.Row="2" Margin="0,71,0,0" Grid.RowSpan="2"/>
<Button x:Name="B_15" Content="15" HorizontalAlignment="Center" VerticalAlignment="Center" Width="75" Height="72" FontSize="24" Grid.Column="2" Grid.Row="2" Margin="0,71,0,0" Grid.RowSpan="2"/>
<Button x:Name="B_0" Content="00" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Height="72" FontSize="24" Grid.Column="3" Grid.Row="2" Margin="0,71,0,0" Grid.RowSpan="2"/>
<Button x:Name="B_Jumble" Grid.ColumnSpan="2" Content="Jumble Tiles" Grid.Column="1" HorizontalAlignment="Left" Height="23" Margin="0,81,0,-33" Grid.Row="3" VerticalAlignment="Top" Width="150"/>
</Grid>
</Window>
'@
#endregion
#region Code Behind
function Convert-XAMLtoWindow
{
param
(
[Parameter(Mandatory=$true)]
[string]
$XAML
)
Add-Type -AssemblyName PresentationFramework
$reader = [XML.XMLReader]::Create([IO.StringReader]$XAML)
$result = [Windows.Markup.XAMLReader]::Load($reader)
$reader.Close()
$reader = [XML.XMLReader]::Create([IO.StringReader]$XAML)
while ($reader.Read())
{
$name=$reader.GetAttribute('Name')
if (!$name) { $name=$reader.GetAttribute('x:Name') }
if($name)
{$result | Add-Member NoteProperty -Name $name -Value $result.FindName($name) -Force}
}
$reader.Close()
$result
}
function Show-WPFWindow
{
param
(
[Parameter(Mandatory=$true)]
[Windows.Window]
$Window
)
$result = $null
$null = $window.Dispatcher.InvokeAsync{
$result = $window.ShowDialog()
Set-Variable -Name result -Value $result -Scope 1
}.Wait()
$result
}
#endregion Code Behind
#region Convert XAML to Window
$window = Convert-XAMLtoWindow -XAML $xaml
#endregion
#region Define Event Handlers
function Test-Victory{
#Evaluate if all the labels are in the correct position
$victory = $true
foreach($num in 1..15){
if([int]$window."b_$num".Content -ne $num){$victory = $false;break}
}
return($victory)
}
function Test-Move($Number){
#Number is a string of the pressed button number.
if($Script:Neighbours[$Number] -contains $script:blank){
return($true)
} else {
return($false)
}
}
Function Move-Tile($Number,$Bypass){
if((!(Test-Victory)) -or $Bypass){
if(Test-Move $Number){
#Set the new window label
$window."B_$script:blank".content = $window."B_$Number".content
$window."B_$script:blank".background = $window."B_$Number".background
$window."B_$Number".background = "#FFDDDDDD"
#Set the new blank window label
$window."B_$Number".content = ''
#Enable the old blank tile
$window."B_$script:blank".isenabled = $true
#disable the new blank tile
$window."B_$Number".isenabled = $false
#set the new blank
$script:blank = $Number
}
}
}
function Move-TileRandom{
$lastmove = "1"
for($i=0;$i -lt 500;$i++){
$move = $Script:Neighbours[$script:blank] | Where-Object {$_ -ne $lastmove} | Get-Random
$lastmove = $move
Move-Tile $move $true
}
}
function Set-TileColour($Tile){
#I was curious about setting tiles to a checkerboard pattern at this stage. It's probably far better to just define it in the xaml
#Ignore the blank tile
if($Tile -ne 0){
#check if the row of the tile is odd or even
if((([math]::floor(($Tile - 1)/4)) % 2 -eq 0)){
#check if the tile is odd or even
if($Tile % 2 -eq 0){
$window."B_$Tile".Background = "#FFFF7878"
} else {
$window."B_$Tile".Background = "#FF9696FF"
}
}else{
if($Tile % 2 -eq 0){
$window."B_$Tile".Background = "#FF9696FF"
} else {
$window."B_$Tile".Background = "#FFFF7878"
}
}
} else {
$window.B_0.Background = "#FFDDDDDD"
}
}
$window.B_1.add_Click{
$n = "1"
move-tile $n
}
$window.B_2.add_Click{
$n = "2"
move-tile $n
}
$window.B_3.add_Click{
$n = "3"
move-tile $n
}
$window.B_4.add_Click{
$n = "4"
move-tile $n
}
$window.B_5.add_Click{
$n = "5"
move-tile $n
}
$window.B_6.add_Click{
$n = "6"
move-tile $n
}
$window.B_7.add_Click{
$n = "7"
move-tile $n
}
$window.B_8.add_Click{
$n = "8"
move-tile $n
}
$window.B_9.add_Click{
$n = "9"
move-tile $n
}
$window.B_10.add_Click{
$n = "10"
move-tile $n
}
$window.B_11.add_Click{
$n = "11"
move-tile $n
}
$window.B_12.add_Click{
$n = "12"
move-tile $n
}
$window.B_13.add_Click{
$n = "13"
move-tile $n
}
$window.B_14.add_Click{
$n = "14"
move-tile $n
}
$window.B_15.add_Click{
$n = "15"
move-tile $n
}
$window.B_0.add_Click{
$n = "0"
move-tile $n
}
$window.B_Jumble.add_Click{
Move-TileRandom
}
#endregion Event Handlers
(([math]::floor(("9" - 1)/4)) % 2 -eq 0)
#region Manipulate Window Content
#initial processing of tiles
$array = 0..15 | ForEach-Object {"{0:00}" -f $_}
0..15 | ForEach-Object {if($array[$_] -ne '00'){$window."B_$_".content = $array[$_]} else {$window."B_$_".content = '';$script:blank = "$_";$window."B_$_".isenabled = $false};Set-TileColour $_}
#Shove them around a bit
Move-TileRandom
#endregion
# Show Window
$result = Show-WPFWindow -Window $window

View file

@ -1,6 +0,0 @@
rebol [] random/seed now g: [style t box red [
if not find [0x108 108x0 0x-108 -108x0] face/offset - e/offset [exit]
x: face/offset face/offset: e/offset e/offset: x] across
] x: random repeat i 15 [append x:[] i] repeat i 15 [
repend g ['t mold x/:i random white] if find [4 8 12] i [append g 'return]
] append g [e: box] view layout g

View file

@ -1,108 +0,0 @@
'----------------15 game-------------------------------------
'WARNING: this script uses ANSI escape codes to position items on console so
'it won't work in Windows from XP to 8.1 where Microsoft removed ANSI support...
'Windows 10, 11 or 98 are ok!!!
option explicit
const maxshuffle=100 'level
dim ans0:ans0=chr(27)&"["
dim anscls:anscls=ans0 & "2J"
dim dirs:dirs=array(6,-1,-6,1)
dim a:a=array(-1,-1,-1,-1,-1,-1,_
-1, 1, 2, 3, 4,-1,_
-1, 5, 6, 7, 8,-1,_
-1, 9,10,11,12,-1,_
-1,13,14,15, 0,-1,_
-1,-1,-1,-1,-1,-1)
dim b(35)
dim pos0
dim s:s=Array("W+Enter: up Z+Enter: down A+Enter: left S+Enter right ",_
"Bad move!! ",_
"You did it! Another game? [y/n]+Enter ",_
"Bye! ")
do
shuffle
draw
toxy 10,1,s(0)
do
if usr(wait()) then
draw
toxy 10,1,s(0)
else
toxy 10,1,s(1)
end if
loop until checkend
toxy 10,1,s(2)
loop until wait()="n"
toxy 10,1,s(3)
function wait():
toxy 11,1,"":
wait=left(lcase(wscript.stdin.readline),1):
end function
sub toxy(x,y,s)
wscript.StdOut.Write ans0 & x & ";" & y & "H"& " "& s
end sub
sub draw
dim i,j
wscript.stdout.write anscls
for i=0 to 3 'row
for j=0 to 3 'col
toxy (j*2)+2,(i*3)+3,iif(b(j*6+i+7)<>0,b(j*6+i+7)," ")
next
next
toxy 10,1,""
end sub
function checkend
dim i
for i=0 to ubound(a)
if (b(i)<>a(i)) then checkend=false : exit function
next
checkend=true
end function
function move(d)
dim p1
p1=pos0+d
if b(p1) <>-1 then
b(pos0)=b(p1):
b(p1)=0:
pos0=p1:
move=true
else
move=false
end if
end function
sub shuffle
dim cnt,r,i
randomize timer
for i=0 to ubound(a):b(i)=a(i):next
pos0=28
cnt=0
do
r=int(rnd*4)
if move(dirs(r))=true then cnt=cnt+1
loop until cnt=maxshuffle
end sub
function iif(a,b,c): if a then iif=b else iif=c end if:end function
function usr(a)
dim d
select case lcase(a)
case "w" :d=-6
case "z" :d=6
case "a" :d=-1
case "s" :d=1
end select
usr= move(d)
end function