How to draw board

Discussion of Common Lisp
Post Reply
adel
Posts: 1
Joined: Fri Sep 13, 2013 4:19 am

How to draw board

Post by adel » Sat Sep 28, 2013 6:59 am

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)

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

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

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

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

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

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

pjstirling
Posts: 166
Joined: Sun Nov 28, 2010 4:21 pm

Re: How to draw board

Post by pjstirling » Sun Sep 29, 2013 11:40 am

Use nested DOTIMES loops

Pixel_Outlaw
Posts: 43
Joined: Mon Aug 26, 2013 9:24 pm

Re: How to draw board

Post by Pixel_Outlaw » Mon Sep 30, 2013 5:23 pm

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.

Post Reply