This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

How to draw board

3 posts · 2712 views

How I can draw grid ( square board 5x5) using Lisp?
Here is an example (I am sorry my drawing is very bad!!) .. (each cell has to be locked cells but I could not draw this here and I could not upload image that can explain everything)
The board should be consists of + (in corners) and - (in the edges) ( Plus and Minus)

+ - - - - -+- - - -- - -+- - - -- - - -+- - - - - - +- - - - - -+

+ - - - - -+- - -- - - -+- - - - - - -+- - - - - - +- - - - - -+

+ - - - - -+- - -- - - -+- - - - - - -+- - - - - - +- - - - - -+

+ - - - - -+- - -- - - -+- - - - - - -+- - - - - - +- - - - -- +

+ - - - - -+- - -- - - -+- - -- - - - -+- - - - - - +- - - -- - -+

+ - - - - -+- - -- - - -+- - - - - - -+- - - - - - +- - - - - -+

Re: How to draw board

Use nested DOTIMES loops

Re: How to draw board

Give this a try:
(defun draw-board (num-across num-down square-width)
  (dotimes (y num-down)
    (dotimes (x num-across)
      (princ "+")
      (dotimes (z square-width)
	(princ "-")))
    (princ "+")
    (format t "~%")))
You could also modify this to draw vertical bars | on the sides but that isn't what your picture showed.