PageSourceSearch

https://www.funnudge.com/_next/static/chunks/3668.285780b23a3a6387.js

js funnudge.com collected 2026-10-02 01:31:06 UTC 10,439 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3668],{3668:(e,t,n)=>{n.r(t),n.d(t,{default:()=>M});var r=n(5155),a=n(2115),o=n(7548),s=n(5833),i=n(6319),l=n(7194),d=n(1175),c=n(4107),u=n(98),p=n(3253);let h=e=>new o.Pq0((7&e)-3.5,.02+.07,3.5-(e>>3)),m=[[-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1]],f=()=>{let e=new Int8Array(64);return e[27]=1,e[36]=1,e[28]=2,e[35]=2,e},g=(e,t,n)=>{if(0!==e[t])return[];let r=1===n?2:1,a=t>>3,o=7&t,s=[];for(let[t,i]of m){let l=a+t,d=o+i,c=[];for(;l>=0&&l<8&&d>=0&&d<8&&e[8*l+d]===r;)c.push(8*l+d),l+=t,d+=i;c.length&&l>=0&&l<8&&d>=0&&d<8&&e[8*l+d]===n&&s.push(...c)}return s},w=(e,t)=>{let n=[];for(let r=0;r<64;r++)g(e,r,t).length&&n.push(r);return n},x=[120,-20,20,5,5,20,-20,120,-20,-40,-5,-5,-5,-5,-40,-20,20,-5,15,3,3,15,-5,20,5,-5,3,3,3,3,-5,5,5,-5,3,3,3,3,-5,5,20,-5,15,3,3,15,-5,20,-20,-40,-5,-5,-5,-5,-40,-20,120,-20,20,5,5,20,-20,120],b=(e,t)=>{let n=1===t?2:1,r=0;for(let a=0;a<64;a++)e[a]===t?r+=x[a]:e[a]===n&&(r-=x[a]);return r+(w(e,t).length-w(e,n).length)*3},v=(e,t,n)=>{let r=e.slice(),a=g(e,t,n);for(let e of(r[t]=n,a))r[e]=n;return r},y=(e,t,n,r,a)=>{let o=w(e,t);if(0===n)return{sq:-1,score:b(e,2)};if(0===o.length)return 0===w(e,1===t?2:1).length?{sq:-1,score:b(e,2)}:{sq:-1,score:y(e,1===t?2:1,n-1,r,a).score};let s=2===t,i={sq:o[0],score:s?-1/0:1/0};for(let l of o){let o=y(v(e,l,t),1===t?2:1,n-1,r,a).score;if(s?(o>i.score&&(i={sq:l,score:o}),r=Math.max(r,o)):(o<i.score&&(i={sq:l,score:o}),a=Math.min(a,o)),a<=r)break}return i};function M(){let e=(0,a.useRef)(null),[t,n]=(0,a.useState)("ai"),[m,x]=(0,a.useState)("medium"),[b,M]=(0,a.useState)({turn:1,over:!1,banner:"",light:2,dark:2}),[N,j]=(0,a.useState)(!1),k=(0,a.useRef)("ai"),S=(0,a.useRef)("medium");k.current=t,S.current=m;let E=(0,a.useRef)({restart:()=>{}});(0,a.useEffect)(()=>{let t=e.current;if(!t)return;let n=(0,u.cC)(t,{fov:42,clear:2765637,shadows:!0,bloom:{strength:.16,radius:.4,threshold:.9}}),{scene:r,camera:a,renderer:m}=n;m.toneMapping=o.FV;let x=new o.BdL(m),b=x.fromScene(new i.l,.06).texture;r.environment=b,x.dispose(),m.toneMappingExposure=.88,r.add(new o.dth(0xffd9b0,2898472,.5));let N=new o.ZyN(0xffc98a,1.15);N.position.set(6,11,5),N.castShadow=!0,N.shadow.mapSize.set(1024,1024),N.shadow.camera.left=-7,N.shadow.camera.right=7,N.shadow.camera.top=7,N.shadow.camera.bottom=-7,N.shadow.camera.far=40,N.shadow.bias=-2e-4,r.add(N);let C=new o.ZyN(9348351,.45);C.position.set(-7,6,-8),r.add(C);let D=(0,l.W)(r),I=(0,p.xX)(),R=new o.eaF(new o.iNn(9.4,.5,9.4),new o._4j({map:I,roughness:.42,metalness:.05}));R.position.y=-.26,R.castShadow=!0,R.receiveShadow=!0,r.add(R);let F=(0,p.Ub)(),q=new o.eaF(new o.iNn(8,.16,8),new o.uSd({map:F,roughness:.45,clearcoat:.22,clearcoatRoughness:.5,envMapIntensity:.55}));q.position.y=-.06,q.receiveShadow=!0,r.add(q);let z=new o.eaF(new o.bdM(8,8),new o.V9B({visible:!1}));z.rotation.x=-Math.PI/2,z.position.y=.02,r.add(z);let A=(0,p.sx)(),P=(0,p.o1)(),_=new o.uSd({map:A,roughness:.36,clearcoat:.5,clearcoatRoughness:.3,envMapIntensity:.85}),L=new o.uSd({map:P,roughness:.32,clearcoat:.6,clearcoatRoughness:.25,envMapIntensity:1}),Y=new o._4j({color:2760986,roughness:.7}),B=new o.Ho_(.4,.4,.14,44),O=new o.GOR((()=>{let e=document.createElement("canvas");e.width=128,e.height=128;let t=e.getContext("2d"),n=t.createRadialGradient(64,64,6,64,64,62);return n.addColorStop(0,"rgba(0,0,0,0.4)"),n.addColorStop(.7,"rgba(0,0,0,0.16)"),n.addColorStop(1,"rgba(0,0,0,0)"),t.fillStyle=n,t.fillRect(0,0,128,128),e})()),T=new o.bdM(.95,.95),G=new o.V9B({map:O,transparent:!0,depthWrite:!1});a.position.set(0,8.2,9.2);let V=new s.N(a,m.domElement);V.target.set(0,0,0),V.enablePan=!1,V.enableDamping=!0,V.dampingFactor=.08,V.minDistance=6,V.maxDistance=16,V.minPolarAngle=.25,V.maxPolarAngle=1.25;let W=new o.YJl;r.add(W);let X=new o.tcD(.16,24),J=new o.V9B({color:3462041,transparent:!0,opacity:.75,depthWrite:!1}),Z=[],H=new Map,U=f(),K=1,Q=!1,$=0,ee=(e,t,n)=>{let a=(e=>{let t=new o.YJl,n=new o.eaF(B,[Y,_,L]);n.castShadow=!0,n.receiveShadow=!0,t.add(n);let r=new o.eaF(T,G);return r.rotation.x=-Math.PI/2,r.position.y=-.068,r.userData.shared=!0,t.add(r),t.rotation.x=1===e?0:Math.PI,t})(t);a.position.copy(h(e)),r.add(a),H.set(e,{group:a,color:t}),n&&(a.scale.setScalar(.01),Z.push({group:a,kind:"pop",t:0,dur:.25,fromRot:a.rotation.x}))},et=e=>{r.remove(e.group),e.group.traverse(e=>{e.geometry&&!e.userData.shared&&e.geometry.dispose()})},en=()=>{for(let e of H.values())et(e);H=new Map;for(let e=0;e<64;e++)U[e]&&ee(e,U[e],!1)},er=()=>{let{light:e,dark:t}=(e=>{let t=0,n=0;for(let r=0;r<64;r++)1===e[r]?t++:2===e[r]&&n++;return{light:t,dark:n}})(U),n=0===w(U,K).length&&0===w(U,1===K?2:1).length,r="";if(n){let n=e>t?1:2*(t>e);r="ai"===k.current?1===n?"\uD83C\uDFC6 You win!":2===n?"\uD83D\uDC80 The AI wins":"\uD83E\uDD1D Draw!":0===n?"\uD83E\uDD1D Draw!":1===n?"⚪ Light wins!":"⚫ Dark wins!",(0,d._O)(1===n||"2p"===k.current?"win":"lose"),(0,c.q7)("reversi-3d","ai"===k.current?+(1===n):1)}M({turn:K,over:n,banner:r,light:e,dark:t}),W.clear();let a="2p"===k.current?K:1;if("ai"!==k.current||K===a)for(let e of w(U,K)){let t=new o.eaF(X,J);t.rotation.x=-Math.PI/2,t.position.copy(h(e)),t.position.y=.05,W.add(t)}return n},ea=e=>{let t=g(U,e,K);0!==t.length&&(Q=!0,W.clear(),U=v(U,e,K),ee(e,K,!0),(0,d._O)("tap"),t.forEach((e,t)=>{let n=H.get(e);n&&(n.color=K,setTimeout(()=>{Z.push({group:n.group,kind:"flip",t:0,dur:.4,fromRot:n.group.rotation.x}),(0,d._O)("tap")},60+45*t))}),setTimeout(()=>{Q=!1;let e=1===K?2:1;w(U,e).length>0?K=e:w(U,K).length>0||(K=e),er()||eo()},120+45*t.length+260))},eo=()=>
1{if("ai"!==k.current||2!==K)return;let e=++$;j(!0),setTimeout(()=>{let t;if(e!==$)return;let n="easy"===S.current?1:"medium"===S.current?3:5,r=w(U,2);"easy"===S.current&&.4>Math.random()?t=r[Math.random()*r.length|0]:(t=y(U,2,n,-1/0,1/0).sq)<0&&(t=r[0]),j(!1),e===$&&void 0!==t&&ea(t)},420)},es=new o.tBo,ei=new o.I9Y,el=0,ed=0,ec=e=>{el=e.clientX,ed=e.clientY},eu=e=>{if(Math.hypot(e.clientX-el,e.clientY-ed)>7||Q||"ai"===k.current&&2===K)return;let t=m.domElement.getBoundingClientRect();ei.x=(e.clientX-t.left)/t.width*2-1,ei.y=-(2*((e.clientY-t.top)/t.height))+1,es.setFromCamera(ei,a);let n=es.intersectObject(z,!1);if(!n.length)return;let r=n[0].point,o=Math.round(r.x+3.5),s=Math.round(3.5-r.z);o<0||o>7||s<0||s>7||ea(8*s+o)};m.domElement.addEventListener("pointerdown",ec),m.domElement.addEventListener("pointerup",eu),E.current={restart:()=>{$++,j(!1),U=f(),K=1,Q=!1,Z=[],en(),er()}},en(),er();let ep=0,eh=performance.now(),em=1e3/60,ef=e=>{ep=requestAnimationFrame(ef);let t=e-eh;if(t<em-1)return;let r=Math.min(t/1e3,.05);eh=e,Z=Z.filter(e=>{e.t+=r/e.dur;let t=Math.min(e.t,1),n=t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2;return"pop"===e.kind?e.group.scale.setScalar(n):(e.group.rotation.x=e.fromRot+n*Math.PI,e.group.position.y=.02+.07+.18*Math.sin(n*Math.PI)),t<1}),W.children.forEach((t,n)=>{t.scale.setScalar(1+.08*Math.sin(e/300+n))}),D.update(r,e),V.update(),n.render()};ep=requestAnimationFrame(ef);let eg=()=>{cancelAnimationFrame(ep),document.hidden||(eh=performance.now(),ep=requestAnimationFrame(ef))};return document.addEventListener("visibilitychange",eg),()=>{for(let e of(cancelAnimationFrame(ep),document.removeEventListener("visibilitychange",eg),$++,m.domElement.removeEventListener("pointerdown",ec),m.domElement.removeEventListener("pointerup",eu),V.dispose(),b.dispose(),D.dispose(),[F,I,A,P,O]))e.dispose();_.dispose(),L.dispose(),Y.dispose(),G.dispose(),B.dispose(),n.dispose()}},[]);let C=b.over?"Game over":"ai"===t?1===b.turn?"Your move":"AI is thinking…":1===b.turn?"Light to move":"Dark to move";return(0,r.jsxs)("div",{className:"select-none",children:[(0,r.jsxs)("div",{className:"mb-4 flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[(0,r.jsxs)("div",{className:"flex rounded-xl bg-white/10 p-1",children:[(0,r.jsx)("button",{onClick:()=>{n("ai"),E.current.restart()},className:"rounded-lg px-3 py-1.5 font-semibold transition ".concat("ai"===t?"bg-emerald-600 text-white":"text-zinc-300"),children:"vs AI"}),(0,r.jsx)("button",{onClick:()=>{n("2p"),E.current.restart()},className:"rounded-lg px-3 py-1.5 font-semibold transition ".concat("2p"===t?"bg-emerald-600 text-white":"text-zinc-300"),children:"2 Players"})]}),"ai"===t&&(0,r.jsx)("div",{className:"flex rounded-xl bg-white/10 p-1",children:["easy","medium","hard"].map(e=>(0,r.jsx)("button",{onClick:()=>x(e),className:"rounded-lg px-3 py-1.5 font-semibold capitalize transition ".concat(m===e?"bg-amber-600 text-white":"text-zinc-300"),children:e},e))})]}),(0,r.jsx)("button",{onClick:()=>E.current.restart(),className:"rounded-xl bg-gradient-to-r from-emerald-600 to-teal-600 px-4 py-2 font-bold text-white transition hover:scale-105",children:"New Game"})]}),(0,r.jsxs)("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2 text-sm",children:[(0,r.jsx)("span",{className:"rounded-full bg-white/10 px-4 py-1.5 font-semibold text-zinc-200",children:N?"\uD83E\uDD14 AI is thinking…":C}),(0,r.jsxs)("span",{className:"rounded-full bg-white/10 px-4 py-1.5 text-zinc-400",children:["⚪ ",(0,r.jsx)("strong",{className:"text-zinc-200",children:b.light})," \xb7 ⚫"," ",(0,r.jsx)("strong",{className:"text-zinc-200",children:b.dark})]})]}),(0,r.jsx)("div",{"data-board":!0,ref:e,className:"relative mx-auto aspect-square w-full touch-none overflow-hidden rounded-2xl border border-white/10 sm:aspect-[4/3]",style:{maxWidth:"min(100%, calc(84vh * 1.333))"},role:"application","aria-label":"3D Reversi (Othello). Click a highlighted square to place a disc and flip your opponent's pieces.",children:b.over&&b.banner&&(0,r.jsxs)("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-4 bg-black/60 backdrop-blur-[2px]",children:[(0,r.jsx)("p",{className:"animate-bounce-in px-4 text-center text-3xl font-extrabold text-white",children:b.banner}),(0,r.jsx)("button",{onClick:()=>E.current.restart(),className:"rounded-xl bg-gradient-to-r from-emerald-600 to-teal-600 px-6 py-3 font-bold text-white transition hover:scale-105",children:"⚫ Play again"})]})}),(0,r.jsx)("p",{className:"mt-3 text-center text-sm text-zinc-500",children:"\uD83D\uDDB1️ Click a green square to place a disc \xb7 Tra
1p the opponent's discs between yours to flip them \xb7 Drag to orbit \xb7 Most discs wins"})]})}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.