Image

Imagespl wrote in Imagecpp

Storing a 2D Board

I wrote a game a few years ago that stores a board with three possible states at each square (OPEN, p_RED, p_BLUE). I have recently come back to this game and written the MiniMax for it. I would like to re-write it and use AlphaBeta.

I wrote it badly the first time, and coppied the board for every branch of MiniMax. Once I fix this, it will be faster, but still not as quick as I would like. My brother, (a CMU student) said that if I could fit the board onto the memory in the CPU, and not the RAM there is a *huge* increase in speed.

I am currently storing the board in a (STL) matrix (actually vector of vectors) of integers. This is wasting a lot of space. I cannot use bools because I have 3 states to worry about. The board ranges from 20x20 to 50x50.

How should I store the board so that it will take up as little space as possible? Is it true that I will get a large increase in speed if I fit the board onto the CPU's built in memory?