MCPcopy Create free account
hub / github.com/SimHacker/micropolis / RandDir

Function RandDir

MicropolisCore/src/CellEngine/src/cellengine.cpp:3723–3749  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3721Byte RandDir(Byte x);
3722
3723Byte RandDir(Byte x)
3724{
3725 long b = Rand8() < 128;
3726 Byte result = 0;
3727
3728 switch (ABCD(x)) {
3729
3730 case PART_A:
3731 result = b ? DIR_N : DIR_W;
3732 break;
3733
3734 case PART_B:
3735 result = b ? DIR_W : DIR_S;
3736 break;
3737
3738 case PART_C:
3739 result = b ? DIR_S : DIR_E;
3740 break;
3741
3742 case PART_D:
3743 result = b ? DIR_E : DIR_N;
3744 break;
3745
3746 }
3747
3748 return PART(x) | result | PAYLOAD(x);
3749}
3750
3751
3752void CellEngine::n_driven()

Callers 1

n_drivenMethod · 0.85

Calls 1

Rand8Function · 0.70

Tested by

no test coverage detected