OmniThreadLibrary forum
News: SMF - Just Installed!
 
*
Welcome, Guest. Please login or register. May 17, 2012, 06:01:32 PM


Login with username, password and session length


Pages: [1]   Go Down

Author Topic: Parallel in Chess  (Read 293 times)

sum

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Parallel in Chess
« on: December 24, 2011, 09:07:53 PM »

I see Parallel example.But I still do not have idea to write chess program.

Please help,thanks

Code: [Select]
type
  Tboard=array[0..9,0..9] of integer;

var
Board:Tboard;

procedure TForm1.Button1Click(Sender: TObject);
var tempmovelist:Tstringlist;SideisRed:Boolean;Score,bestscore:Integer;bestmovestep:string;
begin
// for testing
    bestscore :=-1000;
   SideisRed := True;
   tempmovelist:= Tstringlist.create;
   try
     Makemovelist(Board,SideisRed,tempmovelist);
     Score := Parallel.ForEach(1, tempmovelist.count)
    .NumTasks(inpNumCPU.Value)
    .Aggregate() <-- write what thing here ?
    .Execute(
      procedure (const value: integer; var result: TOmniValue)  <-- Don't know right or not
      begin
           MinMax(Board,-SideisRed,score,depth-1);
           score := -score;
           If score > bestscore then
           begin
              bestscore :=score;
              bestmovestep := tempmovelist[???]  <-- Total don't know
           end;
      end
    );    
// output bestscore and bestmovestep
   finally
      tempmovelist.free;
end;
Logged

Primoz Gabrijelcic

  • Administrator
  • Hero Member
  • *****
  • Posts: 569
    • View Profile
    • Email
Re: Parallel in Chess
« Reply #1 on: December 27, 2011, 06:28:54 AM »

I don't think parallel for is a good way to solve parallel min/max search.
Logged

sum

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: Parallel in Chess
« Reply #2 on: December 27, 2011, 04:34:42 PM »

I might switch to lazarus 's parallel 's mtprocs solution...
http://wiki.lazarus.freepascal.org/Parallel_procedures
Logged
Pages: [1]   Go Up
 
 

Powered by MySQL Powered by PHP Powered by SMF 2.0.2 | SMF © 2006-2009, Simple Machines LLC

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM