Compare commits
No commits in common. "3d01e8fe06b81a35f42984b6c650e06e8673944c" and "27fc08c47d0d4b32fec2cfe766ad0fc04f533a35" have entirely different histories.
3d01e8fe06
...
27fc08c47d
|
|
@ -58,17 +58,12 @@ impl GameRunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_event(&mut self, event: &GameEvent) -> Option<GameEvent> {
|
pub fn handle_event(&mut self, event: &GameEvent) -> Option<GameEvent> {
|
||||||
if event == &GameEvent::PlayError {
|
if !self.state.validate(event) {
|
||||||
|
println!("event not valid : {:?}", event);
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let valid_event = if self.state.validate(event) {
|
// println!("consuming {:?}", event);
|
||||||
self.state.consume(event);
|
self.state.consume(event);
|
||||||
event
|
|
||||||
} else {
|
|
||||||
println!("{}", self.state);
|
|
||||||
println!("event not valid : {:?}", event);
|
|
||||||
&GameEvent::PlayError
|
|
||||||
};
|
|
||||||
|
|
||||||
// chain all successive bot actions
|
// chain all successive bot actions
|
||||||
if self.bots.is_empty() {
|
if self.bots.is_empty() {
|
||||||
|
|
@ -79,7 +74,7 @@ impl GameRunner {
|
||||||
let bot_events: Vec<GameEvent> = self
|
let bot_events: Vec<GameEvent> = self
|
||||||
.bots
|
.bots
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.filter_map(|bot| bot.handle_event(valid_event))
|
.filter_map(|bot| bot.handle_event(event))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
// if bot_events.len() > 1 {
|
// if bot_events.len() > 1 {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import store
|
import trictrac
|
||||||
# import trictrac
|
|
||||||
|
|
||||||
game = store.TricTrac()
|
game = trictrac.TricTrac()
|
||||||
print(game.get_state()) # "Initial state"
|
print(game.get_state()) # "Initial state"
|
||||||
|
|
||||||
moves = game.get_available_moves()
|
moves = game.get_available_moves()
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
import gymnasium as gym
|
import gymnasium as gym
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from gymnasium import spaces
|
from gymnasium import spaces
|
||||||
# import trictrac # module Rust exposé via PyO3
|
import trictrac # module Rust exposé via PyO3
|
||||||
import store # module Rust exposé via PyO3
|
|
||||||
from typing import Dict, List, Tuple, Optional, Any, Union
|
from typing import Dict, List, Tuple, Optional, Any, Union
|
||||||
|
|
||||||
class TricTracEnv(gym.Env):
|
class TricTracEnv(gym.Env):
|
||||||
|
|
@ -14,7 +13,7 @@ class TricTracEnv(gym.Env):
|
||||||
super(TricTracEnv, self).__init__()
|
super(TricTracEnv, self).__init__()
|
||||||
|
|
||||||
# Instancier le jeu
|
# Instancier le jeu
|
||||||
self.game = store.TricTrac()
|
self.game = trictrac.TricTrac()
|
||||||
|
|
||||||
# Stratégie de l'adversaire
|
# Stratégie de l'adversaire
|
||||||
self.opponent_strategy = opponent_strategy
|
self.opponent_strategy = opponent_strategy
|
||||||
|
|
|
||||||
|
|
@ -331,9 +331,6 @@ impl GameState {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlayError => {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We couldn't find anything wrong with the event so it must be good
|
// We couldn't find anything wrong with the event so it must be good
|
||||||
|
|
@ -482,7 +479,6 @@ impl GameState {
|
||||||
TurnStage::RollDice
|
TurnStage::RollDice
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
PlayError => {}
|
|
||||||
}
|
}
|
||||||
self.history.push(valid_event.clone());
|
self.history.push(valid_event.clone());
|
||||||
}
|
}
|
||||||
|
|
@ -624,7 +620,6 @@ pub enum GameEvent {
|
||||||
player_id: PlayerId,
|
player_id: PlayerId,
|
||||||
moves: (CheckerMove, CheckerMove),
|
moves: (CheckerMove, CheckerMove),
|
||||||
},
|
},
|
||||||
PlayError,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GameEvent {
|
impl GameEvent {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue