Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add kill by surronding #1

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
added some buttons in the menu
  • Loading branch information
Simondharcourt committed Sep 27, 2024
commit e292c523f29be9b3683fb7bccd94410d6638f3db
1 change: 0 additions & 1 deletion docs/Djambi-Rules/fr/Djambi_rules.aux
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
\relax
\providecommand{\transparent@use}[1]{}
\@writefile{toc}{\contentsline {section}{\numberline {1}Overview}{2}{}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {1.1}Déroulement}{2}{}\protected@file@percent }
\@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces Placement des pièces en début de partie.}}{2}{}\protected@file@percent }
Expand Down
Binary file modified docs/Djambi-Rules/fr/Djambi_rules.pdf
Binary file not shown.
Binary file modified docs/Djambi-Rules/fr/Djambi_rules.synctex.gz
Binary file not shown.
7 changes: 7 additions & 0 deletions docs/Djambi-Rules/fr/Djami_algo.aux
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
\relax
\@writefile{toc}{\contentsline {section}{\numberline {1}Overview}{3}{}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {1.1}Minimax}{3}{}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {1.2}Reinforcement}{3}{}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {2}Règles classiques}{4}{}\protected@file@percent }
\gdef\svg@ink@ver@settings{{\m@ne }{inkscape}{\m@ne }}
\gdef \@abspage@last{4}
Binary file added docs/Djambi-Rules/fr/Djami_algo.pdf
Binary file not shown.
Binary file added docs/Djambi-Rules/fr/Djami_algo.synctex.gz
Binary file not shown.
53 changes: 53 additions & 0 deletions docs/Djambi-Rules/fr/Djami_algo.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
\documentclass{article}
\usepackage{graphicx}
\usepackage{svg}
\usepackage[bottom=4cm]{geometry}

\begin{document}

\includegraphics[width=5in,height=7in]{media/image1.png}
\newpage

\tableofcontents

\newpage

\section{Overview}

Au niveau de l'algorithme, on pense à plusieurs stratégies en s'inspirant des échecs.

\subsection{Minimax}

Minimax est l'algorithme classique pour les jeux à deux joueurs. Il est basé sur la recherche d'arbre de jeu.
Il a pour avantage de ne pas avoir besoin d'entraînement. On appelle ça une heuristique.

Le concept est d'évaluer une situation en examinanant les coups et réponses possibles et en évaluant la nouvelle situation à chaque issue.
On s'appuie sur des branches et des feuilles dans cette heuristique. Une feuille est "l'état d'un plateau" en tant qu'instance d'objet.

Quelques challenges à relever avec le djambi:
- c'est un jeu à plus de 2 joueurs, avec des éliminations possibles
- il y a beaucoup d'états du jeu possibles
- il y a beaucoup de coup possible à chaque tour
- il y a parfois plusieurs actions à faire (choisir où se déplacer, choisir ou placer la pièce tuée..)
- il faut prendre en compte le moment où un joueur prend le pouvoir et peut jouer plus souvent.



\subsection{Reinforcement}

DeepZero a été entraîné avec un algorithme de renforcement. C'est une approche plus moderne et plus puissante que Minimax.
Il est basé sur l'apprentissage profond et l'entraînement sur des millions de parties.
Appliqué au Djambi, il faudrait entraîner un modèle sur des parties de Djambi pour qu'il apprenne à jouer.



\newpage



\section{Règles classiques}
La version historique du jeu est conçue par Jean Anesto en 1975.
Elle se déroule sur un plateau carré avec 4 joueurs.


