From 487b25ace08b751efd0170a7b0d781bf3984007c Mon Sep 17 00:00:00 2001 From: lorien420 Date: Thu, 24 Mar 2005 18:27:20 +0000 Subject: [PATCH] - Fixed addToQueue assertion bug - Added random excess shatter to AI player. --- src/ComputerPlayerAI.cxx | 12 +++++------- src/Game.cxx | 12 +----------- src/GarbageGenerator.cxx | 25 ++++++++++++------------- src/GarbageGenerator.h | 2 ++ 4 files changed, 20 insertions(+), 31 deletions(-) diff --git a/src/ComputerPlayerAI.cxx b/src/ComputerPlayerAI.cxx index acca718..fdd2d7a 100644 --- a/src/ComputerPlayerAI.cxx +++ b/src/ComputerPlayerAI.cxx @@ -110,14 +110,12 @@ void ComputerPlayerAI::shatter() last_shatter_height = garbageQueue()->removeToFirstGray(); MESSAGE(last_shatter_height << " shattered and " << garbageQueue()->height() << " remaining."); if (gray_height != 0) assert(garbageQueue()->height() != 0); - /* - int gray_height = garbageQueue()->specialHeight(); - if (gray_height > 0) { - last_shatter_height *= gray_height + 1; - MESSAGE("Gray mult: " << gray_height + 1); - LOG("Gray mult: " << gray_height + 1); + loopi(last_shatter_height) { + if (Random::chanceIn(GC_GARBAGE_TO_GARBAGE_SHATTER)) { + garbageQueue()->add(1, 6, GF_NORMAL); + MESSAGE("Adding garbage on AI shatter " << garbageQueue()->height()); + } } - */ } else { state = AI_WAITING; last_shatter_height = 0; diff --git a/src/Game.cxx b/src/Game.cxx index e7bb09a..7bc007d 100644 --- a/src/Game.cxx +++ b/src/Game.cxx @@ -459,19 +459,9 @@ void Game::idlePlay ( ) if (state & GS_PAUSED) MessageManager::freeMessage(); - if (MetaState::mode & CM_SOLO) + if ((MetaState::mode & CM_SOLO) && !(MetaState::mode & CM_AI)) state = Score::gameFinish(); - cerr << "Past game finish... " << endl; - fprintf(stderr, "%x\n", state); - if (MetaState::mode & CM_AI) { - cerr << "In CM_AI" << endl; - cerr << "Won? " << (state & GS_WON) << endl; - step_play = false; - //state = ComputerPlayer::gameFinish(); - cerr << "Won? " << (state & GS_WON) << endl; - } - if (state & GS_LOST) MetaState::gameLoss(); else diff --git a/src/GarbageGenerator.cxx b/src/GarbageGenerator.cxx index 074886a..30754da 100644 --- a/src/GarbageGenerator.cxx +++ b/src/GarbageGenerator.cxx @@ -152,30 +152,29 @@ void GarbageGenerator::addToQueue ( CommunicationBuffer &buffer ) addToQueue(buffer.garbage, buffer.count); } +void GarbageGenerator::addToQueue (uint32 height, uint32 width, uint32 flavor, uint32 stamp) +{ + assert(height <= GC_PLAY_HEIGHT); + assert(width <= GC_PLAY_WIDTH); + if (!GarbageManager::isSpecialFlavor(flavor)) + dealLocalGarbage(height, width, flavor, stamp); + else + dealSpecialLocalGarbage(flavor, stamp); +} + void GarbageGenerator::addToQueue ( GarbageQueueElement *element ) { int stamp = Game::time_step; if (!element) return; GarbageQueueElement e = *element; - assert(e.height <= GC_PLAY_HEIGHT); - assert(e.width <= GC_PLAY_WIDTH); - if (!GarbageManager::isSpecialFlavor(e.flavor)) - dealLocalGarbage(e.height, e.width, e.flavor, stamp); - else - dealSpecialLocalGarbage(e.flavor, stamp); + addToQueue(e.height, e.width, e.flavor, stamp); } void GarbageGenerator::addToQueue ( BufferElement *garbage, size_t size ) { for (size_t n = 0; n < size; n++) { BufferElement e = garbage[n]; - MESSAGE("h " << e.height << " w " << e.width << " stamp " << e.time_stamp << endl); - assert(e.height < GC_PLAY_HEIGHT); - assert(e.width < GC_PLAY_WIDTH); - if (!GarbageManager::isSpecialFlavor(e.flavor)) - dealLocalGarbage(e.height, e.width, e.flavor, e.time_stamp); - else - dealSpecialLocalGarbage(e.flavor, e.time_stamp); + addToQueue(e.height, e.width, e.flavor, e.time_stamp); } } diff --git a/src/GarbageGenerator.h b/src/GarbageGenerator.h index d8bb7bc..487f2c7 100644 --- a/src/GarbageGenerator.h +++ b/src/GarbageGenerator.h @@ -58,6 +58,8 @@ public: static void addToQueue ( GarbageQueueElement *e ); static void addToQueue ( CommunicationBuffer &buffer ); static void addToQueue ( BufferElement garbage[], size_t size ); + static void addToQueue ( uint32 height, uint32 width, uint32 flavor, uint32 stamp ); + private: static void sendGarbage ( int height, int width, int flavor ); -- 2.11.4.GIT