fn battle_random_ai(battle: &mut Battle, party: usize)
{
	let party_side = battle.state().parties()[party].side();
	let party_active = battle.state().parties()[party].active_count();

	let mut party_targets = Vec::new();
	for party_index in 0..battle.state().parties().len()
	{
		if battle.state().parties()[party_index].side() != party_side
		{
			party_targets.push(party_index);
		}
	}
	let party_range = Range::new(0, party_targets.len());
	let mut rng = rand::thread_rng();

	for active_index in 0..party_active
	{
		let attack =
		{
			let active_member = battle.state().parties()[party].active_member(active_index).member;
			let attack_range = Range::new(0, active_member.attacks().len());
			attack_range.ind_sample(&mut rng)
		};
		let party_target = party_range.ind_sample(&mut rng);
		battle.command_add_attack(party, active_index, 0, party_target, attack);
	}
}
/// Randomly chooses a move and target.
Randomly chooses a move and target.
Randomly chooses a move and target .
fn battle_random_ai(battle: &mut Battle, party: usize)
{
	let party_side = battle.state().parties()[party].side();
	let party_active = battle.state().parties()[party].active_count();
	let mut party_targets = Vec::new();
	for party_index in 0..battle.state().parties().len()
	{
		if battle.state().parties()[party_index].side() != party_side
		{
			party_targets.push(party_index);
		}
	}
	let party_range = Range::new(0, party_targets.len());
	let mut rng = rand::thread_rng();
	for active_index in 0..party_active
	{
		let attack =
		{
			let active_member = battle.state().parties()[party].active_member(active_index).member;
			let attack_range = Range::new(0, active_member.attacks().len());
			attack_range.ind_sample(&mut rng)
		};
		let party_target = party_range.ind_sample(&mut rng);
		battle.command_add_attack(party, active_index, 0, party_target, attack);
	}
}
fn battle_random_ai ( battle : & mut Battle , party : usize ) { let party_side = battle . state ( ) . parties ( ) [ party ] . side ( ) ; let party_active = battle . state ( ) . parties ( ) [ party ] . active_count ( ) ; let mut party_targets = Vec :: new ( ) ; for party_index in 0 .. battle . state ( ) . parties ( ) . len ( ) { if battle . state ( ) . parties ( ) [ party_index ] . side ( ) != party_side { party_targets . push ( party_index ) ; } } let party_range = Range :: new ( 0 , party_targets . len ( ) ) ; let mut rng = rand :: thread_rng ( ) ; for active_index in 0 .. party_active { let attack = { let active_member = battle . state ( ) . parties ( ) [ party ] . active_member ( active_index ) . member ; let attack_range = Range :: new ( 0 , active_member . attacks ( ) . len ( ) ) ; attack_range . ind_sample ( & mut rng ) } ; let party_target = party_range . ind_sample ( & mut rng ) ; battle . command_add_attack ( party , active_index , 0 , party_target , attack ) ; } }
Randomly chooses a move and target.
Randomly chooses a move and target .
battle
&mut Battle
party
usize
battle
&mut Battle
party
usize