The following should work:
Plot3D[
Position[{Round[a + b], Round[a - b]}, Min[{Round[a + b], Round[a - b]}]][[1]],
{a, -1, 1},
{b, -1, 1},
MaxRecursion -> 6,
MeshFunctions -> {Ceiling@#3 + 0.001 &, #3 + 0.001 &, #1 &, #2 &},
MeshShading -> ({{{#, Directive[Darker@#, [email protected]] & /@ #}}} &@ColorData[16, "ColorList"]),
Mesh -> ({#, #, 10, 10} &@Range@10),
MeshStyle -> {Directive[Thick, Black], Directive[Thick, Black], Automatic, Automatic},
Exclusions -> None
]

For a more interesting function:
Plot3D[
Floor[2 Sin[a^2 + 2 b^2] + 2],
{a, -2, 2},
{b, -2, 2},
MaxRecursion -> 6,
MeshFunctions -> {Ceiling@#3 + 0.001 &, #3 + 0.001 &, #1 &, #2 &},
MeshShading -> ({{{Darker /@ #, #}}} &@ColorData[16, "ColorList"]),
Mesh -> ({#, #, 10, 10} &@Range@10),
MeshStyle -> {Directive[Thick, Black], Directive[Thick, Black], Automatic, Automatic},
Exclusions -> None
]

An explanation of the different options:
MaxRecursion
: Ensures that the edges of the plateaus are nice and sharp - increase/decrease as necessary
MeshFunctions
: We're using Mesh
to achieve the discrete colors instead of the blending done by ColorFunction
. The mesh specifications produce four meshes, one at the bottom of the "walls", the other at the top (the +0.001
prevents the lines from missing at a few points due to rounding)
MeshShading
: Specifies the color to use for the different regions. Here, we use one of the color lists (see ColorData
for a more complete list) in normal form and with Darker
to get the walls a bit different from the plateaus. The specification needs to be an array of depth 4 (as we have four meshes), where two meshes (x,y) shouldn't affect the color, hence the two single-element levels.
Mesh
: Specifies the actual positions of the four meshes - for both z-meshes, we specify all integers (the range needs to be adjusted depending on the plot), for x,y we specify that 10 lines should be drawn.
MeshStyle
: For the two z-meshes, we specify Directive[Thick,Black]
to increase visibility, the other two (x,y) we leave alone
Exclusions
: Needed to make sure the walls are plotted.
p
? Do the colors need to have any continuity? Or just more or less "random" colors for each integer? Also, possibly related: (58951). And if the function takes integer values as you write, you might want to look atDiscretePlot3D
$\endgroup$F[1]
toF[8]
are missing... And did you look into using other plots to visualize the results (e.g. the suggestedDiscretePlot3D
or others)?Plot3D
is really not designed for discrete data... If you really need to usePlot3D
, you could do something likeColorFunction->ColorData[16],ColorFunctionScaling->False
with any of the discrete color schemes $\endgroup$F[1]
toF[8]
and "function in 3D that takes integer values")... You can always edit the question to put the code where it belongs - also it is always nice to provide a minimal example showing the problem, instead of the full code (i.e. try to make a simple function that is enough to demonstrate the issue) $\endgroup$