mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-30 07:29:54 +00:00
rogueviz:: sag:: fixed position and move-to
This commit is contained in:
parent
a25a476835
commit
a45a02d4df
@ -47,6 +47,8 @@ void saiter() {
|
||||
for(int ii=0; ii<s; ii++) sid2 = hrand_elt(neighbors[sid2]);
|
||||
}
|
||||
int t2 = allow_doubles ? -1 : sagnode[sid2];
|
||||
|
||||
if(fixed_position[t1] || (t2 >= 0 && fixed_position[t2])) return;
|
||||
|
||||
sagnode[sid1] = -1; sagid[t1] = -1;
|
||||
sagnode[sid2] = -1; if(t2 >= 0) sagid[t2] = -1;
|
||||
|
@ -28,6 +28,8 @@ vector<edgeinfo> sagedges;
|
||||
vector<vector<int>> edges_yes, edges_no;
|
||||
vector<vector<pair<int, double>>> edge_weights;
|
||||
|
||||
vector<bool> fixed_position;
|
||||
|
||||
ld edgepower=1, edgemul=1;
|
||||
|
||||
void init();
|
||||
@ -46,6 +48,8 @@ void prepare_graph() {
|
||||
|
||||
edges_yes.clear(); edges_yes.resize(DN);
|
||||
edges_no.clear(); edges_no.resize(DN);
|
||||
|
||||
fixed_position.clear(); fixed_position.resize(DN);
|
||||
|
||||
for(int i=0; i<DN; i++) for(int j=0; j<DN; j++) if(i != j) {
|
||||
if(alledges.count({i, j}))
|
||||
@ -386,6 +390,26 @@ int data_read_args() {
|
||||
PHASE(3); shift(); sag::save_sag_solution(args());
|
||||
}
|
||||
|
||||
else if(argis("-sag-fix")) {
|
||||
shift(); int id = getid(args());
|
||||
if(id >= isize(sagid)) throw hr_exception("bad id in -sag-fix");
|
||||
fixed_position[id] = true;
|
||||
}
|
||||
|
||||
else if(argis("-sag-move-to")) {
|
||||
shift(); int sid1 = getid(args());
|
||||
if(sid1 < 0 || sid1 >= isize(sagid)) throw hr_exception("bad id in -sag-move-to");
|
||||
shift(); int t2 = argi();
|
||||
if(t2 < 0 || t2 >= isize(sagnode)) throw hr_exception("bad id in -sag-move-to");
|
||||
int sid2 = sagid[t2];
|
||||
int t1 = allow_doubles ? -1 : sagnode[sid1];
|
||||
sagnode[sid1] = t2; sagid[t2] = sid1;
|
||||
if(sid2 >= 0) sagnode[sid2] = t1; sagid[t1] = sid2;
|
||||
compute_cost();
|
||||
create_viz();
|
||||
}
|
||||
|
||||
|
||||
else return 1;
|
||||
#endif
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user