Page 1 of 1

How to draw board

Posted: Sat Sep 28, 2013 6:59 am
by adel
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

Posted: Sun Sep 29, 2013 11:40 am
by pjstirling
Use nested DOTIMES loops

Re: How to draw board

Posted: Mon Sep 30, 2013 5:23 pm
by Pixel_Outlaw
Give this a try:

Code: Select all

(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.