Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,33 @@
|
|||
// placeholder knights
|
||||
rank = ["♘"] * 8
|
||||
|
||||
// function to get a random free space from a to b, inclusive
|
||||
randFree = function(a, b)
|
||||
free = []
|
||||
for i in range(a, b)
|
||||
if rank[i] == "♘" then free.push i
|
||||
end for
|
||||
return free[rnd * free.len]
|
||||
end function
|
||||
|
||||
// place the king
|
||||
kingIdx = randFree(1, 6)
|
||||
rank[kingIdx] = "♔"
|
||||
|
||||
// place rooks
|
||||
rank[randFree(0, kingIdx - 1)] = "♖"
|
||||
rank[randFree(kingIdx + 1, 7)] = "♖"
|
||||
|
||||
// place bishops
|
||||
bishIdx = randFree(0, 7)
|
||||
rank[bishIdx] = "♗"
|
||||
while true
|
||||
i = randFree(0, 7)
|
||||
if i % 2 != bishIdx % 2 then break
|
||||
end while
|
||||
rank[i] = "♗"
|
||||
|
||||
// place queen
|
||||
rank[randFree(0, 7)] = "♕"
|
||||
|
||||
print join(rank, " ")
|
||||
Loading…
Add table
Add a link
Reference in a new issue