From 7ce26fd5ec5c918f37a8914f3eee3feebb9cc3f9 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 3 Jun 2019 15:36:24 +0200 Subject: [PATCH] Hunting Grounds in >4-valent tilings --- game.cpp | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/game.cpp b/game.cpp index b8918426..68d558fe 100644 --- a/game.cpp +++ b/game.cpp @@ -6862,26 +6862,32 @@ int ambush(cell *c, eItem what) { cell *clast = NULL; cell *ccur = c0; int v = VALENCE; - for(int tries=0; tries<10000; tries++) { - cell *c2 = NULL; - if(v == 3) { - forCellEx(c1, ccur) - if(c1 != clast && cl.listed(c1) && cl.getdist(c1) == d) - c2 = c1; - } - else { - for(int i=0; itype; i++) { - cell *c1 = (cellwalker(ccur, i) + wstep + 1).peek(); - if(!c1) continue; - if(c1 != clast && cl.listed(c1) && cl.getdist(c1) == d) - c2 = c1; + if(v > 4) { + for(cell *c: cl.lst) if(cl.getdist(c) == d) around.push_back(c); + hrandom_shuffle(&around[0], isize(around)); + } + else { + for(int tries=0; tries<10000; tries++) { + cell *c2 = NULL; + if(v == 3) { + forCellEx(c1, ccur) + if(c1 != clast && cl.listed(c1) && cl.getdist(c1) == d) + c2 = c1; } + if(v == 4) { + for(int i=0; itype; i++) { + cell *c1 = (cellwalker(ccur, i) + wstep + 1).peek(); + if(!c1) continue; + if(c1 != clast && cl.listed(c1) && cl.getdist(c1) == d) + c2 = c1; + } + } + if(!c2) break; + if(c2->land == laHunting && c2->wall == waNone && c2->monst == moNone) + around.push_back(c2); + clast = ccur; ccur = c2; + if(c2 == c0) break; } - if(!c2) break; - if(c2->land == laHunting && c2->wall == waNone && c2->monst == moNone) - around.push_back(c2); - clast = ccur; ccur = c2; - if(c2 == c0) break; } int N = isize(around); int dogs = ambushSize(c, what);