fixed bots
This commit is contained in:
parent
36ce1385da
commit
8a60a181d1
@ -136,12 +136,19 @@ impl Player {
|
||||
}
|
||||
|
||||
// get 2 colours and something else
|
||||
if self.vbox.free[0].len() < 2 {
|
||||
let free_colours = self.vbox.free[0].iter().fold(0, |count, item| {
|
||||
match item.is_some() {
|
||||
true => count + 1,
|
||||
false => count
|
||||
}
|
||||
});
|
||||
if free_colours < 2 {
|
||||
break;
|
||||
}
|
||||
self.vbox_accept(0, 0).expect("could't accept colour 0");
|
||||
self.vbox_accept(0, 0).expect("could't accept colour 1");
|
||||
self.vbox_accept(group_i, 0).expect("could't accept group 0");
|
||||
debug!("Looping");
|
||||
self.bot_vbox_accept(0).expect("could't accept colour 0");
|
||||
self.bot_vbox_accept(0).expect("could't accept colour 1");
|
||||
self.bot_vbox_accept(group_i).expect("could't accept group 0");
|
||||
}
|
||||
|
||||
// info!("{:?}", self.vbox.bound);
|
||||
@ -168,6 +175,11 @@ impl Player {
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
pub fn bot_vbox_accept(&mut self, group: usize) -> Result<&mut Player, Error> {
|
||||
self.vbox.bot_accept(group)?;
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
pub fn vbox_accept(&mut self, group: usize, index: usize) -> Result<&mut Player, Error> {
|
||||
self.vbox.accept(group, index)?;
|
||||
Ok(self)
|
||||
|
||||
@ -128,6 +128,11 @@ impl Vbox {
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
pub fn bot_accept(&mut self, i: usize) -> Result<&mut Vbox, Error> {
|
||||
let buy_index = self.free[i].iter().position(|item| item.is_some());
|
||||
self.accept(i, buy_index.expect("no valid buys"))
|
||||
}
|
||||
|
||||
pub fn reclaim(&mut self, i: usize) -> Result<&mut Vbox, Error> {
|
||||
self.bound.get(i).ok_or(format_err!("no item at index {:?}", i))?;
|
||||
let reclaimed = self.bound.remove(i);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user