From 1deeb2c5b0a33fa4b26158d4b2f5701556fb1d59 Mon Sep 17 00:00:00 2001 From: Ian C Date: Wed, 4 May 2011 13:51:28 +0000 Subject: Improved the hashing routine. --- dbox.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dbox.c b/dbox.c index 2827083..7f162a5 100644 --- a/dbox.c +++ b/dbox.c @@ -627,20 +627,25 @@ static hash_t ROL(hash_t p_val, int p_bits) } -/* This is almost certainly rubbish +/* This is slightly better than the previous hash */ static hash_t CreateHash(const level_t *p_level, const state_t *p_state) { + map_t *m; hash_t hash; int f; - hash = ROL(p_state->player.x, p_state->player.y); + m = CreateMap(p_level, p_state); + + hash = p_state->player.x * p_state->player.y; for(f = 0; f < p_level->no_boxes; f++) { - hash ^= ROL(p_state->box[f].x, p_state->box[f].y); + hash ^= ROL(m[f], f); } + free(m); + return hash; } -- cgit v1.2.3