Autor Beitrag
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Di 30.08.05 12:51 
Ich will das Spiel programmieren, bei dem man 9 Kästchen in 3 Spalten und 3 Reihen hat. Der erste Spieler macht irgendwo ein Kreuz und dann der zweite mit nem Kreis. Gewonnen hat wer zuerst 3 Symbole in einer Reihe hat. Meine Frage ist welche Komponente ich für die Kästchen nehmen soll. Wenn man draufklickt soll zum Beispiel ein Kreuz erscheinen.

Koller

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot


Zuletzt bearbeitet von Marco D. am Di 30.08.05 16:50, insgesamt 1-mal bearbeitet
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Di 30.08.05 12:57 
Das einfachste währe wohl, 9 Images zu nehmen, mit der entsprechenden Bildanzeige-Routine im OnClick, also
ausblenden Delphi-Quelltext
1:
2:
3:
4:
if Player=1 then
  (Sender as TImage).Picture.Bitmap.loadfromfile('kreuz.bmp')
else
  (Sender as TImage).Picture.Bitmap.loadfromfile('kreis.bmp')

Syntax-Fehler bitte selbstständig korrigieren.

Ebenso die Pfade intelligent ermitteln (Anwendungsverzeichnis), oder anstelle des Ladens aus der Datei ressourcenschonendere Varianten nehmen - z.B. im OnCreate die Bitmaps laden und dann immer darauf zugreifen.

_________________
We are, we were and will not be.
starsurfer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 334

Win 95, Win 98, Win XP, Win Vista, Linux
D5 Enterprise ,D2005, D6 Personal, Visual C++ Express 2005, C++ Builder 6 E, Dev-C++
BeitragVerfasst: Di 30.08.05 13:08 
wenn du nur mit "X" und "O" arbeitest, kannst du auch
ausblenden Delphi-Quelltext
1:
canvas.textout()					


nutzen, is einfacher als bild laden :)

siehe anhang (fünf gewinnt) :D
(is noch nit fertig udn de KI is noch reichlich blöd) :?

aba es zeigt dir wie´s gehen kann
Einloggen, um Attachments anzusehen!
_________________
GEIZ IST GEIL! - Ihr Sozialamt
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Di 30.08.05 16:20 
Das Spiel heißt übrigens auch TicTacToe :wink:

Ich hab das damals mit 9 Panels gemacht,
deren Caption ich einfach auf 'X' oder 'O' gesetzt habe.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 30.08.05 16:28 
Moin!

Guckst du hier.

cu
Narses
starsurfer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 334

Win 95, Win 98, Win XP, Win Vista, Linux
D5 Enterprise ,D2005, D6 Personal, Visual C++ Express 2005, C++ Builder 6 E, Dev-C++
BeitragVerfasst: Di 30.08.05 16:43 
*titel änder* :wink:

_________________
GEIZ IST GEIL! - Ihr Sozialamt
Amateur
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 777

(Win98, WinMe) WinXP Prof
D3 Prof, D6 Pers, D2k5 Pers., Turbo C++ Explorer
BeitragVerfasst: Di 30.08.05 16:45 
was mich daran interessieren würde si wie man die überprüfung macht ob jemand gewonnen hat....
ok man könnte 10 millionen if abfragen machen if kästchen oben links=x und kästchen mitte links=x und kästchen unten links =x then ... aber das wären dann wenn ich richtig gerechnet hab 9 stück für jeden spieler... bisschen viel geht das net kürzer?

_________________
"Kein dummes Gerede. Kein Rumrätseln. Denkt an nichts anderes mehr, nur noch an das, was vor euch liegt. Das ist die wahre Herausforderung. Ihr müßt euch vor euch selbst schützen, Leute." (Rennes in "Cube")
Beiträge: >700
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 30.08.05 16:53 
Moin!

user profile iconAmateur hat folgendes geschrieben:
was mich daran interessieren würde si wie man die überprüfung macht ob jemand gewonnen hat....
geht das net kürzer?