\end{document}
4 changes: 4 additions & 0 deletions docs/Djambi-Rules/fr/Djami_algo.toc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
\contentsline {section}{\numberline {1}Overview}{3}{}%
\contentsline {subsection}{\numberline {1.1}Minimax}{3}{}%
\contentsline {subsection}{\numberline {1.2}Reinforcement}{3}{}%
\contentsline {section}{\numberline {2}Règles classiques}{4}{}%
Binary file added flutter/assets/rules/Djambi_rules.pdf
Binary file not shown.
1 change: 1 addition & 0 deletions flutter/devtools_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extensions:
1 change: 1 addition & 0 deletions flutter/ios/Flutter/Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
1 change: 1 addition & 0 deletions flutter/ios/Flutter/Release.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
44 changes: 44 additions & 0 deletions flutter/ios/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
use_frameworks!
use_modular_headers!

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
end

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
59 changes: 54 additions & 5 deletions flutter/lib/components/button.dart
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
import 'package:flame/components.dart';
import 'package:flame/events.dart';
import 'package:flame/extensions.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/painting.dart';
import 'package:flutter/material.dart' show SystemMouseCursors;

class Button extends PositionComponent with TapCallbacks {
mixin Hoverable on PositionComponent {
bool onHoverEnter(PointerHoverInfo info) => false;
bool onHoverExit(PointerHoverInfo info) => false;
}

class Button extends PositionComponent
with TapCallbacks, Hoverable, HasGameRef {
final String text;
final Paint paint;
final void Function() action;
final void Function()? onHover;
final void Function()? onExit;
final RRect _rect;
bool _isPressed =
false; // Variable d'état pour suivre si le bouton est pressé

Button({
required this.action,
required this.text,
this.onHover,
this.onExit,
Color color = const Color(0xff757575),
super.position,
required super.size,
super.anchor = Anchor.center,
}) : paint = Paint()..color = color,
_rect = RRect.fromRectAndRadius(
size!.toRect(),
Radius.circular(size.y / 4)
);
size!.toRect(), Radius.circular(size.y / 4));

@override
Future<void> onLoad() async {
Expand All @@ -32,7 +44,44 @@ class Button extends PositionComponent with TapCallbacks {
}

@override
void onTapUp(TapUpEvent event) => action();
void onTapUp(TapUpEvent event) {
if (kDebugMode) {
print('Button tapped: $text');
}
_isPressed = false; // Réinitialiser l'état lorsque le bouton est relâché
paint.color = const Color(0xff757575); // Réinitialiser la couleur
action(); // Exécuter l'action associée au bouton
super.onTapUp(event);
action();
}

@override
void onTapDown(TapDownEvent event) {
_isPressed = true; // Mettre à jour l'état lorsque le bouton est pressé
paint.color = const Color(
0xff555555); // Changer la couleur pour indiquer l'état pressé
super.onTapDown(event);
}

@override
bool onHoverEnter(PointerHoverInfo info) {
onHover?.call();
gameRef.mouseCursor = SystemMouseCursors.click;
if (kDebugMode) {
print('Hovering over button: $text');
}
return true;
}

@override
bool onHoverExit(PointerHoverInfo info) {
onExit?.call();
gameRef.mouseCursor = SystemMouseCursors.basic;
if (kDebugMode) {
print('Stopped hovering over button: $text');
}
return true;
}

@override
void render(Canvas canvas) {
Expand Down
91 changes: 91 additions & 0 deletions flutter/lib/components/dropdownbutton.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import 'package:flame/components.dart';
import 'package:flame/events.dart';
import 'package:flame/extensions.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/painting.dart';
import 'package:flutter/material.dart' show SystemMouseCursors;

mixin Hoverable on PositionComponent {
bool onHoverEnter(PointerHoverInfo info) => false;
bool onHoverExit(PointerHoverInfo info) => false;
}

class DropdownButton extends PositionComponent
with TapCallbacks, Hoverable, HasGameRef {
final String label;
final List<String> items;
final Paint paint;
final void Function(String) onItemSelected;
final void Function()? onHover;
final void Function()? onExit;
final RRect _rect;
bool _isExpanded = false;
late final TextComponent _labelComponent;
late final List<TextComponent> _itemComponents;

DropdownButton({
required this.label,
required this.items,
required this.onItemSelected,
this.onHover,
this.onExit,
Color color = const Color(0xff757575),
super.position,
required super.size,
super.anchor = Anchor.center,
}) : paint = Paint()..color = color,
_rect = RRect.fromRectAndRadius(
size!.toRect(), Radius.circular(size.y / 4));

@override
Future<void> onLoad() async {
await super.onLoad();
_labelComponent = TextComponent(
text: label,
anchor: Anchor.center,
position: size / 2,
);
await add(_labelComponent);

_itemComponents = items.map((item) {
return TextComponent(
text: item,
anchor: Anchor.center,
position: size / 2,
);
}).toList();
}

@override
void onTapUp(TapUpEvent event) {
if (kDebugMode) {
print('Dropdown tapped: $label');
}
_isExpanded = !_isExpanded;
if (_isExpanded) {
_showItems();
} else {
_hideItems();
}
}

void _showItems() {
for (var i = 0; i < _itemComponents.length; i++) {
var itemComponent = _itemComponents[i];
itemComponent.position =
Vector2(size.x / _itemComponents.length * (i + 0.5), size.y * 1.7);
add(itemComponent);
}
}

void _hideItems() {
for (var itemComponent in _itemComponents) {
remove(itemComponent);
}
}

@override
void render(Canvas canvas) {
canvas.drawRRect(_rect, paint);
}
}
2 changes: 2 additions & 0 deletions flutter/lib/components/game.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flame/game.dart';

import 'pages/home.dart';
import 'pages/play.dart';
import 'pages/settings.dart';

class DjambiGame extends FlameGame {
late final RouterComponent router;
Expand All @@ -12,6 +13,7 @@ class DjambiGame extends FlameGame {
routes: {
"home": Route(HomePage.new),
"play": Route(PlayPage.new),
'settings': Route(SettingsPage.new),
},
initialRoute: "home",
));
Expand Down
36 changes: 31 additions & 5 deletions flutter/lib/components/pages/home.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import 'package:flame/components.dart';
import 'package:flame/input.dart';
import 'package:flutter/material.dart' show SystemMouseCursors;
import 'package:url_launcher/url_launcher.dart';

import '../button.dart';
import '../game.dart';
import '../header.dart';

class HomePage extends PositionComponent with HasGameReference<DjambiGame> {
// @override
// bool get debugMode => true;

late final Button _startButton, _settingsButton, _aboutButton;
late final Button _startButton,
_settingsButton,
_aboutButton,
_advancedButton;

@override
Future<void> onLoad() async {
Expand All @@ -18,16 +23,36 @@ class HomePage extends PositionComponent with HasGameReference<DjambiGame> {
text: "Start",
size: Vector2(300, 75),
action: () => game.router.pushNamed("play"),
onHover: () {
game.mouseCursor = SystemMouseCursors.click;
},
onExit: () {
game.mouseCursor = SystemMouseCursors.basic;
},
),
_advancedButton = Button(
text: "Advanced",
size: Vector2(300, 75),
action: () {},
),
_aboutButton = Button(
text: "About & Rules",
size: Vector2(300, 75),
action: () {},
action: () async {
const url =
'assets/rules/Djambi_rules.pdf'; // Chemin relatif vers votre PDF
final uri = Uri.parse(url);
if (await canLaunchUrl(uri)) {
await launchUrl(uri);
} else {
throw 'Could not launch $url';
}
},
),
_settingsButton = Button(
text: "Settings",
size: Vector2(300, 75),
action: () {},
action: () => game.router.pushNamed("settings"),
),
]);
}
Expand All @@ -36,7 +61,8 @@ class HomePage extends PositionComponent with HasGameReference<DjambiGame> {
void onGameResize(Vector2 size) {
super.onGameResize(size);
_startButton.position = Vector2(size.x / 2, size.y / 3);
_aboutButton.position = _startButton.position + Vector2(0, 100);
_advancedButton.position = _startButton.position + Vector2(0, 100);
_aboutButton.position = _startButton.position + Vector2(0, 200);
_settingsButton.position = _aboutButton.position + Vector2(0, 100);
}
}
Loading