Search

Thursday, August 9, 2012

Day 1: Board Representation II



Well, let's put in practise the theory I learnt in the previous post. The board will be an array (I will use the class Vector) and in theory the size should be (n+2)*(n+1)-1. So, I will write some examples of this just to understand:

6x6 board = 8*7+1=57


01 02 03 04 05 06 07
08 09 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31 32 33 34 35
36 37 38 39 40 41 42
43 44 45 46 47 48 49
50 51 52 53 54 55 56 57

Borders will be at 1,2,3,4,5,6,7,8,15,22,29,36,43,50,51,52,53,54,55,56,57

9x9 board = 11*10+1=111

01 02 03 04 05 06 07 08 09 10
11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30
31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50
51 52 53 54 55 56 57 58 59 60
61 62 63 64 65 66 67 68 69 70
71 72 73 74 75 76 77 78 79 80
81 82 83 84 85 86 87 88 89 90
91 92 93 94 95 96 97 98 99 00
01 02 03 04 05 06 07 08 09 10 11

Borders will be at 1,2,3,4,5,6,7,8,9,10,11,21,31,41,51,61,71,81,91,101,111

So, lets say that borders will be in

  • 1 to n+1 
  • (n+1)*x+1 (x is a for from 1 to n)
  • (n+1)*(n+1) to (n+2)*(n+1)+1
Well, this is theory, let's see if it works. In the next entry I will put it in code and see if this really works like this.

No comments:

Post a Comment