Schau dir doch mal das Beispielprog in dem Link da oben an. :wink:

cu
Narses
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 31.08.05 15:54 
Titel: Tic Tac toe
Wer hatte nochmal das Spiel 'fuenf.exe' hochgeladen ich weiß es nicht mehr. Meine Frage an ihn ist ob er auch mal den Source hochladen kann. Es interesiert mich wie man da Künstliche intelligenz reinbringen kann.

Zu der Frage wie man abfragt ob man gewonnen hat. Ich löse das so:

Bei Image1.click frage ich ab welcher Spieler (1 oder 2) dran ist und speicher dann :

feld1_spieler:='X';

Das bedeutet dass auf feld1 ein X steht (bzw. O wenn der andere dran ist) und dann mach ich:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
//prüfen ob jemand drei in einer Reihe hat
procedure checkwin;
begin
with form1 do
begin
//123
if (feld1_Spieler='X') and (feld2_spieler='X') and (feld3_Spieler='X') then
showmessage(spielername1+' hat gewonnen.');
//456
if (feld4_Spieler='X') and (feld5_spieler='X') and (feld6_Spieler='X') then
showmessage(spielername1+' hat gewonnen.');
//789
if (feld7_Spieler='X') and (feld8_spieler='X') and (feld9_Spieler='X') then
showmessage(spielername1+' hat gewonnen.');
//147
if (feld1_Spieler='X') and (feld4_spieler='X') and (feld7_Spieler='X') then
showmessage(spielername1+' hat gewonnen.');
//258
if (feld2_Spieler='X') and (feld5_spieler='X') and (feld8_Spieler='X') then
showmessage(spielername1+' hat gewonnen.');
//369
if (feld3_Spieler='X') and (feld6_spieler='X') and (feld9_Spieler='X') then
showmessage(spielername1+' hat gewonnen.');
//159
if (feld1_Spieler='X') and (feld5_spieler='X') and (feld9_Spieler='X') then
showmessage(spielername1+' hat gewonnen.');

end;
end;


So kann ich abfragen ob jemand gewonnen hat. Das gleiche müsste man dan halt für Spieler 2 nochmal schreiben. ICh bin mir zwar nicht sicher ob das alle Möglichkeiten sind aber ich denke das ist ok. Bitte um Verbersserngsvorschläge!

Danke koller

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Amateur
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 777

(Win98, WinMe) WinXP Prof
D3 Prof, D6 Pers, D2k5 Pers., Turbo C++ Explorer
BeitragVerfasst: Mi 31.08.05 16:25 
joa so wie koller das macht hab ich mir das auch gedacht...

bei dem link oben is es allerdings eleganter gelöst... macht man nen array von constanten mit (1,4,8) oder so und dann muss man überprüfen ob halt die xe eines spielers in soner combi im array vorhanden sind... aber si ziemlich komisch also ich bin noch net durchgestiegen....man kann auch die if abfragen in zwei functionen machen udn die dann als result boolean abfragen lassen ob die combo irgendwo vorkommt... besteht aber auch nur aus if abfragen.. man kann es zwar noch mit with do und ner case anweisung machen, wird dann etwas kürzer aber mit nem array find ich es besser...
man könnte es auch mit nem record machen in das man die gewinnkombos speichert... als string und dann testet man ob die zahlen der images alle drei in einem der strings vorkommen... läuft aber aufs gleiche raus wie array... is nur viell ress schonender...

Moderiert von user profile iconChristian S.: Code-Tags hinzugefügt, damit Smily nicht geparst wird

_________________
"Kein dummes Gerede. Kein Rumrätseln. Denkt an nichts anderes mehr, nur noch an das, was vor euch liegt. Das ist die wahre Herausforderung. Ihr müßt euch vor euch selbst schützen, Leute." (Rennes in "Cube")
Beiträge: >700